From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id BFE993858D39 for ; Mon, 6 Mar 2023 09:15:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BFE993858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678094152; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Gn6an4h/7xYmeShPiNx/5zijp/F3oSGKLefp3qOLowc=; b=BiNZiSr8QwKLKKjOt9u9bWFicwOnAJcmLNCeOTj7mR15S4fEFMMQdzfTDDIHogBih3uMf4 PtzfWkom7czoNjzHvPh8WNqnDATdSPu1Vkkk1WNe3ycynHBMx0kbUZib4yC3mTNOCloVJU Qxl8YOd1XYT9dEMw5q4He9U8x4wo1lE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-35-LL-hIx3XPDalJk6yUP88Dw-1; Mon, 06 Mar 2023 04:15:48 -0500 X-MC-Unique: LL-hIx3XPDalJk6yUP88Dw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6730985A588; Mon, 6 Mar 2023 09:15:48 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.80]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 29F732026D4B; Mon, 6 Mar 2023 09:15:46 +0000 (UTC) From: Florian Weimer To: Arsen =?utf-8?Q?Arsenovi=C4=87?= Cc: libc-alpha@sourceware.org, Carlos O'Donell , Gentoo Toolchain Subject: Re: [PATCH] elf,nptl: Add -z lazy -z norelro to tests that need it References: <20230302112519.914641-1-arsen@gentoo.org> <87bklajbna.fsf@oldenburg.str.redhat.com> <86y1odlbss.fsf@gentoo.org> <86fsakz5mr.fsf@gentoo.org> Date: Mon, 06 Mar 2023 10:15:45 +0100 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") Message-ID: <87bkl6xmta.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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: * Arsen Arsenovi=C4=87: > Arsen Arsenovi=C4=87 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=3D'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=20 > --- shlib.lds.-Wl,-z,lazy,-z,relro=092023-03-04 19:54:42.977032934 +010= 0 > +++ shlib.lds.-Wl,-z,now,-z,relro=092023-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) } > - . =3D DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >=3D 24 ? 24 : 0, .)= ; > - .got.plt : { *(.got.plt) *(.igot.plt) } > + .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) } > + . =3D DATA_SEGMENT_RELRO_END (0, .); > ~/gnu/glibc/b2 1 $=20 > > 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