This is the mail archive of the binutils@sources.redhat.com 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]

Re: Weird LD problems


"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


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