public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: "Arsen Arsenović" <arsen@gentoo.org>
Cc: libc-alpha@sourceware.org,  Carlos O'Donell <carlos@redhat.com>,
	 Gentoo Toolchain <toolchain@gentoo.org>
Subject: Re: [PATCH] elf,nptl: Add -z lazy -z norelro to tests that need it
Date: Mon, 06 Mar 2023 10:15:45 +0100	[thread overview]
Message-ID: <87bkl6xmta.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <86fsakz5mr.fsf@gentoo.org> ("Arsen =?utf-8?Q?Arsenovi=C4=87?= =?utf-8?Q?=22's?= message of "Sat, 04 Mar 2023 18:46:50 +0100")

* 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


  reply	other threads:[~2023-03-06  9:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-02 11:25 Arsen Arsenović
2023-03-03 11:51 ` Florian Weimer
2023-03-03 21:54   ` Arsen Arsenović
2023-03-04 17:46     ` Arsen Arsenović
2023-03-06  9:15       ` Florian Weimer [this message]
2023-03-06 14:17         ` Arsen Arsenović
2023-03-06 16:42           ` Arsen Arsenović

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bkl6xmta.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=arsen@gentoo.org \
    --cc=carlos@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=toolchain@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).