Question about ld's symbol resolution
A Wang
aw@squareup.com
Wed Jun 17 00:20:14 GMT 2020
Hi,
I've got a project that makes use of library groups (i.e. --start-group
archives --end-group). I was hoping someone could describe this line from
the man page in more detail:
```
The specified archives are searched repeatedly until no new undefined
references are created.
```
Let's say my build command looks like this:
arm-none-eabi-gcc -g -Os -mthumb -mcpu=cortex-m4 -ffunction-sections
-fdata-sections --specs=nano.specs --specs=nosys.specs -Wl,--gc-sections -o
main.elf -Wl,--start-group main.a _my_write.a -lc -Wl,--end-group
If newlib (-lc) referenced a new symbol, the symbol will be added to the
list of undefined references. Would the linker start searching for this new
undefined reference from the beginning of the library list? Or would it
continue searching through libc's object files from the point where it
found the new reference? For example, libc_nano.a's lib_a-stdio.o
references `_write`, should the linker choose the definition of `_write`
from `_my_write.a` since it comes before libc in the linked library order?
Thanks in advance.
From,
AW
More information about the Binutils
mailing list