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