From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id E69F93858D33 for ; Thu, 2 Mar 2023 11:38:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E69F93858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org From: =?UTF-8?q?Arsen=20Arsenovi=C4=87?= To: libc-alpha@sourceware.org Cc: Carlos O'Donell , Gentoo Toolchain , =?UTF-8?q?Arsen=20Arsenovi=C4=87?= Subject: [PATCH] elf,nptl: Add -z lazy -z norelro to tests that need it Date: Thu, 2 Mar 2023 12:25:19 +0100 Message-Id: <20230302112519.914641-1-arsen@gentoo.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Some toolchains, such as that used on Gentoo Hardened, set -z now -z relro out of the box. These flags break tests that rely on fixups in underlinked libraries being applied after a dlopen happens. --- Morning, This patch fixes a few test failures that we encounter on Gentoo when using a toolchain that builds packages with full relro. All of these failures come down to underlinked test objects, which are inherently in opposition with it. Tested on x86_64-pc-linux-gnu against 2.37 and 59a6d5e9477695c41d6feef7ef8636f8f744f3c5, so it should be okay for backporting too. Have a lovely day! elf/Makefile | 22 +++++++++++++++++++++- nptl/Makefile | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/elf/Makefile b/elf/Makefile index 0d19964d42..3387b7e6c9 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -1190,6 +1190,11 @@ postclean-generated += $(objpfx)/dso-sort-tests-2.generated-makefile \ ifeq (yes,$(have-tunables)) $(eval $(call include_dsosort_tests,dso-sort-tests-1.def)) $(eval $(call include_dsosort_tests,dso-sort-tests-2.def)) + +# BZ15311 is intentionally underlinked. +LDFLAGS-tst-bz15311-b.so += -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-tst-bz15311-c.so += -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-tst-bz15311-d.so += -Wl,-z,lazy -Wl,-z,norelro endif check-abi: $(objpfx)check-abi-ld.out \ @@ -1514,6 +1519,20 @@ LDFLAGS-tst-initorderb2.so = -Wl,--no-as-needed LDFLAGS-tst-tlsmod5.so = -nostdlib -Wl,--no-as-needed LDFLAGS-tst-tlsmod6.so = -nostdlib -Wl,--no-as-needed +# The following tests are underlinked or rely on fixups being applied after a +# dlopen call. On toolchains that set -z now and -z relro by default, this +# leads to failures to load or fix up the executables being tested. +LDFLAGS-circlemod2.so = -Wl,-z,lazy +LDFLAGS-tst-tls20mod-bad.so = -Wl,-z,lazy +LDFLAGS-reldep6mod1.so += -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-constload2.so = -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-constload3.so = -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-dblloadmod3.so = -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-ifuncmod6.so = -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-ltglobmod2.so = -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-testobj1.so = -Wl,-z,lazy -Wl,-z,norelro +LDFLAGS-testobj6.so = -Wl,-z,lazy -Wl,-z,norelro + testobj1.so-no-z-defs = yes testobj3.so-no-z-defs = yes testobj4.so-no-z-defs = yes @@ -1612,6 +1631,7 @@ $(objpfx)multiload.out: $(objpfx)testobj1.so LDFLAGS-origtest = -rdynamic $(objpfx)origtest.out: $(objpfx)testobj1.so +$(objpfx)resolvfail.out: $(objpfx)testobj1.so ifeq ($(have-thread-library),yes) $(objpfx)resolvfail: $(shared-thread-library) endif @@ -2337,7 +2357,7 @@ LDFLAGS-tst-audit25a = -Wl,-z,lazy $(objpfx)tst-audit25mod1.so: $(objpfx)tst-audit25mod3.so LDFLAGS-tst-audit25mod1.so = -Wl,-z,now $(objpfx)tst-audit25mod2.so: $(objpfx)tst-audit25mod4.so -LDFLAGS-tst-audit25mod2.so = -Wl,-z,lazy +LDFLAGS-tst-audit25mod2.so = -Wl,-z,lazy -Wl,-z,norelro tst-audit25a-ARGS = -- $(host-test-program-cmd) $(objpfx)tst-audit25b.out: $(objpfx)tst-auditmod25.so diff --git a/nptl/Makefile b/nptl/Makefile index 8cec6faee3..140add412c 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -569,7 +569,7 @@ $(objpfx)tst-compat-forwarder: $(objpfx)tst-compat-forwarder-mod.so tst-mutex10-ENV = GLIBC_TUNABLES=glibc.elision.enable=1 # Protect against a build using -Wl,-z,now. -LDFLAGS-tst-audit-threads-mod1.so = -Wl,-z,lazy +LDFLAGS-tst-audit-threads-mod1.so = -Wl,-z,lazy -Wl,-z,norelro LDFLAGS-tst-audit-threads-mod2.so = -Wl,-z,lazy LDFLAGS-tst-audit-threads = -Wl,-z,lazy $(objpfx)tst-audit-threads: $(objpfx)tst-audit-threads-mod2.so -- 2.39.2