question of compatibility between different GLIBC symbol versions
Fangrui Song
maskray@google.com
Fri Jul 21 02:55:49 GMT 2023
On Thu, Jul 20, 2023 at 4:47 AM robert rozee via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> > Sent: Tuesday, July 18, 2023 at 8:00 PM
> > From: "Florian Weimer" <fweimer@redhat.com>
> >> (1) Is it OK to use unversioned libc symbols through 'manipulation' of
> >> the compile-time linking process? This will result in the binary
> >> picking up the latest version of each symbol at run-time.
>
> > At run time, it really should be the earliest implemented (base)
> > version, otherwise we have a bug.
>
> > At static link time, the link editor picks the default symbol version,
> > which is usually the most recent symbol version.
>
> on first reading i missed the significance of this:
> "At run time [...] the earliest implemented (base) version"
>
> i had always assumed (incorrectly!) that at run-time an unversioned symbol
> in an application binary was matched up with the most recent (@@) symbol
> in libc.
https://maskray.me/blog/2020-11-26-all-about-symbol-versioning#rtld-behavior
has some description about this behavior near "When searching a
definition for foo," :)
The rtld behavior is to retains compatibility when a shared object
becomes versioned: the symbols with the smallest version (index 2)
indicate the previously unversioned symbols. If a new version of a
shared object needs to deprecate an unversioned bar, you can remove
bar and define bar@compat instead. Libraries using bar are unaffected
but new linking against bar is disallowed.
> using something like readelf, how does one check to see which is the base
> version of a symbol? the below (against GLIBC 2.27) seems to show no
> distinction:
% readelf -V =ld.so
...
Version definition section '.gnu.version_d' contains 7 entries:
Addr: 0x0000000000000bd8 Offset: 0x00000bd8 Link: 5 (.dynstr)
000000: Rev: 1 Flags: BASE Index: 1 Cnt: 1 Name: ld-linux-x86-64.so.2
0x001c: Rev: 1 Flags: none Index: 2 Cnt: 1 Name: GLIBC_2.2.5
////////// base version
> $ readelf -a /lib/x86_64-linux-gnu/libc.so.6 | grep " sys_nerr"
> 2074: 00000000001bc9dc 4 OBJECT GLOBAL DEFAULT 16 sys_nerr@GLIBC_2.2.5
> 2076: 00000000001bc9e4 4 OBJECT GLOBAL DEFAULT 16 sys_nerr@GLIBC_2.4
> 2077: 00000000001bc9d8 4 OBJECT GLOBAL DEFAULT 16 sys_nerr@@GLIBC_2.12
> 2079: 00000000001bc9e0 4 OBJECT GLOBAL DEFAULT 16 sys_nerr@GLIBC_2.3
>
>
> cheers,
> rob :-)
--
宋方睿
More information about the Libc-alpha
mailing list