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