forked from rpms/glibc
42eb238e49
* Tue Mar 15 2022 Florian Weimer <fweimer@redhat.com> - 2.34-29 - Sync with upstream branch release/2.34/master, commit 224d8c1890b6c57c7e4e8ddbb792dd9552086704: - debug: Synchronize feature guards in fortified functions [BZ #28746] - debug: Autogenerate _FORTIFY_SOURCE tests - Enable _FORTIFY_SOURCE=3 for gcc 12 and above - fortify: Fix spurious warning with realpath - __glibc_unsafe_len: Fix comment - debug: Add tests for _FORTIFY_SOURCE=3 - Make sure that the fortified function conditionals are constant - Don't add access size hints to fortifiable functions - nss: Protect against errno changes in function lookup (bug 28953) - nss: Do not mention NSS test modules in <gnu/lib-names.h> - io: Add fsync call in tst-stat - hppa: Fix warnings from _dl_lookup_address - nptl: Fix cleanups for stack grows up [BZ# 28899] - hppa: Revise gettext trampoline design - hppa: Fix swapcontext - Fix elf/tst-audit2 on hppa - localedef: Handle symbolic links when generating locale-archive - NEWS: Add a bug fix entry for BZ #28896 - x86: Fix TEST_NAME to make it a string in tst-strncmp-rtm.c - x86: Test wcscmp RTM in the wcsncmp overflow case [BZ #28896] - x86: Fallback {str|wcs}cmp RTM in the ncmp overflow case [BZ #28896] - string: Add a testcase for wcsncmp with SIZE_MAX [BZ #28755] - linux: fix accuracy of get_nprocs and get_nprocs_conf [BZ #28865] - Add reference to BZ#28860 on NEWS - linux: Fix missing __convert_scm_timestamps (BZ #28860) Resolves: #2063230 Resolves: #2033683 Resolves: #2063041 Resolves: #2063142
105 lines
3.4 KiB
Diff
105 lines
3.4 KiB
Diff
commit 3be79b72d556e3ac37075ad6b99eb5eac18e1402
|
|
Author: John David Anglin <danglin@gcc.gnu.org>
|
|
Date: Sun Mar 6 15:56:57 2022 +0000
|
|
|
|
Fix elf/tst-audit2 on hppa
|
|
|
|
The test elf/tst-audit2 fails on hppa with a segmentation fault in the
|
|
long branch stub used to call malloc from calloc. This occurs because
|
|
the test is not a PIC executable and calloc is called from the dynamic
|
|
linker before the dp register is initialized in _dl_start_user.
|
|
|
|
The fix is to move the dp register initialization into
|
|
elf_machine_runtime_setup. Since the address of $global$ can't be
|
|
loaded directly, we continue to use the DT_PLTGOT value from the
|
|
the main_map to initialize dp. Since l_main_map is not available
|
|
in v2.34 and earlier, we use a new function, elf_machine_main_map,
|
|
to find the main map.
|
|
|
|
diff --git a/sysdeps/hppa/dl-machine.h b/sysdeps/hppa/dl-machine.h
|
|
index f048fd20728ccde6..24f0f47d8f1e25cd 100644
|
|
--- a/sysdeps/hppa/dl-machine.h
|
|
+++ b/sysdeps/hppa/dl-machine.h
|
|
@@ -27,6 +27,7 @@
|
|
#include <string.h>
|
|
#include <link.h>
|
|
#include <errno.h>
|
|
+#include <ldsodefs.h>
|
|
#include <dl-fptr.h>
|
|
#include <abort-instr.h>
|
|
#include <tls.h>
|
|
@@ -159,6 +160,24 @@ elf_machine_plt_value (struct link_map *map, const Elf32_Rela *reloc,
|
|
return (struct fdesc) { value.ip + reloc->r_addend, value.gp };
|
|
}
|
|
|
|
+static inline struct link_map *
|
|
+elf_machine_main_map (void)
|
|
+{
|
|
+ struct link_map *main_map;
|
|
+
|
|
+#if defined SHARED && IS_IN (rtld)
|
|
+ asm (
|
|
+" bl 1f,%0\n"
|
|
+" addil L'_rtld_local - ($PIC_pcrel$0 - 1),%0\n"
|
|
+"1: ldw R'_rtld_local - ($PIC_pcrel$0 - 5)(%%r1),%0\n"
|
|
+ : "=r" (main_map) : : "r1");
|
|
+#else
|
|
+ main_map = NULL;
|
|
+#endif
|
|
+
|
|
+ return main_map;
|
|
+}
|
|
+
|
|
/* 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. */
|
|
|
|
@@ -174,6 +193,15 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
|
|
Elf32_Addr i[2];
|
|
} sig = {{0x00,0xc0,0xff,0xee, 0xde,0xad,0xbe,0xef}};
|
|
|
|
+ /* Initialize dp register for main executable. */
|
|
+ if (l == elf_machine_main_map ())
|
|
+ {
|
|
+ register Elf32_Addr dp asm ("%r27");
|
|
+
|
|
+ dp = D_PTR (l, l_info[DT_PLTGOT]);
|
|
+ asm volatile ("" : : "r" (dp));
|
|
+ }
|
|
+
|
|
/* If we don't have a PLT we can just skip all this... */
|
|
if (__builtin_expect (l->l_info[DT_JMPREL] == NULL,0))
|
|
return lazy;
|
|
@@ -336,16 +364,6 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile)
|
|
its return value is the user program's entry point. */
|
|
|
|
#define RTLD_START \
|
|
-/* Set up dp for any non-PIC lib constructors that may be called. */ \
|
|
-static struct link_map * __attribute__((used)) \
|
|
-set_dp (struct link_map *map) \
|
|
-{ \
|
|
- register Elf32_Addr dp asm ("%r27"); \
|
|
- dp = D_PTR (map, l_info[DT_PLTGOT]); \
|
|
- asm volatile ("" : : "r" (dp)); \
|
|
- return map; \
|
|
-} \
|
|
- \
|
|
asm ( \
|
|
" .text\n" \
|
|
" .globl _start\n" \
|
|
@@ -445,14 +463,11 @@ asm ( \
|
|
" stw %r24,-44(%sp)\n" \
|
|
\
|
|
".Lnofix:\n" \
|
|
+ /* Call _dl_init(main_map, argc, argv, envp). */ \
|
|
" addil LT'_rtld_local,%r19\n" \
|
|
" ldw RT'_rtld_local(%r1),%r26\n" \
|
|
-" bl set_dp, %r2\n" \
|
|
" ldw 0(%r26),%r26\n" \
|
|
\
|
|
- /* Call _dl_init(_dl_loaded, argc, argv, envp). */ \
|
|
-" copy %r28,%r26\n" \
|
|
- \
|
|
/* envp = argv + argc + 1 */ \
|
|
" sh2add %r25,%r24,%r23\n" \
|
|
" bl _dl_init,%r2\n" \
|