tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: "Fixing" new ld(1) DT_NEEDED handling



On 10/14/13 10:22, Martin Husemann wrote:
Isn't that the desired behaviour?
That is an example of correct behaviour, but not what this thread is about:
your main() does only reference libmain(), and this is properly recorded.

You trigger the issue when you modify main to reference func_a() but not
libmain().


Hmm, what exactly is the problem?

$ cat main.c
#include <stdio.h>

//extern char *libfunc(void);
extern char *func_a(void);


int main(void)
{
        //printf ("lib returns: '%s'\n", libfunc());
        printf ("funca returns: '%s'\n", func_a());
        return 0;
}
$ gcc -o main main.c libmain.so -Wl,-rpath,.
/tmp/binu/bin/ld: /tmp/ccqNBHIw.o: undefined reference to symbol 'func_a'
./libfunca.so: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
$ gcc -o main main.c libmain.so libfunca.so -Wl,-rpath,.
$ ./main
funca returns: '<funca>'
$ readelf -a main| grep NEEDED
 0x0000000000000001 (NEEDED)             Shared library: [libmain.so]
 0x0000000000000001 (NEEDED)             Shared library: [libfunca.so]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
$


regards,
chris



Home | Main Index | Thread Index | Old Index