[PATCH v2] elf: Treat undefined version as hidden

H.J. Lu hjl.tools@gmail.com
Mon Aug 2 02:51:19 GMT 2021


On Sun, Aug 1, 2021 at 7:03 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Sun, Aug 01, 2021 at 07:31:04AM -0700, H.J. Lu via Binutils wrote:
> > Since undefined version can't be used to resolve any references,
>
> Testcase please, specifically when the "undefined version" is that

Here is the v2 patch with a testcase.

> for a .dynbss symbol definition.  I did a little experiment myself and
> I don't think you are correct.  My testcase might be faulty, so please
> write one yourself.
>
> Mine had
> a) One shared lib with a definition of a variable foo, a function to
> print foo seen by that lib, and another function to set a hidden alias
> of foo.  foo was made versioned using a version script.
> b) A second lib with a reference to a foo, a function to print foo
> seen by the lib, and another function to set foo.  No version script
> was used.
> c) A main program with a text reference to foo in order to force a
> dynbss copy of foo.
>
> Output is
>
> b foo = 1
> c foo = 1
> c setting foo to 2
> b foo = 2
> c foo = 2
> b setting foo alias to 3
> b foo = 2
> c foo = 2
>
> readelf shows there is just one dynamic foo in the main program, the
> dynbss copy: GLOBAL DEFAULT 25 foo@VER (2).
>
> LD_DEBUG=all | grep foo shows
>    3541018:     symbol=foo;  lookup in file=./prxxxxx [0]
>    3541018:     binding file ./prxxxxxc.so [0] to ./prxxxxx [0]: normal symbol `foo'
>    3541018:     symbol=foo;  lookup in file=./prxxxxx [0]
>    3541018:     binding file ./prxxxxxb.so [0] to ./prxxxxx [0]: normal symbol `foo' [VER]
>    3541018:     symbol=foo;  lookup in file=./prxxxxx [0]
>    3541018:     binding file ./prxxxxx [0] to ./prxxxxx [0]: normal symbol `foo' [VER]
>    3541018:     symbol=foo;  lookup in file=./prxxxxxb.so [0]
>    3541018:     binding file ./prxxxxx [0] to ./prxxxxxb.so [0]: normal symbol `foo' [VER]
>

It is not the same as hidden since it is used to resolve reference to
unversioned symbol.  But it is not the real definition.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-elf-Treat-undefined-version-as-hidden.patch
Type: text/x-patch
Size: 8841 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20210801/41f962f0/attachment-0001.bin>


More information about the Binutils mailing list