This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hello, First of all this is my first time posting on this mailing list, please forgive me if somehow I'm doing something wrong. When laying out symbols in the address space using a linker script, ld allows to refer to a specific symbol coming from a specific object file inside a static library with the following syntax: archive.a:object_file.o(.section.symbol_name) Using gold rather than ld, it seems that such a directive is ignored. The linking process succeeds. However, when using this instruction to put a specific symbol at a specific location with gold and checking the resulting symbols layout using nm or having a look at the Map file, the symbol is not in the expected location. I made a small test case using a dummy hello world program statically compiled in its entirety with gcc 5.4.0. The C library is musl libc (last commit on the master branch from the official git repository). For binutils, I also use the last commit on the master branch from the official git repository. I use the linker script to place a specific symbol (.text.exit) from a static library (musl C library: libc.a) at a specific location in the address space which is: the first position in the .text section. I'm doing this using the linker script attached to this email. I also attach my Makefile and the C program (it's a trivial hello world). After compiling and linking I'm checking the map file (obtained using the -Map ld/gold flag) to have a look at the location of .text.exit. Using ld as the linker, it is indeed in the first position of the text section. Using gold, it is not (it is present farther in the address space, as if my directive was not taken into account). Now, while neither of these work with gold: musl/lib/libc.a:exit.o(.text.exit); musl/lib/libc.a(.text.exit); This works: *(.text.exit); Is that a missing feature in gold? or am I doing something wrong, maybe there is another way to refer to a specific symbol of a specific object file in an archive using gold? Thank you very much, Pierre
Attachment:
linker-script.x
Description: Binary data
Attachment:
Makefile
Description: Binary data
#include <stdio.h> #include <stdlib.h> int main(void) { printf("hello world\n"); return 0; }
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |