mbox

[RFC,0/2] Transparent multi-version symbol support

Message ID cover.1616095061.git.fweimer@redhat.com
Headers

Message

Florian Weimer March 18, 2021, 8:06 p.m. UTC
  This turned out to be way harder than it should be.  Older binutils does
not support multiple .symver directives for the same first symbol, so we
have various kludges like (from time/clock_settime.c):

| versioned_symbol (libc, __clock_settime, clock_settime, GLIBC_2_17);
| 
| /* clock_settime moved to libc in version 2.17;
|    old binaries may expect the symbol version it had in librt.  */
| #if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_17)
| strong_alias (__clock_settime, __clock_settime_2);
| compat_symbol (libc, __clock_settime_2, clock_settime, GLIBC_2_2);
| #endif

I think I have found a way to do this with assembler hacks, so that it
applies to function and data symbols alike.  With this, the above
snipper becomes:

| versioned_symbol (libc, __clock_settime, clock_settime, GLIBC_2_17);
| 
| /* clock_settime moved to libc in version 2.17;
|    old binaries may expect the symbol version it had in librt.  */
| #if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_17)
| compat_symbol (libc, __clock_settime, clock_settime, GLIBC_2_2);
| #endif

So the explicit aliases are gone.

Built with build-many-glibcs.py with binutils 2.36 and 2.34.  Tested on
i686-linux-gnu and x86_64-linux-gnu with binutils 2.34 and 2.35.

The object files aren't unchanged due to the __malloc_initialize_hook
change (and presumably others, I haven't looked closely).

Thanks,
Florian

Florian Weimer (2):
  Change how the symbol_version_reference macro is defined
  Fold compat_symbol_unique functionality into compat_symbol

 config.h.in                   |  4 ++
 configure                     | 28 +++++++++++
 configure.ac                  | 21 +++++++++
 include/libc-symbols.h        | 21 +++------
 include/shlib-compat.h        | 55 +++++++---------------
 locale/lc-ctype.c             | 14 +++---
 malloc/malloc.c               |  2 +-
 nptl/libpthread-compat.c      | 16 +++----
 sysdeps/generic/libc-symver.h | 88 +++++++++++++++++++++++++++++++++++
 sysdeps/ia64/libc-symver.h    | 33 +++++++++++++
 time/clock_getcpuclockid.c    |  3 +-
 time/clock_getres.c           |  3 +-
 time/clock_gettime.c          |  3 +-
 time/clock_nanosleep.c        |  3 +-
 time/clock_settime.c          |  3 +-
 15 files changed, 219 insertions(+), 78 deletions(-)
 create mode 100644 sysdeps/generic/libc-symver.h
 create mode 100644 sysdeps/ia64/libc-symver.h