!202 elf: drop elf/tls-macros.h in favor of thread tls_mode attribute

From: @liqingqing_1229
Reviewed-by: @lvying6,@wangbin224
Signed-off-by: @wangbin224
This commit is contained in:
openeuler-ci-bot 2021-09-29 07:17:25 +00:00 committed by Gitee
commit 62e383a696
8 changed files with 2767 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,82 @@
From bca0f5cbc9257c13322b99e55235c4f21ba0bd82 Mon Sep 17 00:00:00 2001
From: Fangrui Song <maskray@google.com>
Date: Wed, 18 Aug 2021 11:13:03 -0700
Subject: [PATCH] arm: Simplify elf_machine_{load_address,dynamic}
and drop reliance on _GLOBAL_OFFSET_TABLE_[0] being the link-time
address of _DYNAMIC. &__ehdr_start is a better way to get the load address.
This is similar to commits b37b75d269883a2c553bb7019a813094eb4e2dd1
(x86-64) and 43d06ed218fc8be58987bdfd00e21e5720f0b862 (aarch64).
Reviewed-by: Joseph Myers <joseph@codesourcery.com>
---
sysdeps/arm/dl-machine.h | 47 ++++++++++-------------------------------------
1 file changed, 10 insertions(+), 37 deletions(-)
diff --git a/sysdeps/arm/dl-machine.h b/sysdeps/arm/dl-machine.h
index ff5e09e..eb13cb8 100644
--- a/sysdeps/arm/dl-machine.h
+++ b/sysdeps/arm/dl-machine.h
@@ -37,48 +37,21 @@ elf_machine_matches_host (const Elf32_Ehdr *ehdr)
return ehdr->e_machine == EM_ARM;
}
-
-/* Return the link-time address of _DYNAMIC. Conveniently, this is the
- first element of the GOT. */
-static inline Elf32_Addr __attribute__ ((unused))
-elf_machine_dynamic (void)
-{
- /* Declaring this hidden ensures that a PC-relative reference is used. */
- extern const Elf32_Addr _GLOBAL_OFFSET_TABLE_[] attribute_hidden;
- return _GLOBAL_OFFSET_TABLE_[0];
-}
-
-
/* Return the run-time load address of the shared object. */
-static inline Elf32_Addr __attribute__ ((unused))
+static inline ElfW(Addr) __attribute__ ((unused))
elf_machine_load_address (void)
{
- Elf32_Addr pcrel_addr;
-#ifdef SHARED
- extern Elf32_Addr __dl_start (void *) asm ("_dl_start");
- Elf32_Addr got_addr = (Elf32_Addr) &__dl_start;
- asm ("adr %0, _dl_start" : "=r" (pcrel_addr));
-#else
- extern Elf32_Addr __dl_relocate_static_pie (void *)
- asm ("_dl_relocate_static_pie") attribute_hidden;
- Elf32_Addr got_addr = (Elf32_Addr) &__dl_relocate_static_pie;
- asm ("adr %0, _dl_relocate_static_pie" : "=r" (pcrel_addr));
-#endif
-#ifdef __thumb__
- /* Clear the low bit of the function address.
-
- NOTE: got_addr is from GOT table whose lsb is always set by linker if it's
- Thumb function address. PCREL_ADDR comes from PC-relative calculation
- which will finish during assembling. GAS assembler before the fix for
- PR gas/21458 was not setting the lsb but does after that. Always do the
- strip for both, so the code works with various combinations of glibc and
- Binutils. */
- got_addr &= ~(Elf32_Addr) 1;
- pcrel_addr &= ~(Elf32_Addr) 1;
-#endif
- return pcrel_addr - got_addr;
+ extern const ElfW(Ehdr) __ehdr_start attribute_hidden;
+ return (ElfW(Addr)) &__ehdr_start;
}
+/* Return the link-time address of _DYNAMIC. */
+static inline ElfW(Addr) __attribute__ ((unused))
+elf_machine_dynamic (void)
+{
+ extern ElfW(Dyn) _DYNAMIC[] attribute_hidden;
+ return (ElfW(Addr)) _DYNAMIC - elf_machine_load_address ();
+}
/* Set up the loaded object described by L so its unrelocated PLT
entries will jump to the on-demand fixup code in dl-runtime.c. */
--
1.8.3.1

View File

@ -0,0 +1,543 @@
From 33c50ef42878b07ee6ead8b3f1a81d8c2c74697c Mon Sep 17 00:00:00 2001
From: Fangrui Song <maskray@google.com>
Date: Mon, 16 Aug 2021 09:59:30 -0700
Subject: [PATCH] elf: Drop elf/tls-macros.h in favor of __thread and tls_model
attributes [BZ #28152] [BZ #28205]
elf/tls-macros.h was added for TLS testing when GCC did not support
__thread. __thread and tls_model attributes are mature now and have been
used by many newer tests.
Also delete tst-tls2.c which tests .tls_common (unused by modern GCC and
unsupported by Clang/LLD). .tls_common and .tbss definition are almost
identical after linking, so the runtime test doesn't add additional
coverage. Assembler and linker tests should be on the binutils side.
When LLD 13.0.0 is allowed in configure.ac
(https://sourceware.org/pipermail/libc-alpha/2021-August/129866.html),
`make check` result is on par with glibc built with GNU ld on aarch64
and x86_64.
As a future clean-up, TLS_GD/TLS_LD/TLS_IE/TLS_IE macros can be removed from
sysdeps/*/tls-macros.h. We can add optional -mtls-dialect={gnu2,trad}
tests to ensure coverage.
Tested on aarch64-linux-gnu, powerpc64le-linux-gnu, and x86_64-linux-gnu.
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
---
elf/Makefile | 4 +-
elf/tls-macros.h | 25 -----------
elf/tst-tls1.c | 64 +++++++++++-----------------
elf/tst-tls2.c | 82 ------------------------------------
elf/tst-tls3.c | 26 +++++-------
elf/tst-tlsmod1.c | 24 +++++------
elf/tst-tlsmod2.c | 6 +--
elf/tst-tlsmod3.c | 8 ++--
elf/tst-tlsmod4.c | 6 +--
elf/tst-tlsmod5.c | 4 +-
elf/tst-tlsmod6.c | 4 +-
sysdeps/powerpc/mod-tlsopt-powerpc.c | 6 +--
sysdeps/powerpc/tst-tlsifunc.c | 4 +-
13 files changed, 64 insertions(+), 199 deletions(-)
delete mode 100644 elf/tls-macros.h
delete mode 100644 elf/tst-tls2.c
diff --git a/elf/Makefile b/elf/Makefile
index d05f410..725537c 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -163,7 +163,7 @@ tests-static-normal := tst-array1-static tst-array5-static \
tst-single_threaded-static tst-single_threaded-pthread-static \
tst-dst-static tst-getauxval-static
-tests-static-internal := tst-tls1-static tst-tls2-static \
+tests-static-internal := tst-tls1-static \
tst-ptrguard1-static tst-stackguard1-static \
tst-tls1-static-non-pie
@@ -183,7 +183,7 @@ endif
tests := tst-tls9 tst-leaks1 \
tst-array1 tst-array2 tst-array3 tst-array4 tst-array5 \
tst-auxv tst-stringtable
-tests-internal := tst-tls1 tst-tls2 $(tests-static-internal)
+tests-internal := tst-tls1 $(tests-static-internal)
tests-static := $(tests-static-normal) $(tests-static-internal)
ifeq (yes,$(build-shared))
diff --git a/elf/tls-macros.h b/elf/tls-macros.h
deleted file mode 100644
index e25e33b..0000000
--- a/elf/tls-macros.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Macros to support TLS testing in times of missing compiler support. */
-
-#define COMMON_INT_DEF(x) \
- asm (".tls_common " #x ",4,4")
-/* XXX Until we get compiler support we don't need declarations. */
-#define COMMON_INT_DECL(x)
-
-/* XXX This definition will probably be machine specific, too. */
-#define VAR_INT_DEF(x) \
- asm (".section .tdata\n\t" \
- ".globl " #x "\n" \
- ".balign 4\n" \
- #x ":\t.long 0\n\t" \
- ".size " #x ",4\n\t" \
- ".previous")
-/* XXX Until we get compiler support we don't need declarations. */
-#define VAR_INT_DECL(x)
-
-#include_next <tls-macros.h>
-
- /* XXX Each architecture must have its own asm for now. */
-#if !defined TLS_LE || !defined TLS_IE \
- || !defined TLS_LD || !defined TLS_GD
-# error "No support for this architecture so far."
-#endif
diff --git a/elf/tst-tls1.c b/elf/tst-tls1.c
index c31da56..b341221 100644
--- a/elf/tst-tls1.c
+++ b/elf/tst-tls1.c
@@ -1,13 +1,14 @@
/* glibc test for TLS in ld.so. */
#include <stdio.h>
-#include "tls-macros.h"
-
-
-/* Two common 'int' variables in TLS. */
-COMMON_INT_DEF(foo);
-COMMON_INT_DEF(bar);
+__thread int foo, bar __attribute__ ((tls_model("local-exec")));
+extern __thread int foo_gd asm ("foo") __attribute__ ((tls_model("global-dynamic")));
+extern __thread int foo_ld asm ("foo") __attribute__ ((tls_model("local-dynamic")));
+extern __thread int foo_ie asm ("foo") __attribute__ ((tls_model("initial-exec")));
+extern __thread int bar_gd asm ("bar") __attribute__ ((tls_model("global-dynamic")));
+extern __thread int bar_ld asm ("bar") __attribute__ ((tls_model("local-dynamic")));
+extern __thread int bar_ie asm ("bar") __attribute__ ((tls_model("initial-exec")));
static int
do_test (void)
@@ -18,63 +19,48 @@ do_test (void)
/* Set the variable using the local exec model. */
puts ("set bar to 1 (LE)");
- ap = TLS_LE (bar);
- *ap = 1;
+ bar = 1;
/* Get variables using initial exec model. */
fputs ("get sum of foo and bar (IE)", stdout);
- ap = TLS_IE (foo);
- bp = TLS_IE (bar);
+ ap = &foo_ie;
+ bp = &bar_ie;
printf (" = %d\n", *ap + *bp);
result |= *ap + *bp != 1;
- if (*ap != 0)
- {
- printf ("foo = %d\n", *ap);
- result = 1;
- }
- if (*bp != 1)
+ if (*ap != 0 || *bp != 1)
{
- printf ("bar = %d\n", *bp);
+ printf ("foo = %d\nbar = %d\n", *ap, *bp);
result = 1;
}
- /* Get variables using local dynamic model. */
- fputs ("get sum of foo and bar (LD)", stdout);
- ap = TLS_LD (foo);
- bp = TLS_LD (bar);
+ /* Get variables using local dynamic model or TLSDESC. */
+ fputs ("get sum of foo and bar (LD or TLSDESC)", stdout);
+ ap = &foo_ld;
+ bp = &bar_ld;
printf (" = %d\n", *ap + *bp);
result |= *ap + *bp != 1;
- if (*ap != 0)
- {
- printf ("foo = %d\n", *ap);
- result = 1;
- }
- if (*bp != 1)
+ if (*ap != 0 || *bp != 1)
{
- printf ("bar = %d\n", *bp);
+ printf ("foo = %d\nbar = %d\n", *ap, *bp);
result = 1;
}
- /* Get variables using generic dynamic model. */
- fputs ("get sum of foo and bar (GD)", stdout);
- ap = TLS_GD (foo);
- bp = TLS_GD (bar);
+ /* Get variables using general dynamic model or TLSDESC. */
+ fputs ("get sum of foo and bar (GD or TLSDESC)", stdout);
+ ap = &foo_gd;
+ bp = &bar_gd;
printf (" = %d\n", *ap + *bp);
result |= *ap + *bp != 1;
- if (*ap != 0)
- {
- printf ("foo = %d\n", *ap);
- result = 1;
- }
- if (*bp != 1)
+ if (*ap != 0 || *bp != 1)
{
- printf ("bar = %d\n", *bp);
+ printf ("foo = %d\nbar = %d\n", *ap, *bp);
result = 1;
}
+
return result;
}
diff --git a/elf/tst-tls2.c b/elf/tst-tls2.c
deleted file mode 100644
index 963b8d6..0000000
--- a/elf/tst-tls2.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/* glibc test for TLS in ld.so. */
-#include <stdio.h>
-
-#include "tls-macros.h"
-
-
-/* Two 'int' variables in TLS. */
-VAR_INT_DEF(foo);
-VAR_INT_DEF(bar);
-
-
-static int
-do_test (void)
-{
- int result = 0;
- int *ap, *bp;
-
-
- /* Set the variable using the local exec model. */
- puts ("set bar to 1 (LE)");
- ap = TLS_LE (bar);
- *ap = 1;
-
-
- /* Get variables using initial exec model. */
- fputs ("get sum of foo and bar (IE)", stdout);
- ap = TLS_IE (foo);
- bp = TLS_IE (bar);
- printf (" = %d\n", *ap + *bp);
- result |= *ap + *bp != 1;
- if (*ap != 0)
- {
- printf ("foo = %d\n", *ap);
- result = 1;
- }
- if (*bp != 1)
- {
- printf ("bar = %d\n", *bp);
- result = 1;
- }
-
-
- /* Get variables using local dynamic model. */
- fputs ("get sum of foo and bar (LD)", stdout);
- ap = TLS_LD (foo);
- bp = TLS_LD (bar);
- printf (" = %d\n", *ap + *bp);
- result |= *ap + *bp != 1;
- if (*ap != 0)
- {
- printf ("foo = %d\n", *ap);
- result = 1;
- }
- if (*bp != 1)
- {
- printf ("bar = %d\n", *bp);
- result = 1;
- }
-
-
- /* Get variables using generic dynamic model. */
- fputs ("get sum of foo and bar (GD)", stdout);
- ap = TLS_GD (foo);
- bp = TLS_GD (bar);
- printf (" = %d\n", *ap + *bp);
- result |= *ap + *bp != 1;
- if (*ap != 0)
- {
- printf ("foo = %d\n", *ap);
- result = 1;
- }
- if (*bp != 1)
- {
- printf ("bar = %d\n", *bp);
- result = 1;
- }
-
- return result;
-}
-
-
-#include <support/test-driver.c>
diff --git a/elf/tst-tls3.c b/elf/tst-tls3.c
index 7e0abb4..222b179 100644
--- a/elf/tst-tls3.c
+++ b/elf/tst-tls3.c
@@ -1,13 +1,12 @@
/* glibc test for TLS in ld.so. */
#include <stdio.h>
-#include "tls-macros.h"
-
-/* One define int variable, two externs. */
-COMMON_INT_DECL(foo);
-VAR_INT_DECL(bar);
-VAR_INT_DEF(baz);
+__thread int foo, bar __attribute__ ((tls_model("initial-exec")));
+__thread int baz __attribute__ ((tls_model("local-exec")));
+extern __thread int foo_gd __attribute__ ((alias("foo"), tls_model("global-dynamic")));
+extern __thread int bar_gd __attribute__ ((alias("bar"), tls_model("global-dynamic")));
+extern __thread int baz_ld __attribute__ ((alias("baz"), tls_model("local-dynamic")));
extern int in_dso (void);
@@ -22,23 +21,20 @@ do_test (void)
/* Set the variable using the local exec model. */
puts ("set baz to 3 (LE)");
- ap = TLS_LE (baz);
- *ap = 3;
+ baz = 3;
/* Get variables using initial exec model. */
puts ("set variables foo and bar (IE)");
- ap = TLS_IE (foo);
- *ap = 1;
- bp = TLS_IE (bar);
- *bp = 2;
+ foo = 1;
+ bar = 2;
/* Get variables using local dynamic model. */
fputs ("get sum of foo, bar (GD) and baz (LD)", stdout);
- ap = TLS_GD (foo);
- bp = TLS_GD (bar);
- cp = TLS_LD (baz);
+ ap = &foo_gd;
+ bp = &bar_gd;
+ cp = &baz_ld;
printf (" = %d\n", *ap + *bp + *cp);
result |= *ap + *bp + *cp != 6;
if (*ap != 1)
diff --git a/elf/tst-tlsmod1.c b/elf/tst-tlsmod1.c
index 8d91567..a448c4d 100644
--- a/elf/tst-tlsmod1.c
+++ b/elf/tst-tlsmod1.c
@@ -1,12 +1,12 @@
#include <stdio.h>
-#include "tls-macros.h"
+__thread int foo, bar __attribute__ ((tls_model("global-dynamic")));
+extern __thread int baz __attribute__ ((tls_model("global-dynamic")));
+extern __thread int foo_ie asm ("foo") __attribute__ ((tls_model("initial-exec")));
+extern __thread int bar_ie asm ("bar") __attribute__ ((tls_model("initial-exec")));
+extern __thread int baz_ie asm ("baz") __attribute__ ((tls_model("initial-exec")));
-/* One define int variable, two externs. */
-COMMON_INT_DEF(foo);
-VAR_INT_DEF(bar);
-VAR_INT_DECL(baz);
extern int in_dso (void);
@@ -19,8 +19,8 @@ in_dso (void)
/* Get variables using initial exec model. */
fputs ("get sum of foo and bar (IE)", stdout);
asm ("" ::: "memory");
- ap = TLS_IE (foo);
- bp = TLS_IE (bar);
+ ap = &foo_ie;
+ bp = &bar_ie;
printf (" = %d\n", *ap + *bp);
result |= *ap + *bp != 3;
if (*ap != 1)
@@ -35,11 +35,11 @@ in_dso (void)
}
- /* Get variables using generic dynamic model. */
- fputs ("get sum of foo and bar and baz (GD)", stdout);
- ap = TLS_GD (foo);
- bp = TLS_GD (bar);
- cp = TLS_GD (baz);
+ /* Get variables using generic dynamic model or TLSDESC. */
+ fputs ("get sum of foo and bar and baz (GD or TLSDESC)", stdout);
+ ap = &foo;
+ bp = &bar;
+ cp = &baz;
printf (" = %d\n", *ap + *bp + *cp);
result |= *ap + *bp + *cp != 6;
if (*ap != 1)
diff --git a/elf/tst-tlsmod2.c b/elf/tst-tlsmod2.c
index 40eb140..3223fe4 100644
--- a/elf/tst-tlsmod2.c
+++ b/elf/tst-tlsmod2.c
@@ -1,9 +1,7 @@
#include <stdio.h>
-#include "tls-macros.h"
-
-COMMON_INT_DEF(foo);
+__thread int foo;
int
@@ -15,7 +13,7 @@ in_dso (int n, int *caller_foop)
puts ("foo"); /* Make sure PLT is used before macros. */
asm ("" ::: "memory");
- foop = TLS_GD (foo);
+ foop = &foo;
if (caller_foop != NULL && foop != caller_foop)
{
diff --git a/elf/tst-tlsmod3.c b/elf/tst-tlsmod3.c
index 6d186c4..d6e7498 100644
--- a/elf/tst-tlsmod3.c
+++ b/elf/tst-tlsmod3.c
@@ -1,10 +1,10 @@
#include <stdio.h>
-#include "tls-macros.h"
extern int in_dso (int n, int *caller_foop);
-COMMON_INT_DEF(comm_n);
+extern __thread int foo;
+__thread int comm_n;
@@ -20,8 +20,8 @@ in_dso2 (void)
puts ("foo"); /* Make sure PLT is used before macros. */
asm ("" ::: "memory");
- foop = TLS_GD (foo);
- np = TLS_GD (comm_n);
+ foop = &foo;
+ np = &comm_n;
if (n != *np)
{
diff --git a/elf/tst-tlsmod4.c b/elf/tst-tlsmod4.c
index 86889aa..f38919a 100644
--- a/elf/tst-tlsmod4.c
+++ b/elf/tst-tlsmod4.c
@@ -1,9 +1,7 @@
#include <stdio.h>
-#include "tls-macros.h"
-
-COMMON_INT_DEF(baz);
+__thread int baz;
int
@@ -15,7 +13,7 @@ in_dso (int n, int *caller_bazp)
puts ("foo"); /* Make sure PLT is used before macros. */
asm ("" ::: "memory");
- bazp = TLS_GD (baz);
+ bazp = &baz;
if (caller_bazp != NULL && bazp != caller_bazp)
{
diff --git a/elf/tst-tlsmod5.c b/elf/tst-tlsmod5.c
index a97c7e5..3f39c5b 100644
--- a/elf/tst-tlsmod5.c
+++ b/elf/tst-tlsmod5.c
@@ -1,3 +1 @@
-#include "tls-macros.h"
-
-COMMON_INT_DEF(foo);
+__thread int foo;
diff --git a/elf/tst-tlsmod6.c b/elf/tst-tlsmod6.c
index e968596..7b3571f 100644
--- a/elf/tst-tlsmod6.c
+++ b/elf/tst-tlsmod6.c
@@ -1,3 +1 @@
-#include "tls-macros.h"
-
-COMMON_INT_DEF(bar);
+__thread int bar;
diff --git a/sysdeps/powerpc/mod-tlsopt-powerpc.c b/sysdeps/powerpc/mod-tlsopt-powerpc.c
index ee0db12..2a82e53 100644
--- a/sysdeps/powerpc/mod-tlsopt-powerpc.c
+++ b/sysdeps/powerpc/mod-tlsopt-powerpc.c
@@ -1,11 +1,9 @@
/* shared library to test for __tls_get_addr optimization. */
#include <stdio.h>
-#include "../../elf/tls-macros.h"
#include "dl-tls.h"
-/* common 'int' variable in TLS. */
-COMMON_INT_DEF(foo);
+__thread int foo __attribute__ ((tls_model("global-dynamic")));
int
@@ -14,7 +12,7 @@ tls_get_addr_opt_test (void)
int result = 0;
/* Get variable using general dynamic model. */
- int *ap = TLS_GD (foo);
+ int *ap = &foo;
if (*ap != 0)
{
printf ("foo = %d\n", *ap);
diff --git a/sysdeps/powerpc/tst-tlsifunc.c b/sysdeps/powerpc/tst-tlsifunc.c
index 3095d41..c8c0bad 100644
--- a/sysdeps/powerpc/tst-tlsifunc.c
+++ b/sysdeps/powerpc/tst-tlsifunc.c
@@ -21,9 +21,9 @@
#include <stdint.h>
#include <inttypes.h>
#include <libc-symbols.h>
-#include <tls-macros.h>
__thread int bar;
+extern __thread int bar_gd asm ("bar") __attribute__ ((tls_model("global-dynamic")));
static int *bar_ptr = NULL;
static uint32_t resolver_platform = 0;
@@ -57,7 +57,7 @@ get_platform (void)
void
init_foo (void)
{
- bar_ptr = TLS_GD (bar);
+ bar_ptr = &bar_gd;
}
int
--
1.8.3.1

View File

@ -0,0 +1,27 @@
From 82fbcd7118d760492e2ecc9fa291e358b9ba0361 Mon Sep 17 00:00:00 2001
From: Arjun Shankar <arjun@redhat.com>
Date: Fri, 20 Aug 2021 16:24:05 +0200
Subject: [PATCH] elf: Fix missing colon in LD_SHOW_AUXV output [BZ #28253]
This commit adds a missing colon in the AT_MINSIGSTKSZ entry in
the _dl_show_auxv function.
---
elf/dl-sysdep.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/elf/dl-sysdep.c b/elf/dl-sysdep.c
index d47bef1..2c684c2 100644
--- a/elf/dl-sysdep.c
+++ b/elf/dl-sysdep.c
@@ -317,7 +317,7 @@ _dl_show_auxv (void)
[AT_SYSINFO_EHDR - 2] = { "SYSINFO_EHDR: 0x", hex },
[AT_RANDOM - 2] = { "RANDOM: 0x", hex },
[AT_HWCAP2 - 2] = { "HWCAP2: 0x", hex },
- [AT_MINSIGSTKSZ - 2] = { "MINSIGSTKSZ ", dec },
+ [AT_MINSIGSTKSZ - 2] = { "MINSIGSTKSZ: ", dec },
[AT_L1I_CACHESIZE - 2] = { "L1I_CACHESIZE: ", dec },
[AT_L1I_CACHEGEOMETRY - 2] = { "L1I_CACHEGEOMETRY: 0x", hex },
[AT_L1D_CACHESIZE - 2] = { "L1D_CACHESIZE: ", dec },
--
1.8.3.1

View File

@ -63,7 +63,7 @@
##############################################################################
Name: glibc
Version: 2.34
Release: 8
Release: 9
Summary: The GNU libc libraries
License: %{all_license}
URL: http://www.gnu.org/software/glibc/
@ -99,6 +99,13 @@ Patch18: elf-Unconditionally-use-__ehdr_start.patch
Patch19: aarch64-Make-elf_machine_-load_address-dynamic-robus.patch
Patch20: mtrace-Use-a-static-buffer-for-printing-BZ-25947.patch
Patch21: time-Fix-overflow-itimer-tests-on-32-bit-systems.patch
Patch22: arm-Simplify-elf_machine_-load_address-dynamic.patch
Patch23: elf-Drop-elf-tls-macros.h-in-favor-of-__thread-and-t.patch
Patch24: elf-Fix-missing-colon-in-LD_SHOW_AUXV-output-BZ-2825.patch
Patch25: Remove-sysdeps-tls-macros.h.patch
Patch26: riscv-Drop-reliance-on-_GLOBAL_OFFSET_TABLE_-0.patch
Patch27: x86_64-Simplify-elf_machine_-load_address-dynamic.patch
Patch28: x86-fix-Autoconf-caching-of-instruction-support-chec.patch
#Patch9000: turn-REP_STOSB_THRESHOLD-from-2k-to-1M.patch
Patch9001: delete-no-hard-link-to-avoid-all_language-package-to.patch
@ -1190,6 +1197,10 @@ fi
%doc hesiod/README.hesiod
%changelog
* Wed Sep 29 2021 Qingqing Li<liqingqing3@huawei.com> - 2.34-9
- elf: drop elf/tls-macros.h in favor of thread tls_mode attribute.
- use __ehdr_start for __GLOBAL_OFFSET_TABLE[0]
* Wed Sep 29 2021 Qingqing Li<liqingqing3@huawei.com> - 2.34-8
- fix overflow ittimer tests on 32 bit system

View File

@ -0,0 +1,60 @@
From 34b4624b04fc8f038b2c329ca7560197320615b4 Mon Sep 17 00:00:00 2001
From: Fangrui Song <maskray@google.com>
Date: Wed, 18 Aug 2021 10:01:31 -0700
Subject: [PATCH] riscv: Drop reliance on _GLOBAL_OFFSET_TABLE_[0]
&__ehdr_start is a better way to get the load address.
This is similar to commits b37b75d269883a2c553bb7019a813094eb4e2dd1
(x86-64) and 43d06ed218fc8be58987bdfd00e21e5720f0b862 (aarch64).
Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com>
---
sysdeps/riscv/dl-machine.h | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/sysdeps/riscv/dl-machine.h b/sysdeps/riscv/dl-machine.h
index aedf69f..5b07461 100644
--- a/sysdeps/riscv/dl-machine.h
+++ b/sysdeps/riscv/dl-machine.h
@@ -76,27 +76,26 @@ elf_machine_matches_host (const ElfW(Ehdr) *ehdr)
return 1;
}
+/* Return the run-time load address of the shared object. */
+static inline ElfW(Addr)
+elf_machine_load_address (void)
+{
+ extern const ElfW(Ehdr) __ehdr_start attribute_hidden;
+ return (ElfW(Addr)) &__ehdr_start;
+}
+
/* Return the link-time address of _DYNAMIC. */
static inline ElfW(Addr)
elf_machine_dynamic (void)
{
- extern ElfW(Addr) _GLOBAL_OFFSET_TABLE_ __attribute__ ((visibility ("hidden")));
- return _GLOBAL_OFFSET_TABLE_;
+ extern ElfW(Dyn) _DYNAMIC[] attribute_hidden;
+ return (ElfW(Addr)) _DYNAMIC - elf_machine_load_address ();
}
#define STRINGXP(X) __STRING (X)
#define STRINGXV(X) STRINGV_ (X)
#define STRINGV_(...) # __VA_ARGS__
-/* Return the run-time load address of the shared object. */
-static inline ElfW(Addr)
-elf_machine_load_address (void)
-{
- ElfW(Addr) load_addr;
- asm ("lla %0, _DYNAMIC" : "=r" (load_addr));
- return load_addr - elf_machine_dynamic ();
-}
-
/* Initial entry point code for the dynamic linker.
The C function `_dl_start' is the real entry point;
its return value is the user program's entry point. */
--
1.8.3.1

View File

@ -0,0 +1,178 @@
From 0835c0f0bad351117154b815f34f8af19ea7e325 Mon Sep 17 00:00:00 2001
From: Matt Whitlock <sourceware@mattwhitlock.name>
Date: Wed, 16 Jun 2021 23:40:47 -0400
Subject: [PATCH] x86: fix Autoconf caching of instruction support checks [BZ
#27991]
The Autoconf documentation for the AC_CACHE_CHECK macro states:
The commands-to-set-it must have no side effects except for setting
the variable cache-id, see below.
However, the tests for support of -msahf and -mmovbe were embedded in
the commands-to-set-it for lib_cv_include_x86_isa_level. This had the
consequence that libc_cv_have_x86_lahf_sahf and libc_cv_have_x86_movbe
were not defined whenever lib_cv_include_x86_isa_level was read from
cache. These variables' being undefined meant that their unquoted use
in later test expressions led to the 'test' built-in's misparsing its
arguments and emitting errors like "test: =: unexpected operator" or
"test: =: unary operator expected", depending on the particular shell.
This commit refactors the tests for LAHF/SAHF and MOVBE instruction
support into their own AC_CACHE_CHECK macro invocations to obey the
rule that the commands-to-set-it must have no side effects other than
setting the variable named by cache-id.
Signed-off-by: Matt Whitlock <sourceware@mattwhitlock.name>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
---
sysdeps/x86/configure | 56 ++++++++++++++++++++++++++++++------------------
sysdeps/x86/configure.ac | 34 +++++++++++++++--------------
2 files changed, 53 insertions(+), 37 deletions(-)
diff --git a/sysdeps/x86/configure b/sysdeps/x86/configure
index ead1295..62676bb 100644
--- a/sysdeps/x86/configure
+++ b/sysdeps/x86/configure
@@ -126,8 +126,6 @@ cat > conftest2.S <<EOF
4:
EOF
libc_cv_include_x86_isa_level=no
-libc_cv_have_x86_lahf_sahf=no
-libc_cv_have_x86_movbe=no
if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -nostartfiles -nostdlib -r -o conftest conftest1.S conftest2.S'
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
(eval $ac_try) 2>&5
@@ -137,9 +135,22 @@ if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -nostartfiles -nostdlib -r -o conftest c
count=`LC_ALL=C $READELF -n conftest | grep NT_GNU_PROPERTY_TYPE_0 | wc -l`
if test "$count" = 1; then
libc_cv_include_x86_isa_level=yes
- cat > conftest.c <<EOF
-EOF
- if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -fverbose-asm -S -o - conftest.c'
+ fi
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_include_x86_isa_level" >&5
+$as_echo "$libc_cv_include_x86_isa_level" >&6; }
+if test $libc_cv_include_x86_isa_level = yes; then
+ $as_echo "#define INCLUDE_X86_ISA_LEVEL 1" >>confdefs.h
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LAHF/SAHF instruction support" >&5
+$as_echo_n "checking for LAHF/SAHF instruction support... " >&6; }
+if ${libc_cv_have_x86_lahf_sahf+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ libc_cv_have_x86_lahf_sahf=no
+ if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -fverbose-asm -S -o - -x c /dev/null'
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
(eval $ac_try) 2>&5
ac_status=$?
@@ -147,7 +158,20 @@ EOF
test $ac_status = 0; }; } | grep -q "\-msahf"; then
libc_cv_have_x86_lahf_sahf=yes
fi
- if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -fverbose-asm -S -o - conftest.c'
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_have_x86_lahf_sahf" >&5
+$as_echo "$libc_cv_have_x86_lahf_sahf" >&6; }
+ if test $libc_cv_have_x86_lahf_sahf = yes; then
+ $as_echo "#define HAVE_X86_LAHF_SAHF 1" >>confdefs.h
+
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MOVBE instruction support" >&5
+$as_echo_n "checking for MOVBE instruction support... " >&6; }
+if ${libc_cv_have_x86_movbe+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ libc_cv_have_x86_movbe=no
+ if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -fverbose-asm -S -o - -x c /dev/null'
{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
(eval $ac_try) 2>&5
ac_status=$?
@@ -155,23 +179,13 @@ EOF
test $ac_status = 0; }; } | grep -q "\-mmovbe"; then
libc_cv_have_x86_movbe=yes
fi
- fi
-fi
-rm -f conftest*
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_include_x86_isa_level" >&5
-$as_echo "$libc_cv_include_x86_isa_level" >&6; }
-if test $libc_cv_include_x86_isa_level = yes; then
- $as_echo "#define INCLUDE_X86_ISA_LEVEL 1" >>confdefs.h
-
fi
-if test $libc_cv_have_x86_lahf_sahf = yes; then
- $as_echo "#define HAVE_X86_LAHF_SAHF 1" >>confdefs.h
-
-fi
-if test $libc_cv_have_x86_movbe = yes; then
- $as_echo "#define HAVE_X86_MOVBE 1" >>confdefs.h
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_have_x86_movbe" >&5
+$as_echo "$libc_cv_have_x86_movbe" >&6; }
+ if test $libc_cv_have_x86_movbe = yes; then
+ $as_echo "#define HAVE_X86_MOVBE 1" >>confdefs.h
+ fi
fi
config_vars="$config_vars
enable-x86-isa-level = $libc_cv_include_x86_isa_level"
diff --git a/sysdeps/x86/configure.ac b/sysdeps/x86/configure.ac
index bca97fd..04a12ab 100644
--- a/sysdeps/x86/configure.ac
+++ b/sysdeps/x86/configure.ac
@@ -98,30 +98,32 @@ cat > conftest2.S <<EOF
4:
EOF
libc_cv_include_x86_isa_level=no
-libc_cv_have_x86_lahf_sahf=no
-libc_cv_have_x86_movbe=no
if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -nostartfiles -nostdlib -r -o conftest conftest1.S conftest2.S); then
count=`LC_ALL=C $READELF -n conftest | grep NT_GNU_PROPERTY_TYPE_0 | wc -l`
if test "$count" = 1; then
libc_cv_include_x86_isa_level=yes
- cat > conftest.c <<EOF
-EOF
- if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -fverbose-asm -S -o - conftest.c) | grep -q "\-msahf"; then
- libc_cv_have_x86_lahf_sahf=yes
- fi
- if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -fverbose-asm -S -o - conftest.c) | grep -q "\-mmovbe"; then
- libc_cv_have_x86_movbe=yes
- fi
fi
fi
rm -f conftest*])
if test $libc_cv_include_x86_isa_level = yes; then
AC_DEFINE(INCLUDE_X86_ISA_LEVEL)
-fi
-if test $libc_cv_have_x86_lahf_sahf = yes; then
- AC_DEFINE(HAVE_X86_LAHF_SAHF)
-fi
-if test $libc_cv_have_x86_movbe = yes; then
- AC_DEFINE(HAVE_X86_MOVBE)
+ AC_CACHE_CHECK([for LAHF/SAHF instruction support],
+ libc_cv_have_x86_lahf_sahf, [dnl
+ libc_cv_have_x86_lahf_sahf=no
+ if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -fverbose-asm -S -o - -x c /dev/null) | grep -q "\-msahf"; then
+ libc_cv_have_x86_lahf_sahf=yes
+ fi])
+ if test $libc_cv_have_x86_lahf_sahf = yes; then
+ AC_DEFINE(HAVE_X86_LAHF_SAHF)
+ fi
+ AC_CACHE_CHECK([for MOVBE instruction support],
+ libc_cv_have_x86_movbe, [dnl
+ libc_cv_have_x86_movbe=no
+ if AC_TRY_COMMAND(${CC-cc} $CFLAGS $CPPFLAGS -fverbose-asm -S -o - -x c /dev/null) | grep -q "\-mmovbe"; then
+ libc_cv_have_x86_movbe=yes
+ fi])
+ if test $libc_cv_have_x86_movbe = yes; then
+ AC_DEFINE(HAVE_X86_MOVBE)
+ fi
fi
LIBC_CONFIG_VAR([enable-x86-isa-level], [$libc_cv_include_x86_isa_level])
--
1.8.3.1

View File

@ -0,0 +1,55 @@
From b37b75d269883a2c553bb7019a813094eb4e2dd1 Mon Sep 17 00:00:00 2001
From: Fangrui Song <maskray@google.com>
Date: Tue, 17 Aug 2021 10:45:57 -0700
Subject: [PATCH] x86_64: Simplify elf_machine_{load_address,dynamic}
and drop reliance on _GLOBAL_OFFSET_TABLE_[0] being the link-time
address of _DYNAMIC. &__ehdr_start is a better way to get the load address.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
---
sysdeps/x86_64/dl-machine.h | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
index a8596aa..ceee507 100644
--- a/sysdeps/x86_64/dl-machine.h
+++ b/sysdeps/x86_64/dl-machine.h
@@ -35,27 +35,20 @@ elf_machine_matches_host (const ElfW(Ehdr) *ehdr)
}
-/* Return the link-time address of _DYNAMIC. Conveniently, this is the
- first element of the GOT. This must be inlined in a function which
- uses global data. */
+/* Return the run-time load address of the shared object. */
static inline ElfW(Addr) __attribute__ ((unused))
-elf_machine_dynamic (void)
+elf_machine_load_address (void)
{
- /* This produces an IP-relative reloc which is resolved at link time. */
- extern const ElfW(Addr) _GLOBAL_OFFSET_TABLE_[] attribute_hidden;
- return _GLOBAL_OFFSET_TABLE_[0];
+ extern const ElfW(Ehdr) __ehdr_start attribute_hidden;
+ return (ElfW(Addr)) &__ehdr_start;
}
-
-/* Return the run-time load address of the shared object. */
+/* Return the link-time address of _DYNAMIC. */
static inline ElfW(Addr) __attribute__ ((unused))
-elf_machine_load_address (void)
+elf_machine_dynamic (void)
{
- /* Compute the difference between the runtime address of _DYNAMIC as seen
- by an IP-relative reference, and the link-time address found in the
- special unrelocated first GOT entry. */
extern ElfW(Dyn) _DYNAMIC[] attribute_hidden;
- return (ElfW(Addr)) &_DYNAMIC - elf_machine_dynamic ();
+ return (ElfW(Addr)) _DYNAMIC - elf_machine_load_address ();
}
/* Set up the loaded object described by L so its unrelocated PLT
--
1.8.3.1