How to find where a symbol is placed when linking
To find where a symbol is placed when linking you must find the section that defines the symbol, and ensure that the linker has not removed the section.
To find where a symbol is placed when linking, use the --keep=section_id
and
--symbols
options. For example, if object(section)
is the section containing the
symbol, enter:
armlink --keep=object(section) --symbols s.o --output=s.axf
Note
You can also run fromelf -s
on the resultant
image.
Examples
Do the following:
Create the file s.c containing the following source code:
long long altstack[10] __attribute__ ((section ("STACK"), zero_init)); int main(void) { return sizeof(altstack); }
Compile the source:
armcc -c s.c -o s.o
Link the object s.o, keeping the
STACK
symbol and displaying the symbols:armlink --keep=s.o(STACK) --symbols s.o --output=s.axf
Locate the
STACK
symbol in the output, for example:====================================================================== Image Symbol Table Local Symbols Symbol Name Value Ov Type Size Object(Section) … STACK 0x00008200 Section 80 s.o(STACK) Global Symbols Symbol Name Value Ov Type Size Object(Section) … altstack 0x00008200 Data 80 s.o(STACK) Image$$ZI$$Limit 0x00008250 Number 0 s.o(STACK)
This shows that the stack is placed in the ZI execution region.