This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
The difference in behavior between ld and gold when processing "start group/end group" option
- From: "Nikola Ikonic" <Nikola dot Ikonic at rt-rk dot com>
- To: binutils at sourceware dot org
- Cc: "Petar Jovanovic" <Petar dot Jovanovic at rt-rk dot com>
- Date: Tue, 03 Mar 2015 18:19:45 +0100
- Subject: The difference in behavior between ld and gold when processing "start group/end group" option
- Authentication-results: sourceware.org; auth=none
Hello,
I have found a difference in behavior of gold and GNU ld when processing command line in one specific case when "start group/end group" is used in conjuction with linker script, and I am wondering if this difference is intentional or possible bug in either of linkers. In the example I have made, two libraries (libtest.a/libtest2.a) have different definitions of the same function and the command line uses linker script with a library name inside "start group/end group" option. Linker script only includes other libraries. When the same line is given to gold and GNU LD they call function from different libraries.
EXAMPLE:
main.c
extern void head_dummy();
int main(){
 head_dummy();
 return 0;
}
test.c
#include <stdio.h>
void dummy_func()
{
 printf("\nthis is library TEST\n\n");
}
test2.c
#include <stdio.h>
void dummy_func()
{
 printf("\nthis is library TEST2\n\n");
}
head_dummy.c
extern void dummy_func();ÂÂ Â
void head_dummy()
{
 dummy_func();
}
libscript.a
GROUP ( libtest2.a libdummy.a )
$ gcc main.o -o main.exe -Wl,--start-group -Wl,-lscript -Wl,-ltest -Wl,--end-group -L./
Executable linked with LD prints "... TEST2" while gold-linked executable prints "... TEST".
Which of these linkers behave correctly?
Thank you in advance for the explanation.