about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2021-01-18 11:45:46 +0000
committerH.J. Lu <hjl.tools@gmail.com>2021-01-19 06:38:28 -0800
commitcabc8a291629011894ff5d1dc4ec7e25ecee6269 (patch)
treeff5468cc18c3bd7eb82524a98f239db8e8dca095 /elf
parent0ec583d926f9d4744918bd191cc7b8c3a74515a1 (diff)
downloadglibc-cabc8a291629011894ff5d1dc4ec7e25ecee6269.tar.gz
glibc-cabc8a291629011894ff5d1dc4ec7e25ecee6269.tar.xz
glibc-cabc8a291629011894ff5d1dc4ec7e25ecee6269.zip
elf: Avoid RELATIVE relocation for _dl_sysinfo
Set the default _dl_sysinfo in _dl_aux_init to avoid RELATIVE relocation
in static PIE.

This is needed for fixing bug 27072 on x86.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'elf')
-rw-r--r--elf/dl-support.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 9d468d5a4b..2434c470c7 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -193,8 +193,9 @@ int _dl_thread_gscope_count;
 struct dl_scope_free_list *_dl_scope_free_list;
 
 #ifdef NEED_DL_SYSINFO
-/* Needed for improved syscall handling on at least x86/Linux.  */
-uintptr_t _dl_sysinfo = DL_SYSINFO_DEFAULT;
+/* Needed for improved syscall handling on at least x86/Linux.  NB: Don't
+   initialize it here to avoid RELATIVE relocation in static PIE.  */
+uintptr_t _dl_sysinfo;
 #endif
 #ifdef NEED_DL_SYSINFO_DSO
 /* Address of the ELF headers in the vsyscall page.  */
@@ -232,6 +233,11 @@ _dl_aux_init (ElfW(auxv_t) *av)
   uid_t uid = 0;
   gid_t gid = 0;
 
+#ifdef NEED_DL_SYSINFO
+  /* NB: Avoid RELATIVE relocation in static PIE.  */
+  GL(dl_sysinfo) = DL_SYSINFO_DEFAULT;
+#endif
+
   _dl_auxv = av;
   for (; av->a_type != AT_NULL; ++av)
     switch (av->a_type)