[PATCH 1/4] elf: Introduce generic <dl-tls.h>

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon Dec 30 19:38:35 GMT 2024



On 27/12/24 12:37, Florian Weimer wrote:
> On arc, the definition of TLS_DTV_UNALLOCATED now comes from
> <dl-dtv.h>.
> 
> For x86-64 x32, a separate version is needed because unsigned long int
> is 32 bits on this target.

LGTM, thanks.

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

> ---
>  sysdeps/aarch64/dl-tls.h          | 27 ----------------------
>  sysdeps/alpha/dl-tls.h            | 27 ----------------------
>  sysdeps/arc/dl-tls.h              | 30 ------------------------
>  sysdeps/arm/dl-tls.h              | 28 -----------------------
>  sysdeps/csky/dl-tls.h             | 26 ---------------------
>  sysdeps/generic/dl-tls.h          | 38 +++++++++++++++++++++++++++++--
>  sysdeps/hppa/dl-tls.h             | 28 -----------------------
>  sysdeps/i386/dl-tls.h             |  3 +++
>  sysdeps/microblaze/dl-tls.h       | 26 ---------------------
>  sysdeps/or1k/dl-tls.h             | 27 ----------------------
>  sysdeps/sh/dl-tls.h               | 28 -----------------------
>  sysdeps/sparc/dl-tls.h            | 28 -----------------------
>  sysdeps/x86_64/{ => x32}/dl-tls.h |  4 ++++
>  13 files changed, 43 insertions(+), 277 deletions(-)
>  delete mode 100644 sysdeps/aarch64/dl-tls.h
>  delete mode 100644 sysdeps/alpha/dl-tls.h
>  delete mode 100644 sysdeps/arc/dl-tls.h
>  delete mode 100644 sysdeps/arm/dl-tls.h
>  delete mode 100644 sysdeps/csky/dl-tls.h
>  delete mode 100644 sysdeps/hppa/dl-tls.h
>  delete mode 100644 sysdeps/microblaze/dl-tls.h
>  delete mode 100644 sysdeps/or1k/dl-tls.h
>  delete mode 100644 sysdeps/sh/dl-tls.h
>  delete mode 100644 sysdeps/sparc/dl-tls.h
>  rename sysdeps/x86_64/{ => x32}/dl-tls.h (91%)
> 
> diff --git a/sysdeps/aarch64/dl-tls.h b/sysdeps/aarch64/dl-tls.h
> deleted file mode 100644
> index c7c8c114c6..0000000000
> --- a/sysdeps/aarch64/dl-tls.h
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Copyright (C) 2005-2024 Free Software Foundation, Inc.
> -
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public License as
> -   published by the Free Software Foundation; either version 2.1 of the
> -   License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -/* Type used for the representation of TLS information in the GOT.  */
> -typedef struct
> -{
> -  unsigned long int ti_module;
> -  unsigned long int ti_offset;
> -} tls_index;
> -
> -
> -extern void *__tls_get_addr (tls_index *ti);
> diff --git a/sysdeps/alpha/dl-tls.h b/sysdeps/alpha/dl-tls.h
> deleted file mode 100644
> index ccea4e15c6..0000000000
> --- a/sysdeps/alpha/dl-tls.h
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Thread-local storage handling in the ELF dynamic linker.  Alpha version.
> -   Copyright (C) 2002-2024 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -
> -/* Type used for the representation of TLS information in the GOT.  */
> -typedef struct
> -{
> -  unsigned long int ti_module;
> -  unsigned long int ti_offset;
> -} tls_index;
> -
> -extern void *__tls_get_addr (tls_index *ti);
> diff --git a/sysdeps/arc/dl-tls.h b/sysdeps/arc/dl-tls.h
> deleted file mode 100644
> index e498fab8fe..0000000000
> --- a/sysdeps/arc/dl-tls.h
> +++ /dev/null
> @@ -1,30 +0,0 @@
> -/* Thread-local storage handling in the ELF dynamic linker.  ARC version.
> -   Copyright (C) 2020-2024 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -
> -/* Type used for the representation of TLS information in the GOT.  */
> -typedef struct
> -{
> -  unsigned long int ti_module;
> -  unsigned long int ti_offset;
> -} tls_index;
> -
> -extern void *__tls_get_addr (tls_index *ti);
> -
> -/* Value used for dtv entries for which the allocation is delayed.  */
> -#define TLS_DTV_UNALLOCATED	((void *) -1l)
> diff --git a/sysdeps/arm/dl-tls.h b/sysdeps/arm/dl-tls.h
> deleted file mode 100644
> index fe244dd728..0000000000
> --- a/sysdeps/arm/dl-tls.h
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Thread-local storage handling in the ELF dynamic linker.  ARM version.
> -   Copyright (C) 2005-2024 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -
> -/* Type used for the representation of TLS information in the GOT.  */
> -typedef struct dl_tls_index
> -{
> -  unsigned long int ti_module;
> -  unsigned long int ti_offset;
> -} tls_index;
> -
> -
> -extern void *__tls_get_addr (tls_index *ti);
> diff --git a/sysdeps/csky/dl-tls.h b/sysdeps/csky/dl-tls.h
> deleted file mode 100644
> index 3027553abd..0000000000
> --- a/sysdeps/csky/dl-tls.h
> +++ /dev/null
> @@ -1,26 +0,0 @@
> -/* Thread-local storage handling in the ELF dynamic linker.  C-SKY version.
> -   Copyright (C) 2018-2024 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -/* Type used for the representation of TLS information in the GOT.  */
> -typedef struct
> -{
> -  unsigned long int ti_module;
> -  unsigned long int ti_offset;
> -} tls_index;
> -
> -extern void *__tls_get_addr (tls_index *ti);
> diff --git a/sysdeps/generic/dl-tls.h b/sysdeps/generic/dl-tls.h
> index 7703a97525..5cdd211a16 100644
> --- a/sysdeps/generic/dl-tls.h
> +++ b/sysdeps/generic/dl-tls.h
> @@ -1,2 +1,36 @@
> -/* There has to be an architecture specific version of this file.  */
> -#error "architecture-specific version of <dl-tls.h> missing"
> +/* TLS definitions for the ELF dynamic linker.  Generic version.
> +   Copyright (C) 2002-2024 Free Software Foundation, Inc.
> +
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public License as
> +   published by the Free Software Foundation; either version 2.1 of the
> +   License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#ifndef _DL_TLS_H
> +#define _DL_TLS_H
> +
> +/* Type used for the representation of TLS information in the GOT.  */
> +typedef struct
> +{
> +  unsigned long int ti_module;
> +  unsigned long int ti_offset;
> +} tls_index;
> +
> +extern void *__tls_get_addr (tls_index *ti);
> +
> +/* Dynamic thread vector pointers point to the start of each
> +   TLS block.  */
> +#define TLS_DTV_OFFSET 0
> +
> +#endif /* _DL_TLS_H */
> diff --git a/sysdeps/hppa/dl-tls.h b/sysdeps/hppa/dl-tls.h
> deleted file mode 100644
> index bbf7d76f2f..0000000000
> --- a/sysdeps/hppa/dl-tls.h
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Thread-local storage handling in the ELF dynamic linker.  hppa version.
> -   Copyright (C) 2003-2024 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -
> -/* Type used for the representation of TLS information in the GOT.  */
> -typedef struct
> -{
> -  unsigned long int ti_module;
> -  unsigned long int ti_offset;
> -} tls_index;
> -
> -
> -extern void *__tls_get_addr (tls_index *ti);
> diff --git a/sysdeps/i386/dl-tls.h b/sysdeps/i386/dl-tls.h
> index f17286703d..21bf017014 100644
> --- a/sysdeps/i386/dl-tls.h
> +++ b/sysdeps/i386/dl-tls.h
> @@ -24,6 +24,9 @@ typedef struct dl_tls_index
>    unsigned long int ti_offset;
>  } tls_index;
>  
> +/* Dynamic thread vector pointers point to the start of each
> +   TLS block.  */
> +#define TLS_DTV_OFFSET 0
>  
>  #ifdef SHARED
>  /* This is the prototype for the GNU version.  */
> diff --git a/sysdeps/microblaze/dl-tls.h b/sysdeps/microblaze/dl-tls.h
> deleted file mode 100644
> index 8053a716cb..0000000000
> --- a/sysdeps/microblaze/dl-tls.h
> +++ /dev/null
> @@ -1,26 +0,0 @@
> -/* Copyright (C) 2005-2024 Free Software Foundation, Inc.
> -
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public License as
> -   published by the Free Software Foundation; either version 2.1 of the
> -   License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -/* Type used for the representation of TLS information in the GOT.  */
> -typedef struct
> -{
> -  unsigned long int ti_module;
> -  unsigned long int ti_offset;
> -} tls_index;
> -
> -extern void *__tls_get_addr (tls_index *ti);
> diff --git a/sysdeps/or1k/dl-tls.h b/sysdeps/or1k/dl-tls.h
> deleted file mode 100644
> index 780ecadbf1..0000000000
> --- a/sysdeps/or1k/dl-tls.h
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* TLS definitions for the ELF dynamic linker.  OpenRISC version.
> -   Copyright (C) 2022-2024 Free Software Foundation, Inc.
> -
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public License as
> -   published by the Free Software Foundation; either version 2.1 of the
> -   License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -/* Type used for the representation of TLS information in the GOT.  */
> -typedef struct
> -{
> -  unsigned long int ti_module;
> -  unsigned long int ti_offset;
> -} tls_index;
> -
> -extern void *__tls_get_addr (tls_index *ti);
> diff --git a/sysdeps/sh/dl-tls.h b/sysdeps/sh/dl-tls.h
> deleted file mode 100644
> index 70cbe28b90..0000000000
> --- a/sysdeps/sh/dl-tls.h
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Thread-local storage handling in the ELF dynamic linker.  SH version.
> -   Copyright (C) 2002-2024 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -
> -/* Type used for the representation of TLS information in the GOT.  */
> -typedef struct
> -{
> -  unsigned long int ti_module;
> -  unsigned long int ti_offset;
> -} tls_index;
> -
> -
> -extern void *__tls_get_addr (tls_index *ti);
> diff --git a/sysdeps/sparc/dl-tls.h b/sysdeps/sparc/dl-tls.h
> deleted file mode 100644
> index 5af2dc750d..0000000000
> --- a/sysdeps/sparc/dl-tls.h
> +++ /dev/null
> @@ -1,28 +0,0 @@
> -/* Thread-local storage handling in the ELF dynamic linker.  SPARC version.
> -   Copyright (C) 2003-2024 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <https://www.gnu.org/licenses/>.  */
> -
> -
> -/* Type used for the representation of TLS information in the GOT.  */
> -typedef struct
> -{
> -  unsigned long int ti_module;
> -  unsigned long int ti_offset;
> -} tls_index;
> -
> -
> -extern void *__tls_get_addr (tls_index *ti);
> diff --git a/sysdeps/x86_64/dl-tls.h b/sysdeps/x86_64/x32/dl-tls.h
> similarity index 91%
> rename from sysdeps/x86_64/dl-tls.h
> rename to sysdeps/x86_64/x32/dl-tls.h
> index fde9f5493a..644ed90032 100644
> --- a/sysdeps/x86_64/dl-tls.h
> +++ b/sysdeps/x86_64/x32/dl-tls.h
> @@ -31,4 +31,8 @@ typedef struct dl_tls_index
>  
>  extern void *__tls_get_addr (tls_index *ti);
>  
> +/* Dynamic thread vector pointers point to the start of each
> +   TLS block.  */
> +#define TLS_DTV_OFFSET 0
> +
>  #endif /* _X86_64_DL_TLS_H */



More information about the Libc-alpha mailing list