Hi Niels, > Michael Tautschnig <m...@debian.org> writes: > > > src/argp/testsuite/ex3.c:const char *argp_program_bug_address = > > "<bug-gnu-ut...@gnu.org>"; > > src/argp/argp-ba.c:const char *argp_program_bug_address = 0; > > > (The latter goes in src/argp/libargp.a.) > > > > The linker is free to pick either of the values; > > No, the linker does *not* have that freedom. > > A unix linker is supposed to process arguments in order, and bring in > argp-ba.o from libargp.a if and only if the symbol > argp_program_bug_address (the *only* symbol defined in that file) is > referenced in the earlier objects, but *not* defined in the earlier > objects. >
I'm not sure where such behaviour would be specified for a unix linker!? The man page of ld does indeed note this behaviour if (!) -z muldefs is used. But otherwise multiple definitions (unlike multiple common symbols) do not seem to imply any definitive result!? But I'd be happy to learn about more detailed documentation on that matter. > What does your linker command line look like? Order matters, and -largp > must be placed after ex3.o. > This is the command line being used (which has -z defs, but not -z muldefs): gcc -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -ggdb3 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Waggregate-return -Wpointer-arith -Wbad-function-cast -Wnested-externs -Wl,-z,defs -Wl,--as-needed -Wl,-z,relro -o ex3 ex3.o ../libargp.a Best, Michael
pgptT5xES0qHj.pgp
Description: PGP signature