bca718
commit ac63a0783cdee8454c84fc45f37330d98b6039e7
bca718
Author: Dmitry V. Levin <ldv@altlinux.org>
bca718
Date:   Fri Jun 5 22:20:13 2015 +0000
bca718
bca718
    Prepare for restoration of .interp section in libpthread.so
bca718
    
bca718
    Make runtime-linker.h available outside $(elf-objpfx) by moving
bca718
    the file to $(common-objpfx) and the rules for it to Makerules.
bca718
    
bca718
    Tested for x86_64 and x86 (testsuite, and that no compiled code
bca718
    changed by the patch).
bca718
    
bca718
    * Makeconfig (+interp): Remove unused variable.
bca718
    * elf/Makefile ($(objpfx)interp.os): Define for [$(build-shared) = yes]
bca718
    only.  Depend on $(common-objpfx)runtime-linker.h instead of
bca718
    $(elf-objpfx)runtime-linker.h.
bca718
    ($(elf-objpfx)runtime-linker.h): Rename to
bca718
    $(common-objpfx)runtime-linker.h and move ...
bca718
    * Makerules [$(build-shared) = yes]: ... here.
bca718
    * elf/interp.c: Include <runtime-linker.h> instead of
bca718
    <elf/runtime-linker.h>.
bca718
bca718
commit 78ad175b3060aae058ed5d05ced2bc58714901cd
bca718
Author: Gleb Fotengauer-Malinovskiy <glebfm@altlinux.org>
bca718
Date:   Tue Jun 2 21:04:06 2015 +0300
bca718
bca718
    nptl: restore .interp section in libpthread.so
bca718
    
bca718
    In commit 02657da2cf4457804ed938ee08b8316249126444, .interp section
bca718
    was removed from libpthread.so.  This led to an error:
bca718
    
bca718
      $ /lib64/libpthread.so.0
bca718
      Native POSIX Threads Library by Ulrich Drepper et al
bca718
      Copyright (C) 2015 Free Software Foundation, Inc.
bca718
      This is free software; see the source for copying conditions.
bca718
      There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
bca718
      PARTICULAR PURPOSE.
bca718
      Forced unwind support included.
bca718
      Segmentation fault
bca718
    
bca718
      (gdb) bt
bca718
      #0  0x00000000000055a6 in _exit@plt ()
bca718
    
bca718
    Unfortunately, there is no way to add a regression test for the bug
bca718
    because .interp specifies the path to dynamic linker of the target
bca718
    system.
bca718
    
bca718
    [BZ #18479]
bca718
    * nptl/pt-interp.c: New file.
bca718
    * nptl/Makefile (libpthread-routines, libpthread-shared-only-routines):
bca718
    Add pt-interp.
bca718
    [$(build-shared) = yes] ($(objpfx)pt-interp.os): Depend on
bca718
    $(common-objpfx)runtime-linker.h.
bca718
bca718
Index: glibc-2.17-c758a686/nptl/Makefile
bca718
===================================================================
bca718
--- glibc-2.17-c758a686.orig/nptl/Makefile
bca718
+++ glibc-2.17-c758a686/nptl/Makefile
bca718
@@ -30,7 +30,7 @@ routines = alloca_cutoff forward libc-lo
bca718
 	   libc-cleanup
bca718
 shared-only-routines = forward
bca718
 
bca718
-libpthread-routines = nptl-init vars events version \
bca718
+libpthread-routines = nptl-init vars events version pt-interp \
bca718
 		      pthread_create pthread_exit pthread_detach \
bca718
 		      pthread_join pthread_tryjoin pthread_timedjoin \
bca718
 		      pthread_self pthread_equal pthread_yield \
bca718
@@ -131,7 +131,8 @@ libpthread-routines = nptl-init vars eve
bca718
 #		      pthread_setgid pthread_setegid pthread_setregid \
bca718
 #		      pthread_setresgid
bca718
 
bca718
-libpthread-shared-only-routines = version pt-allocrtsig unwind-forcedunwind
bca718
+libpthread-shared-only-routines = version pt-interp pt-allocrtsig \
bca718
+				  unwind-forcedunwind
bca718
 libpthread-static-only-routines = pthread_atfork
bca718
 
bca718
 # Since cancellation handling is in large parts handled using exceptions
bca718
@@ -591,6 +592,8 @@ $(objpfx)banner.h: Banner
bca718
 generated += banner.h
bca718
 # Give libpthread.so an entry point and make it directly runnable itself.
bca718
 LDFLAGS-pthread.so += -e __nptl_main
bca718
+# pt-interp.c exists just to get the runtime linker path into libpthread.so.
bca718
+$(objpfx)pt-interp.os: $(common-objpfx)runtime-linker.h
bca718
 endif
bca718
 
bca718
 ifeq ($(run-built-tests),yes)
bca718
Index: glibc-2.17-c758a686/nptl/pt-interp.c
bca718
===================================================================
bca718
--- /dev/null
bca718
+++ glibc-2.17-c758a686/nptl/pt-interp.c
bca718
@@ -0,0 +1 @@
bca718
+#include <elf/interp.c>
bca718
Index: glibc-2.17-c758a686/Makeconfig
bca718
===================================================================
bca718
--- glibc-2.17-c758a686.orig/Makeconfig
bca718
+++ glibc-2.17-c758a686/Makeconfig
bca718
@@ -566,7 +566,6 @@ endif
bca718
 # Variants of the two previous definitions for statically linking programs.
bca718
 +prectorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtbeginT.o`
bca718
 +postctorT = `$(CC) $(sysdep-LDFLAGS) --print-file-name=crtend.o`
bca718
-+interp = $(addprefix $(elf-objpfx),interp.os)
bca718
 csu-objpfx = $(common-objpfx)csu/
bca718
 elf-objpfx = $(common-objpfx)elf/
bca718
 
bca718
Index: glibc-2.17-c758a686/elf/Makefile
bca718
===================================================================
bca718
--- glibc-2.17-c758a686.orig/elf/Makefile
bca718
+++ glibc-2.17-c758a686/elf/Makefile
bca718
@@ -344,16 +344,10 @@ $(objpfx)ld.so: $(objpfx)librtld.os $(ld
bca718
 	$(READELF) -s $@ \
bca718
 	  | $(AWK) '($$7 ~ /^UND(|EF)$$/ && $$1 != "0:" && $$4 != "REGISTER") { print; p=1 } END { exit p != 0 }'
bca718
 
bca718
+ifeq (yes,$(build-shared))
bca718
 # interp.c exists just to get the runtime linker path into libc.so.
bca718
-$(objpfx)interp.os: $(elf-objpfx)runtime-linker.h
bca718
-
bca718
-$(elf-objpfx)runtime-linker.h: $(elf-objpfx)runtime-linker.st; @:
bca718
-$(elf-objpfx)runtime-linker.st: $(common-objpfx)config.make
bca718
-	$(name-target-directory)
bca718
-	echo '#define RUNTIME_LINKER "$(rtlddir)/$(rtld-installed-name)"' \
bca718
-		> ${@:st=T}
bca718
-	$(move-if-change) ${@:st=T} ${@:st=h}
bca718
-	touch $@
bca718
+$(objpfx)interp.os: $(common-objpfx)runtime-linker.h
bca718
+endif
bca718
 
bca718
 ifneq (ld.so,$(rtld-installed-name))
bca718
 # Make sure ld.so.1 exists in the build directory so we can link
bca718
Index: glibc-2.17-c758a686/elf/interp.c
bca718
===================================================================
bca718
--- glibc-2.17-c758a686.orig/elf/interp.c
bca718
+++ glibc-2.17-c758a686/elf/interp.c
bca718
@@ -16,7 +16,7 @@
bca718
    License along with the GNU C Library; if not, see
bca718
    <http://www.gnu.org/licenses/>.  */
bca718
 
bca718
-#include <elf/runtime-linker.h>
bca718
+#include <runtime-linker.h>
bca718
 
bca718
 const char __invoke_dynamic_linker__[] __attribute__ ((section (".interp")))
bca718
   = RUNTIME_LINKER;
bca718
Index: glibc-2.17-c758a686/Makerules
bca718
===================================================================
bca718
--- glibc-2.17-c758a686.orig/Makerules
bca718
+++ glibc-2.17-c758a686/Makerules
bca718
@@ -123,6 +123,16 @@ $(common-objpfx)libc-abis.stamp: $(..)sc
bca718
 common-generated += $(common-objpfx)libc-abis.h
bca718
 endif # avoid-generated
bca718
 
bca718
+ifeq (yes,$(build-shared))
bca718
+$(common-objpfx)runtime-linker.h: $(common-objpfx)runtime-linker.stamp; @:
bca718
+$(common-objpfx)runtime-linker.stamp: $(common-objpfx)config.make
bca718
+	$(make-target-directory)
bca718
+	echo '#define RUNTIME_LINKER "$(rtlddir)/$(rtld-installed-name)"' \
bca718
+		> ${@:stamp=T}
bca718
+	$(move-if-change) ${@:stamp=T} ${@:stamp=h}
bca718
+	touch $@
bca718
+endif
bca718
+
bca718
 # Make sure the subdirectory for object files gets created.
bca718
 ifdef objpfx
bca718
 ifeq (,$(wildcard $(objpfx).))