[PATCH] elf,nptl: Add -z lazy -z norelro to tests that need it
Florian Weimer
fweimer@redhat.com
Mon Mar 6 09:15:45 GMT 2023
* Arsen Arsenović:
> Arsen Arsenović <arsen@gentoo.org> writes:
>
>> Hm. Something went awry while I was debugging this. I looked at a test
>> again just now and noticed that the symbols some of these tests were
>> crashing on came from libc (dlopen here) while loading constload2 (which
>> is dlopen'd from constload1). The backtrace contains a PLT trampoline
>> which then fixups dlopen inside the RELRO segment.
>>
>> I take it dlopen@got[plt] is not supposed to be in the RELRO range?
>>
>> I could have sworn this failed when fixing up bar (void) as a result of
>> constload2 dlopening constload3... but maybe that was a different
>> failure.
>>
>> Let's put this patch on hold while I investigate further.
>>
>> FWIW, this should be easy to reproduce by building with CC='gcc
>> -Wl,-z,relro,-z,now' or so, I think.
>
> Ah, I think I see the issue:
>
> ~/gnu/glibc/b2$ diff -u0 shlib.lds.-Wl,-z,{lazy,now},-z,relro
> --- shlib.lds.-Wl,-z,lazy,-z,relro 2023-03-04 19:54:42.977032934 +0100
> +++ shlib.lds.-Wl,-z,now,-z,relro 2023-03-04 18:57:03.195010040 +0100
> @@ -1 +1 @@
> -/* Script for -shared -z combreloc -z separate-code */
> +/* Script for -shared -z combreloc -z separate-code -z relro -z now */
> @@ -153,3 +153,2 @@
> - .got : { *(.got) *(.igot) }
> - . = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 24 ? 24 : 0, .);
> - .got.plt : { *(.got.plt) *(.igot.plt) }
> + .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
> + . = DATA_SEGMENT_RELRO_END (0, .);
> ~/gnu/glibc/b2 1 $
>
> The builds system assumes that all the flags used while building glibc
> use the same linker script, and that this will be the same linker script
> as the one that's used initially to generate shlib.lds. This is not
> true when -z relro is set and -z {now,lazy} are being varied.
>
> This also explains why the problem only arose after we introduced
> -Wl,-z,now.
Interesting, thanks for looking into this.
Does the issue go away if you configure with --enable-bind-now?
That's what we are doing, and we don't see those test failures.
Florian
More information about the Libc-alpha
mailing list