[v2] elf: Add -z lazy to some more tests

Message ID 20230307003222.2810662-1-arsen@aarsen.me
State Superseded
Headers
Series [v2] elf: Add -z lazy to some more tests |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Arsen Arsenović March 7, 2023, 12:32 a.m. UTC
  From: Arsen Arsenović <arsen@gentoo.org>

Some toolchains, such as that used on Gentoo Hardened, set '-z now' out
of the box.  This trips up a couple of tests.
---
Evening,

This is a re-roll of the following patch series:
https://inbox.sourceware.org/libc-alpha/20230302112519.914641-1-arsen@gentoo.org/

Changes from v1:
- Dropped -z norelro.  This turned out to be unnecessary after
  Adhemervals removal of --with-default-link and linker script
  machinery:
  https://patchwork.sourceware.org/project/glibc/list/?series=17843
  See: https://inbox.sourceware.org/libc-alpha/86fsakz5mr.fsf@gentoo.org
  for an explanation of what caused the need for norelro.  That fix was
  misguided, due to a previous error on my part, too.
  I applied this patch on top of that patchset and it would appear to
  resolve all related failures.
  The above is not applied to Git yet, but should be before this patch
  is.

 elf/Makefile | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
  

Comments

Florian Weimer March 7, 2023, 9:08 a.m. UTC | #1
* Arsen Arsenović:

> @@ -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

Thsis seems unrelated?  I can see why it's needed, but please mention it
in the commit message at least?

Thanks,
Florian
  
Arsen Arsenović March 7, 2023, 9:23 a.m. UTC | #2
Florian Weimer <fweimer@redhat.com> writes:

> * Arsen Arsenović:
>
>> @@ -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
>
> Thsis seems unrelated?  I can see why it's needed, but please mention it
> in the commit message at least?

Ah, right.  I forgot about that entirely.

That test uses the testobj6, but doesn't depend on it.  If running the
elf/resolvfail test before make check, it's possible to see:

  FAIL: elf/resolvfail
  original exit status 1
  cannot load testobj1.so: testobj1.so: cannot open shared object file: No such file or directory

... which is fixed by just adding the dependency.  Will split into a new
commit and re-send.
  

Patch

diff --git a/elf/Makefile b/elf/Makefile
index 0d19964d42..4d0e04b2a2 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
+LDFLAGS-tst-bz15311-c.so += -Wl,-z,lazy
+LDFLAGS-tst-bz15311-d.so += -Wl,-z,lazy
 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, and rely on late loading.  On toolchains
+# that set -z now 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
+LDFLAGS-constload2.so = -Wl,-z,lazy
+LDFLAGS-constload3.so = -Wl,-z,lazy
+LDFLAGS-dblloadmod3.so = -Wl,-z,lazy
+LDFLAGS-ifuncmod6.so = -Wl,-z,lazy
+LDFLAGS-ltglobmod2.so = -Wl,-z,lazy
+LDFLAGS-testobj1.so = -Wl,-z,lazy
+LDFLAGS-testobj6.so = -Wl,-z,lazy
+
 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