This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Weird LD problems
- From: Ian Lance Taylor <ian at airs dot com>
- To: "John Anthony Kazos Jr." <jkazos at vt dot edu>
- Cc: binutils at sources dot redhat dot com
- Date: 26 May 2003 09:37:41 -0700
- Subject: Re: Weird LD problems
- References: <5.2.1.1.0.20030525203808.00a2c7a0@pop.vt.edu>
"John Anthony Kazos Jr." <jkazos@vt.edu> writes:
> I copied /lib/ld-linux.so.2 to my current dir as ld-test.so, and I
> copied /lib/libc.so.6 to my current dir as libc-test.so. I used "gcc
> -c" to make a main.o from my main.c. (When I did a normal "gcc main.c
> -o test" and "./test; echo $?" it worked fine.) But I just can't get
> it to work, giving me strange file-not-found and _start not found and
> other things.
Use gcc -v to see precisely how gcc invokes the linker. If you
emulate that precisely, it should work, even if you rename the files.
> What I am trying to do is separate linking from loading. I want to say
> "go look at /a/b/c/something.so, and there's your symbols to link
> against. Now, when you get run, I want you to use 'somethingelse.so'
> as your loader and 'funstuff.so' as that library, and let the system
> figure out where they are." How can I do this? I am trying to
> eliminate all instances of hard-coded directories in my executables,
> so that a package dir can be anywhere (and can be moved anywhere) and
> work.
You can change names from link time to run time by using DT_SONAME in
the shared libraries you link against. Or I suppose you could do it
by fiddling ld.so. I don't think there is any straightforward way to
do it.
Ian