Fix testroot.pristine creation copying dynamic linker

Message ID alpine.DEB.2.21.1910162150320.3868@digraph.polyomino.org.uk
State Superseded
Headers

Commit Message

Joseph Myers Oct. 16, 2019, 9:51 p.m. UTC
  This patch addresses an issue reported in
<https://sourceware.org/ml/libc-alpha/2019-07/msg00661.html> where the
creation of testroot.pristine, on encountering
LD_TRACE_LOADED_OBJECTS=1 of the form

        libc.so.6 => /scratch/jmyers/glibc/mbs/obj/glibc-8-0-mips64-linux-gnu-x86_64-linux-gnu/default/libc.so.6 (0x772dd000)
        /lib32/ld.so.1 => /scratch/jmyers/glibc/mbs/obj/glibc-8-0-mips64-linux-gnu-x86_64-linux-gnu/default/elf/ld.so.1 (0x7747b000)

tries to copy /lib32/ld.so.1 (which does not exist) into the testroot
instead of copying the path on the RHS of "=>", which does exist,
because the Makefile logic assumes that the path on such a line with
'/' should be copied, when if there are such paths on both the LHS and
the RHS of "=>", only the one on the RHS necessarily exists and so
only that should be copied.  The patch follows the approach suggested
by DJ in <https://sourceware.org/ml/libc-alpha/2019-07/msg00662.html>.

Tested for x86_64, with and without --enable-hardcoded-path-in-tests;
also previously tested for MIPS, with and without
--enable-hardcoded-path-in-tests, to confirm it fixes the original
problem.

Co-authored-by: DJ Delorie <dj@redhat.com>
  

Comments

Andreas Schwab Oct. 17, 2019, 8:48 a.m. UTC | #1
On Okt 16 2019, Joseph Myers <joseph@codesourcery.com> wrote:

> diff --git a/Makefile b/Makefile
> index a736c3afcc..b16b82d3e1 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -555,7 +555,7 @@ ifeq ($(run-built-tests),yes)
>  	for dso in `$(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1  \
>  		$(rtld-prefix) \
>  		$(objpfx)testroot.pristine/bin/sh \
> -	        | grep / | sed 's/^[^/]*//' | sed 's/ .*//'` ;\
> +	        | grep / | sed 's@.*=> /@/@' | sed 's/^[^/]*//' | sed 's/ .*//'` ;\

You can combine those four pipelines into a single sed call.

Andreas.
  

Patch

diff --git a/Makefile b/Makefile
index a736c3afcc..b16b82d3e1 100644
--- a/Makefile
+++ b/Makefile
@@ -555,7 +555,7 @@  ifeq ($(run-built-tests),yes)
 	for dso in `$(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1  \
 		$(rtld-prefix) \
 		$(objpfx)testroot.pristine/bin/sh \
-	        | grep / | sed 's/^[^/]*//' | sed 's/ .*//'` ;\
+	        | grep / | sed 's@.*=> /@/@' | sed 's/^[^/]*//' | sed 's/ .*//'` ;\
 	  do \
 	    test -d `dirname $(objpfx)testroot.pristine$$dso` || \
 	      mkdir -p `dirname $(objpfx)testroot.pristine$$dso` ;\
@@ -564,7 +564,7 @@  ifeq ($(run-built-tests),yes)
 	for dso in `$(test-wrapper-env) LD_TRACE_LOADED_OBJECTS=1  \
 		$(rtld-prefix) \
 		$(objpfx)support/$(LINKS_DSO_PROGRAM) \
-	        | grep / | sed 's/^[^/]*//' | sed 's/ .*//'` ;\
+	        | grep / | sed 's@.*=> /@/@' | sed 's/^[^/]*//' | sed 's/ .*//'` ;\
 	  do \
 	    test -d `dirname $(objpfx)testroot.pristine$$dso` || \
 	      mkdir -p `dirname $(objpfx)testroot.pristine$$dso` ;\