[v2,2/3] locale: Use compat_symbol_reference in _nl_postload_ctype

Message ID f9855e3eb14d4605ca6625a110011ec022a6bd64.1616184336.git.fweimer@redhat.com
State Committed
Commit 6d8fcee694b9581630a7f27fcbf0009fc44d7baa
Headers
Series Transparent support for multiple symbol versions |

Commit Message

Florian Weimer March 19, 2021, 8:07 p.m. UTC
  These symbol usages are not definitions, so compat_symbol_reference is
more appropriate than compat_symbol.  compat_symbol_reference is also
safe to emit multiple times (in case the inline assembly is
duplicated; this is possible because it is nested in a function).
compat_symbol does not necessarily have this property because it is
intended to provide a symbol definition.
---
 locale/lc-ctype.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
  

Comments

Adhemerval Zanella March 24, 2021, 5:11 p.m. UTC | #1
On 19/03/2021 17:07, Florian Weimer via Libc-alpha wrote:
> These symbol usages are not definitions, so compat_symbol_reference is
> more appropriate than compat_symbol.  compat_symbol_reference is also
> safe to emit multiple times (in case the inline assembly is
> duplicated; this is possible because it is nested in a function).
> compat_symbol does not necessarily have this property because it is
> intended to provide a symbol definition.

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  locale/lc-ctype.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/locale/lc-ctype.c b/locale/lc-ctype.c
> index 1db0605c82..7c97480cbd 100644
> --- a/locale/lc-ctype.c
> +++ b/locale/lc-ctype.c
> @@ -93,12 +93,14 @@ _nl_postload_ctype (void)
>       We need those relocations so that a versioned definition with a COPY
>       reloc in an executable will override the libc.so definition.  */
>  
> -compat_symbol (libc, __ctype_b, __ctype_b, GLIBC_2_0);
> -compat_symbol (libc, __ctype_tolower, __ctype_tolower, GLIBC_2_0);
> -compat_symbol (libc, __ctype_toupper, __ctype_toupper, GLIBC_2_0);
> -compat_symbol (libc, __ctype32_b, __ctype32_b, GLIBC_2_0);
> -compat_symbol (libc, __ctype32_tolower, __ctype32_tolower, GLIBC_2_2);
> -compat_symbol (libc, __ctype32_toupper, __ctype32_toupper, GLIBC_2_2);
> +compat_symbol_reference (libc, __ctype_b, __ctype_b, GLIBC_2_0);
> +compat_symbol_reference (libc, __ctype_tolower, __ctype_tolower, GLIBC_2_0);
> +compat_symbol_reference (libc, __ctype_toupper, __ctype_toupper, GLIBC_2_0);
> +compat_symbol_reference (libc, __ctype32_b, __ctype32_b, GLIBC_2_0);
> +compat_symbol_reference (libc, __ctype32_tolower, __ctype32_tolower,
> +			  GLIBC_2_2);
> +compat_symbol_reference (libc, __ctype32_toupper, __ctype32_toupper,
> +			 GLIBC_2_2);
>  
>    __ctype_b = current (uint16_t, CLASS, 128);
>    __ctype_toupper = current (int32_t, TOUPPER, 128);
>
  

Patch

diff --git a/locale/lc-ctype.c b/locale/lc-ctype.c
index 1db0605c82..7c97480cbd 100644
--- a/locale/lc-ctype.c
+++ b/locale/lc-ctype.c
@@ -93,12 +93,14 @@  _nl_postload_ctype (void)
      We need those relocations so that a versioned definition with a COPY
      reloc in an executable will override the libc.so definition.  */
 
-compat_symbol (libc, __ctype_b, __ctype_b, GLIBC_2_0);
-compat_symbol (libc, __ctype_tolower, __ctype_tolower, GLIBC_2_0);
-compat_symbol (libc, __ctype_toupper, __ctype_toupper, GLIBC_2_0);
-compat_symbol (libc, __ctype32_b, __ctype32_b, GLIBC_2_0);
-compat_symbol (libc, __ctype32_tolower, __ctype32_tolower, GLIBC_2_2);
-compat_symbol (libc, __ctype32_toupper, __ctype32_toupper, GLIBC_2_2);
+compat_symbol_reference (libc, __ctype_b, __ctype_b, GLIBC_2_0);
+compat_symbol_reference (libc, __ctype_tolower, __ctype_tolower, GLIBC_2_0);
+compat_symbol_reference (libc, __ctype_toupper, __ctype_toupper, GLIBC_2_0);
+compat_symbol_reference (libc, __ctype32_b, __ctype32_b, GLIBC_2_0);
+compat_symbol_reference (libc, __ctype32_tolower, __ctype32_tolower,
+			  GLIBC_2_2);
+compat_symbol_reference (libc, __ctype32_toupper, __ctype32_toupper,
+			 GLIBC_2_2);
 
   __ctype_b = current (uint16_t, CLASS, 128);
   __ctype_toupper = current (int32_t, TOUPPER, 128);