[PATCH] [ELF] Fix undefined symbol handling in DSO.

Joerg Sonnenberger joerg at britannica.bec.de
Mon Apr 7 12:27:17 PDT 2014


On Mon, Apr 07, 2014 at 12:07:20PM -0700, Rui Ueyama wrote:
> On Mon, Apr 7, 2014 at 3:32 AM, Joerg Sonnenberger
> <joerg at britannica.bec.de>wrote:
> 
> > On Sun, Apr 06, 2014 at 09:58:13PM -0700, Rui Ueyama wrote:
> > > Currently LLD ignores undefined symbols found in DSOs when linking
> > against
> > > DSO files, if -shared flag is given. Internally, it's achieved by
> > enabling
> > > "useShlibUndefines" flag, which makes the file reader to ignore all
> > undefined
> > > symbols in DSO, so that Resolver don't see any undefined symbols when
> > > handling DSO files.
> >
> > I don't think your patch fixes the real issue. The correct behavior
> > is:
> >
> > (1) If the undefined symbol comes from an object file (or archive
> > library), it is a true undefined symbol. In this case, the behavior
> > depends on (a) -z defs (b) the output type. For shared libraries,
> > undefined symbols are by default not fatal, for executables, they are.
> >
> 
> That's I believe already implemetned correctly. Please take a look at
> GnuLdDriver.cpp:295.
> 
>  (2) Undefined symbols in shared libraries pulled in via -l are ignored.
> >
> 
> By "ignored", I'd think you mean "undefined symbol from library is not
> fatal", right?

No, I really meant ignored. The most you can or should do about them is
check for consistency of the type. Otherwise they are completely
irrelevant. Trying to resolve them is just going to waste time.

> (3) For ELF, shared libraries are processed recursively.
> 
> Are you talking about runtime behavior? Could you elaborate a bit?

No, link time behavior. GNU folks decided to break this in recent
versions, but ELF has a recursive namespace and the linker should
implement that. A simple case is linking against OpenSSL's libssl. That
one is linked against libcrypto. For that reason, adding -lssl does
add the symbols from libcrypto.so as well. Searching is controlled by
the combination of libssl.so's rpath and the -rpath-link flags.

Joerg



More information about the llvm-commits mailing list