diff options
author | Florian Weimer <fweimer@redhat.com> | 2021-03-25 11:05:37 +0100 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2021-03-25 12:33:02 +0100 |
commit | 0923f74adaa2827264a0d7cbe51ba287fc0f0c16 (patch) | |
tree | 06778dcf88a5b0ac149f3c23d5cb85de4a2f78b7 /sysdeps/generic | |
parent | 6d8fcee694b9581630a7f27fcbf0009fc44d7baa (diff) | |
download | glibc-0923f74adaa2827264a0d7cbe51ba287fc0f0c16.tar.gz glibc-0923f74adaa2827264a0d7cbe51ba287fc0f0c16.tar.xz glibc-0923f74adaa2827264a0d7cbe51ba287fc0f0c16.zip |
Support for multiple versions in versioned_symbol, compat_symbol
This essentially folds compat_symbol_unique functionality into compat_symbol. This change eliminates the need for intermediate aliases for defining multiple symbol versions, for both compat_symbol and versioned_symbol. Some binutils versions do not suport multiple versions per symbol on some targets, so aliases are automatically introduced, similar to what compat_symbol_unique did. To reduce symbol table sizes, a configure check is added to avoid these aliases if they are not needed. The new mechanism works with data symbols as well as function symbols, due to the way an assembler-level redirect is used. It is not compatible with weak symbols for old binutils versions, which is why the definition of __malloc_initialize_hook had to be changed. This is not a loss of functionality because weak symbols do not matter to dynamic linking. The placeholder symbol needs repeating in nptl/libpthread-compat.c now that compat_symbol is used, but that seems more obvious than introducing yet another macro. A subtle difference was that compat_symbol_unique made the symbol global automatically. compat_symbol does not do this, so static had to be removed from the definition of __libpthread_version_placeholder. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'sysdeps/generic')
-rw-r--r-- | sysdeps/generic/libc-symver.h | 56 |
1 files changed, 53 insertions, 3 deletions
diff --git a/sysdeps/generic/libc-symver.h b/sysdeps/generic/libc-symver.h index 11c77ae1cd..69d147e2a8 100644 --- a/sysdeps/generic/libc-symver.h +++ b/sysdeps/generic/libc-symver.h @@ -22,17 +22,67 @@ #ifndef _LIBC_SYMVER_H #define _LIBC_SYMVER_H 1 +#include <config.h> + /* Use symbol_version_reference to specify the version a symbol reference should link to. Use symbol_version or default_symbol_version for the definition of a versioned symbol. The difference is that the latter is a no-op in non-shared - builds. */ + builds. + + _set_symbol_version is similar to symbol_version_reference, except + that this macro expects the name and symbol version as a single + string or token sequence, with an @ or @@ separator. (A string is + used in C mode and a token sequence in assembler mode.) + _set_symbol_version only be used for definitions because it may + introduce an alias symbol that would not be globally unique for + mere references. The _set_symbol_version macro is used to define + default_symbol_version and compat_symbol. */ + #ifdef __ASSEMBLER__ # define symbol_version_reference(real, name, version) \ .symver real, name##@##version -#else /* !__ASSEMBLER__ */ +#else # define symbol_version_reference(real, name, version) \ __asm__ (".symver " #real "," #name "@" #version) -#endif +#endif /* !__ASSEMBLER__ */ + +#if SYMVER_NEEDS_ALIAS +/* If the assembler cannot support multiple versions for the same + symbol, introduce __SInnn_ aliases to which the symbol version is + attached. */ +# define __symbol_version_unique_concat(x, y) __SI ## x ## _ ## y +# define _symbol_version_unique_concat(x, y) \ + __symbol_version_unique_concat (x, y) +# define _symbol_version_unique_alias(name) \ + _symbol_version_unique_concat (name, __COUNTER__) +# ifdef __ASSEMBLER__ +# define _set_symbol_version_2(real, alias, name_version) \ + .globl alias ASM_LINE_SEP \ + .equiv alias, real ASM_LINE_SEP \ + .symver alias, name_version +# else +# define _set_symbol_version_2(real, alias, name_version) \ + __asm__ (".globl " #alias "\n\t" \ + ".equiv " #alias ", " #real "\n\t" \ + ".symver " #alias "," name_version) +# endif +# define _set_symbol_version_1(real, alias, name_version) \ + _set_symbol_version_2 (real, alias, name_version) +/* REAL must be globally unique, so that the counter also produces + globally unique symbols. */ +# define _set_symbol_version(real, name_version) \ + _set_symbol_version_1 (real, _symbol_version_unique_alias (real), \ + name_version) +# else /* !SYMVER_NEEDS_ALIAS */ +# ifdef __ASSEMBLER__ +# define _set_symbol_version(real, name_version) \ + .symver real, name_version +# else +# define _set_symbol_version(real, name_version) \ + __asm__ (".symver " #real "," name_version) +# endif +#endif /* !SYMVER_NEEDS_ALIAS */ + #endif /* _LIBC_SYMVER_H */ |