From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.3 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS,URIBL_BLACK shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id C2DD31F8C6 for ; Tue, 13 Jul 2021 23:58:27 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B5D043857439 for ; Tue, 13 Jul 2021 23:58:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B5D043857439 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1626220706; bh=6V+Ht7aMCbYANY5KF5kv8AKdXvtrdqOh6fSYetaKdKE=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=KtbVoLT1Obj7nzsbU/4B2rsyRz+fNc/cwplLO7OjzVsMip5S5Sh1PAp2cGfmn0lDj PSs3QKPjoV0ZJD6jZ0vwQZeTStOpQCu/LhAczjRsSK43oN99OBj76+AvNRRCcvqfJw dkBOAygAzTzhHXo6nKH+VaXkYv+u5/tuSouSCVyQ= Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by sourceware.org (Postfix) with ESMTPS id F19363858C3B for ; Tue, 13 Jul 2021 23:58:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F19363858C3B Received: by mail-yb1-xb35.google.com with SMTP id x192so202533ybe.6 for ; Tue, 13 Jul 2021 16:58:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=6V+Ht7aMCbYANY5KF5kv8AKdXvtrdqOh6fSYetaKdKE=; b=gXZbZ7Znpyxphm95TF5+CsHkKrUOJUK5DxWUo1W050wNAmehS6CIoUVwq1vlZI2O0q Cjw2wuaAy6tUxZyd+jIMEvOuqiFhsBM9DUkMBcL4rJn9oHzM9UVZLJPIt1wHJbL2dvPn MWAT3lLNpH2z0piQip79sbYDtTUjF2oW0KsFMWDC47/cJ2W3eXzqXt9CXAm9J5Vijg5f P570/RsqvwPjWxoVTKHuaki4yPG4obYx6rcw/EMrzpTFxVkpX+9YYm+PrnyLZhL6tvDO IaWxbDl5w1/coXtN9guHu+Cw7gAHRD680iXXyflDg3dwHQc255Ny1TUBRdJTZeiBfpmx M6dA== X-Gm-Message-State: AOAM531gC/NEJlqJ5QBA3qi2uY/GnPInvGiipT5/c6GVfH79Y2WTj3te uZ7BUaUSFbZr0el30seVGecvjWAStANpXlx9zaoAFg== X-Google-Smtp-Source: ABdhPJxIxtxWWWnkvkR5fUilthl4kYJyD4w/m5ncp239wRGC4XdkzcobjEK0GISh44xLh0gguHddF9bAgQrqNENqui0= X-Received: by 2002:a25:744c:: with SMTP id p73mr9053519ybc.507.1626220686383; Tue, 13 Jul 2021 16:58:06 -0700 (PDT) MIME-Version: 1.0 References: <20210708221032.955550-1-maskray@google.com> <8b8fb5c9-ce4e-b10e-95b1-0281f96894c0@redhat.com> <20210713080646.3n3ycmh3p4d7ul3t@google.com> <11b630ce-8d50-ee07-37e9-b5fec16a6f18@gotplt.org> <20210713230639.mkyiijn6v7tlo7fc@google.com> In-Reply-To: Date: Tue, 13 Jul 2021 16:57:55 -0700 Message-ID: Subject: Re: [PATCH] csu: Skip ARCH_SETUP_IREL if _dl_relocate_static_pie applied IRELATIVE relocations [BZ #27164] To: "H.J. Lu" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: =?utf-8?q?F=C4=81ng-ru=C3=AC_S=C3=B2ng_via_Libc-alpha?= Reply-To: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Cc: GNU C Library Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" On Tue, Jul 13, 2021 at 4:48 PM H.J. Lu wrote: > > On Tue, Jul 13, 2021 at 4:31 PM F=C4=81ng-ru=C3=AC S=C3=B2ng wrote: > > > > On Tue, Jul 13, 2021 at 4:21 PM H.J. Lu wrote: > > > > > > On Tue, Jul 13, 2021 at 4:07 PM Fangrui Song via Libc-alpha > > > wrote: > > > > > > > > On 2021-07-13, Siddhesh Poyarekar wrote: > > > > >On 7/13/21 1:36 PM, Fangrui Song via Libc-alpha wrote: > > > > >>A toolchain project can do some workaround for a libc if this cho= ice > > > > >>makes a large community happy. However, I think it is important n= ot to > > > > >>take it granted. It is inadequate to just dismiss toolchain devel= opers' > > > > >>reasonable complaints. The libc should actively fix the issues so= that > > > > >>the toolchain will not need to bear unneeded code in the future. > > > > >> > > > > >>I actually have contributed quite a few lld/ELF patches to work a= round > > > > >>glibc. For this one I just feel it is not right to just patch lld= /ELF > > > > >>without fixing glibc. > > > > > > > > > >What's the utility of having the __rela_iplt{_start,_end} symbols = in > > > > >all binaries other than, maybe, simplifying the static linker > > > > >implementation? How does it improve things for the generated > > > > >application code in the end? AFAICT it is doing the opposite by > > > > >requiring application startup to add a conditional to work around = the > > > > >presence of a redundant symbol. > > > > > > > > > >Siddhesh > > > > > > > > Please see the sentence from the first message > > > > "In addition, this enables a future simplification to GNU ld: we ca= n > > > > drop a linker script difference between -no-pie and -pie." > > > > > > Did you mean non-PIE static and PIE static? Neither PIE nor PDE > > > define __rela_iplt{_start,_end}. > > > > > > > This is the only difference other than image base difference. > > > > > > There are many differences between non-PIE static and PIE static. > > > Non-PIE static doesn't have DT_XXX sections. > > > > % diff -U1 =3D(ld.bfd --verbose) =3D(ld.bfd -pie --verbose) > > --- /tmp/zshEtZMxJ 2021-07-13 16:30:50.228732445 -0700 > > +++ /tmp/zshNM1wJL 2021-07-13 16:30:50.232732450 -0700 > > @@ -12,3 +12,3 @@ > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D > > -/* Script for -z combreloc -z separate-code */ > > +/* Script for -pie -z combreloc -z separate-code */ > > /* Copyright (C) 2014-2020 Free Software Foundation, Inc. > > @@ -24,3 +24,3 @@ > > { > > - PROVIDE (__executable_start =3D SEGMENT_START("text-segment", > > 0x400000)); . =3D SEGMENT_START("text-segment", 0x400000) + > > SIZEOF_HEADERS; > > + PROVIDE (__executable_start =3D SEGMENT_START("text-segment", 0)); . > > =3D SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS; > > .interp : { *(.interp) } > > @@ -55,5 +55,3 @@ > > *(.rela.plt) > > - PROVIDE_HIDDEN (__rela_iplt_start =3D .); > > *(.rela.iplt) > > - PROVIDE_HIDDEN (__rela_iplt_end =3D .); > > } > > Here is the deal: > > 1. ld uses the same linker script for both PDE static and PDE. We need > __rela_iplt{_start,_end} for PDE static. That is why there are > > PROVIDE_HIDDEN (__rela_iplt_start =3D .); > *(.rela.iplt) > PROVIDE_HIDDEN (__rela_iplt_end =3D .); > > Since PDE is linked against libc.so which doesn't reference > __rela_iplt{_start,_end}, these symbols are not defined for PDE. > > 2. ld uses the same linker script for both PIE static and PIE. There is > no need for __rela_iplt{_start,_end}. > > Are you suggesting to use the same linker scripts for PDE, PDE static, > PIE and PIE static? Because of the image base difference, PDE/PIE linker scripts cannot be entirely identical, but symbol differences should be reduced. BTW: diff -u =3D(ld.bfd -pie --verbose) =3D(ld.bfd -shared --verbose) has some PROVIDE_HIDDEN differences. Since these symbols are PROVIDE style, these differences are artificial and should be reduced as well.