cgccassemblybsprtems

Extern Symbol Value Automatically Assigned to the End of RAM


I do not understand why extern symbol equals to the end of ram which is defined in the linker.

In especially, i see that case in the rtems code below:

extern symbol "rdb_start" definition - start.S - line 155 -157

extern symbol "rdb_start" usage - bspgetworkarea.c - line 23-41

For instance, when you define your RAM size 0x800000 in the linker and take your entry address as 0x40000000, then rdb_start value corresponds to the 0x407FFFF0 automatically. If you define any other symbol similar to the rdb_start and make it global as rdb_start, you see the same result. it's value is automatically assigned to 407FFFF0.

why?


Solution

  • I had a similar question while trying to get RTEMS to run on a LEON3 processor. After asking Gaisler (the people who manufacture the LEON3) I learned that rdb_start start stands for "remote debugger start" and is an externally set symbol. It is what's used to set the stack pointer when the program is directly loaded to RAM via a remote debugger (i.e. GRMON) or when unpacked from PROM via your bootloader (i.e. mkprom).

    The stack pointer should generally be set to the end of memory - 1 word. The memory space for a LEON3 processor with 8 MB of RAM, for example, is generally between 0x40000000 - 0x407FFFFF and the stack pointer is set to 0x407FFFF0.

    I was able to change the value of rdb_start by passing the -stack option to mkprom2 and by using the stack command within GRMON to set the value of the new stack pointer.

    I hope this helps the next person trying to figure out what rdb_start in the context of RTEMS is!