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]

The difference in behavior between ld and gold when processing "start group/end group" option


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]