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: Hard coding paths to shared libraries


"Zack Weinberg" <zack@codesourcery.com> writes:

> The black magic I mentioned is not the same thing as the stuff
> Alexandre was talking about.  DT_AUXILIARY is only black magic because
> the way to create such entries is undocumented as far as I know (which
> also means I don't know how to do it).

To get a DT_AUXILIARY entry, you use the -f/--auxiliary option.  It's
documented in the linker manual.  The documentation is even almost
comprehensible.

> > I am trying to dig into the code to understand what went wrong. It
> > looks like the /vol/cp entries got hardcoded into our binary since
> > the path is showing on the left side of the arrow ( => ). The same
> > appears to have happened with the /lib/ld-linux-ia64.so.2. If I
> > understand how can someone do this on purpose, it may help me spot
> > the issue on the code that we have received from the developers. Any
> > ideas? Sorry, if my original question was not straight to the point.
> 
> This sounds like a more conventional problem involving bad RPATH
> entries.  Suggest you run objdump --private-headers on the binary;
> this will reveal whether it has a NEEDED entry for /vol/cp/.../foo.so,
> an RPATH entry for /vol/cp/.../ and a NEEDED for foo.so, or something
> else entirely.

If a dynamic object has no SONAME entry, then if you link against it,
the actual file name will be used for the NEEDED entry.  What the
actual file name is will probably more or less depend upon how the
linker was invoked.

For example, if I do
    gcc -shared -o foo.so foo.o
(note no -h/--soname option)
    gcc -o bar bar.o /home/ian/foo.so
then bar will get a NEEDED entry of /home/ian/foo.so.

Ian


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