This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] [BZ #18479]: nptl: restore .interp section in libpthread.so
- From: Gleb Fotengauer-Malinovskiy <glebfm at altlinux dot org>
- To: libc-alpha at sourceware dot org
- Date: Tue, 2 Jun 2015 21:04:06 +0300
- Subject: [PATCH] [BZ #18479]: nptl: restore .interp section in libpthread.so
- Authentication-results: sourceware.org; auth=none
In commit 02657da2cf4457804ed938ee08b8316249126444, .interp section was
removed from libpthread.so. This led to an error:
$ /lib64/libpthread.so.0
Native POSIX Threads Library by Ulrich Drepper et al
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Forced unwind support included.
Segmentation fault
(gdb) bt
#0 0x00000000000055a6 in _exit@plt ()
Since NOT_IN_* macros were removed and new IS_IN* stuff is enforced,
a slightly different workaround has to be added to avoid inclusion
of symbol-hacks into interp.os file.
Unfortunately, there is no way to add a regression test for the bug
because .interp specifies the path to dynamic linker of the target
system.
Tested on x86_64, x86, and armhf.
[BZ #18479]
* sysdeps/generic/symbol-hacks.h: Skip if NO_SYMBOL_HACKS is defined.
* sysdeps/wordsize-32/symbol-hacks.h: Likewise.
* elf/Makefile (CPPFLAGS-interp.c): Set to -DNO_SYMBOL_HACKS=1.
* nptl/Makefile ($(objpfx)libpthread.so): Add $(+interp).
Signed-off-by: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
elf/Makefile | 1 +
nptl/Makefile | 1 +
sysdeps/generic/symbol-hacks.h | 3 ++-
sysdeps/wordsize-32/symbol-hacks.h | 3 ++-
4 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/elf/Makefile b/elf/Makefile
index e5b142c..0f646a7 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -354,6 +354,7 @@ $(objpfx)ld.so: $(objpfx)librtld.os $(ld-map)
mv -f $@.new $@
# interp.c exists just to get the runtime linker path into libc.so.
+CPPFLAGS-interp.c = -DNO_SYMBOL_HACKS=1
$(objpfx)interp.os: $(elf-objpfx)runtime-linker.h
$(elf-objpfx)runtime-linker.h: $(elf-objpfx)runtime-linker.st; @:
diff --git a/nptl/Makefile b/nptl/Makefile
index 7c39d6d..0e546bb 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -542,6 +542,7 @@ extra-B-pthread.so = -B$(common-objpfx)nptl/
$(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs))
$(objpfx)libpthread.so: +preinit += $(addprefix $(objpfx),$(crti-objs))
$(objpfx)libpthread.so: +postinit += $(addprefix $(objpfx),$(crtn-objs))
+$(objpfx)libpthread.so: $(+interp)
# Make sure we link with the thread library.
ifeq ($(build-shared),yes)
diff --git a/sysdeps/generic/symbol-hacks.h b/sysdeps/generic/symbol-hacks.h
index ce576c9..e2da923 100644
--- a/sysdeps/generic/symbol-hacks.h
+++ b/sysdeps/generic/symbol-hacks.h
@@ -1,6 +1,7 @@
/* Some compiler optimizations may transform loops into memset/memmove
calls and without proper declaration it may generate PLT calls. */
-#if !defined __ASSEMBLER__ && IS_IN (libc) && defined SHARED
+#if !defined __ASSEMBLER__ && IS_IN (libc) && defined SHARED \
+ && !defined NO_SYMBOL_HACKS
asm ("memmove = __GI_memmove");
asm ("memset = __GI_memset");
asm ("memcpy = __GI_memcpy");
diff --git a/sysdeps/wordsize-32/symbol-hacks.h b/sysdeps/wordsize-32/symbol-hacks.h
index ceabb76..0bdf785 100644
--- a/sysdeps/wordsize-32/symbol-hacks.h
+++ b/sysdeps/wordsize-32/symbol-hacks.h
@@ -23,7 +23,8 @@
therefore we get PLTs. Unnecessarily so. Changing gcc is a big
task which might not be worth it so we play tricks with the
assembler. */
-#if !defined __ASSEMBLER__ && !defined in_divdi3_c && IS_IN (libc) && defined SHARED
+#if !defined __ASSEMBLER__ && !defined in_divdi3_c && IS_IN (libc) \
+ && defined SHARED && !defined NO_SYMBOL_HACKS
asm ("__divdi3 = __divdi3_internal");
asm ("__udivdi3 = __udivdi3_internal");
asm ("__moddi3 = __moddi3_internal");
--
glebfm