using linker symbols in assembly .S file
Kameron Larsen
kroylar@gmail.com
Wed Mar 12 23:43:00 GMT 2014
Hello all,
I'm trying to build u-boot for the sparc leon3 processor and I believe
I've run into a problem with ld. u-boot uses a file called start.S as
the start file. This file accesses linker level symbols such as _text,
__init_end, __bss_start, __bss_end, etc. These symbols are all defined
in the linker script using the . (dot) notation within their relative
sections.
I know that with C one can use the extern keyword to access such
symbols. For example,
extern char _text, __init_end;
Then these address can be accessed using & (ampersand), just like any
other variable.
However, I'm noticing that with a .S assembler file, these addresses
are not filling in correctly. I've read in the GNU Assembler
documentation that "`as' treats all undefined symbols
as external." Does this mean that _text in start.S will be left as
undefined if assembled, and that ld will later fill in the correct
definition? If this is the case, then I'm experiencing a problem with
ld. The definitions that are being filled in are not correct.
For example, I build u-boot and use objdump -t to list the symbol
table of the u-boot binary, I can clearly see that _text is located at
0x40000000. So I would expect my use of _text in the start.S file to
show 0x40000000 as well. However, I can use objdump -d on the u-boot
binary to see that the value being filled in for _text is not
0x40000000 but instead some other number.
I'd really appreciate some help in getting to the bottom of this.
Thanks!
-Kameron
More information about the Binutils
mailing list