Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4085406
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:34:24+00:00 2026-05-20T18:34:24+00:00

Im having problems when I define global variables in a basic C program for

  • 0

Im having problems when I define global variables in a basic C program for an ARM9 processor. I’m using EABI GNU compiler and the binary generated from a 12KB elf is 4GB! I assume the issue is with my scatter file but Im having trouble getting my head around it.

I have 256KB of ROM (base address 0xFFFF0000) and 32KBs of RAM (base 0x01000000)

SECTIONS {
  . = 0xFFFF0000;
  .text : {
    * (vectors);
    * (.text);
  }
  .rodata : { *(.rodata) }
  . = 0x01000000;
  sbss = .;
  .data : { *(.data) }
  .bss  : { *(.bss) }
  ebss = .;
  bssSize = ebss - sbss;
}

And my program is as follows:

int a=10;
int main() {
  int b=5;
  b = (a>b)? a : b;  
  return b;
};

If I declare a as a local variable, i.e. there is no .data section then everything works.
fine. Any help greatly appreciated.

–16th March 2011–
Can anyone help with this, Im getting nowhere and have read the manuals, forums etc…
My boot, compile command and objcopy commands are pasted below

     .section "vectors"
reset:  b   start
undef:  b   undef
swi:    b   swi
pabt:   b   pabt
dabt:   b   dabt
    nop
irq:    b   irq
fiq:    b   fiq
  .text
start:
        ldr   sp, =0x01006000
        bl    main

stop:   b     stop

arm-none-eabi-gcc -mcpu=arm926ej-s -Wall -nostartfiles -Wall main.c boot.s -o main.elf -T \ scatter_file
arm-none-eabi-objcopy ./main.elf –output-target=binary ./main.bin
arm-none-eabi-objdump ./main.elf –disassemble-all > ./main.dis

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:34:25+00:00Added an answer on May 20, 2026 at 6:34 pm

    I found the problem. The objcopy command will try to create the entire address space described in the linker script, from the lowest address to the highest including everything in between. You can tell it to just generate the ROM code as follows:

    objcopy ./main.elf -j ROM –output-target=binary ./main.bin

    I also changed the linker script slightly

    MEMORY {
      ram(WXAIL) : ORIGIN = 0x01000000, LENGTH = 32K    
      rom(RX)    : ORIGIN = 0xFFFF0000, LENGTH = 32K                    
    }
    
    SECTIONS {
      ROM : { 
        *(vectors);
        *(.text);
        *(.rodata);
      } > rom 
    
      RAM : {
        *(.data); 
        *(.bss);
      } > ram 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having problems using textures that are larger than the OpenGL window or the
I am having problems converting a string in the format yyyy-MM-ddZ using VB.net. For
I am having small problem in making a global variable works. I am using
I'm having trouble with using beestings in a heredoc in a global function. The
I'm having some problems displaying the contents of one NSArrayController in two windows defined
Im having problems displaying records to my view when passing viewdata to a user
Im having problems building a query with the linq to sql data query expression
I have recently started having problems with TortoiseCVS, or more specifically with plink, the
I'm having problems deciding on what is the best way is to handle and
I am having problems getting text within a table to appear centered in IE.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.