From patchwork Wed Nov 11 00:12:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 9646 Received: (qmail 97239 invoked by alias); 11 Nov 2015 00:13:13 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 97218 invoked by uid 89); 11 Nov 2015 00:13:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=3.3 required=5.0 tests=AWL, BAYES_99, BAYES_999, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS, URIBL_BLACK autolearn=no version=3.3.2 X-HELO: mail-oi0-f48.google.com MIME-Version: 1.0 X-Received: by 10.202.208.83 with SMTP id h80mr2910989oig.74.1447200780066; Tue, 10 Nov 2015 16:13:00 -0800 (PST) In-Reply-To: References: <20151107145502.GA959@intel.com> <20151107155458.GF8500@port70.net> Date: Tue, 10 Nov 2015 16:12:59 -0800 Message-ID: Subject: Re: [PATCH] [BZ #19178] Add a test for prelink output From: "H.J. Lu" To: Joseph Myers Cc: Szabolcs Nagy , GNU C Library On Tue, Nov 10, 2015 at 1:43 PM, Joseph Myers wrote: > On Tue, 10 Nov 2015, H.J. Lu wrote: > >> On Mon, Nov 9, 2015 at 6:42 AM, H.J. Lu wrote: >> > On Sat, Nov 7, 2015 at 7:54 AM, Szabolcs Nagy wrote: >> >> * H.J. Lu [2015-11-07 06:55:02 -0800]: >> >>> This test applies to i386 and x86_64 which set R_386_GLOB_DAT and >> >>> R_X86_64_GLOB_DAT to ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA. OK for >> >>> master? >> >>> >> >> >> >> why is the test x86 specific? >> >> >> >> extern protected data handling and LD_TRACE_PRELINKING >> >> seem to be generic. >> > >> > It only applies to GLOB_DAT relocation. Not all targets have it >> > and I have only x86 to test. >> > >> >> I will check it in and backport the fix with this this to 2.22 branch. > > I see no sign of consensus for an x86-specific test here. I too think the > test should be written in an architecture-independent way, with a way for > architectures for which it is inapplicable to disable it. Here is a patch to run it on targets with GLOB_DAT reloc. diff --git a/config.make.in b/config.make.in index 75bb9cc..ba9c60d 100644 --- a/config.make.in +++ b/config.make.in @@ -50,6 +50,7 @@ enable-werror = @enable_werror@ have-z-combreloc = @libc_cv_z_combreloc@ have-z-execstack = @libc_cv_z_execstack@ have-protected-data = @libc_cv_protected_data@ +have-glob-dat-reloc = @libc_cv_has_glob_dat@ with-fp = @with_fp@ enable-timezone-tools = @enable_timezone_tools@ unwind-find-fde = @libc_cv_gcc_unwind_find_fde@ diff --git a/configure b/configure index 01f5075..90953f0 100755 --- a/configure +++ b/configure @@ -622,6 +622,7 @@ libc_cv_cc_nofma stack_protector fno_unit_at_a_time libc_cv_output_format +libc_cv_has_glob_dat libc_cv_hashstyle libc_cv_fpie libc_cv_z_execstack @@ -5693,6 +5694,39 @@ $as_echo "$libc_cv_use_default_link" >&6; } use_default_link=$libc_cv_use_default_link fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLOB_DAT reloc" >&5 +$as_echo_n "checking for GLOB_DAT reloc... " >&6; } +if ${libc_cv_has_glob_dat+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat > conftest.c <&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } +then + if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then + libc_cv_has_glob_dat=yes + else + libc_cv_has_glob_dat=no + fi +else + libc_cv_has_glob_dat=no +fi +rm -f conftest* +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_has_glob_dat" >&5 +$as_echo "$libc_cv_has_glob_dat" >&6; } + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking linker output format" >&5 $as_echo_n "checking linker output format... " >&6; } if ${libc_cv_output_format+:} false; then : diff --git a/configure.ac b/configure.ac index 3fdf992..cd37433 100644 --- a/configure.ac +++ b/configure.ac @@ -1340,6 +1340,29 @@ $ac_try" use_default_link=$libc_cv_use_default_link fi +AC_CACHE_CHECK(for GLOB_DAT reloc, + libc_cv_has_glob_dat, [dnl +cat > conftest.c <&AS_MESSAGE_LOG_FD]) +then +dnl look for GLOB_DAT relocation. + if $READELF -rW conftest.so | grep '_GLOB_DAT' > /dev/null; then + libc_cv_has_glob_dat=yes + else + libc_cv_has_glob_dat=no + fi +else + libc_cv_has_glob_dat=no +fi +rm -f conftest*]) +AC_SUBST(libc_cv_has_glob_dat) + AC_CACHE_CHECK(linker output format, libc_cv_output_format, [dnl if libc_cv_output_format=` ${CC-cc} -nostartfiles -nostdlib -Wl,--print-output-format 2>&AS_MESSAGE_LOG_FD` diff --git a/elf/Makefile b/elf/Makefile index 76985cc..9d2dc5c 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -302,6 +302,13 @@ check-abi: $(objpfx)check-abi-ld.out tests-special += $(objpfx)check-abi-ld.out update-abi: update-abi-ld +ifeq ($(have-glob-dat-reloc),yes) +tests += tst-prelink +ifeq ($(run-built-tests),yes) +tests-special += $(objpfx)tst-prelink-cmp.out +endif +endif + include ../Rules ifeq (yes,$(build-shared)) @@ -1234,3 +1241,13 @@ $(objpfx)tst-audit12: $(libdl) tst-audit12-ENV = LD_AUDIT=$(objpfx)tst-auditmod12.so $(objpfx)tst-audit12mod1.so: $(objpfx)tst-audit12mod2.so LDFLAGS-tst-audit12mod2.so = -Wl,--version-script=tst-audit12mod2.map + +tst-prelink-ENV = LD_TRACE_PRELINKING=1 + +$(objpfx)tst-prelink-conflict.out: $(objpfx)tst-prelink.out + grep stdout $< | grep conflict | $(AWK) '{ print $$10, $$11 }' > $@ + +$(objpfx)tst-prelink-cmp.out: tst-prelink.exp \ + $(objpfx)tst-prelink-conflict.out + cmp $^ > $@; \ + $(evaluate-test) diff --git a/sysdeps/x86/tst-prelink.c b/elf/tst-prelink.c similarity index 100% rename from sysdeps/x86/tst-prelink.c rename to elf/tst-prelink.c diff --git a/sysdeps/x86/tst-prelink.exp b/elf/tst-prelink.exp similarity index 100% rename from sysdeps/x86/tst-prelink.exp rename to elf/tst-prelink.exp diff --git a/sysdeps/x86/Makefile b/sysdeps/x86/Makefile index a2f4f8a..0de4f42 100644 --- a/sysdeps/x86/Makefile +++ b/sysdeps/x86/Makefile @@ -7,19 +7,4 @@ sysdep-dl-routines += dl-get-cpu-features tests += tst-get-cpu-features tests-static += tst-get-cpu-features-static - -tests += tst-prelink -tst-prelink-ENV = LD_TRACE_PRELINKING=1 - -$(objpfx)tst-prelink-conflict.out: $(objpfx)tst-prelink.out - grep stdout $< | grep conflict | $(AWK) '{ print $$10, $$11 }' > $@ - -$(objpfx)tst-prelink-cmp.out: $(..)sysdeps/x86/tst-prelink.exp \ - $(objpfx)tst-prelink-conflict.out - cmp $^ > $@; \ - $(evaluate-test) - -ifeq ($(run-built-tests),yes) -tests-special += $(objpfx)tst-prelink-cmp.out -endif endif