From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id E00EE3857819 for ; Fri, 29 Oct 2021 19:15:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E00EE3857819 Received: by mail-pl1-x636.google.com with SMTP id t21so7437947plr.6 for ; Fri, 29 Oct 2021 12:15:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Z/H7q4D7tuP+WoAZykeoQE33fRgrHagg0xj/TvdIupA=; b=fojcE1YLqvM+XkcaIODnYz+weCceyxh6+F91ff8ouUrUZhCe3hqjFG+BA1OTfQbfjN fYeASCtgKuyof8LD+vqNeBLKKrcrLL6Ke/fPCMOWiEFpHDLKw5LLIydSWyLHN5nJeDgM qLPq8J8KobReu9YGkVS5QveIGDrhTZOFHb8NN4I7Psua7zGAKrsKLZLyhuTCEmzy2QC7 21XmA2iwSPgS5BWBpMldwZYER/setiKDuih50KVPyELCnVVJy3agp3O3U0S3A0eRHj+A Q+IoDSIcKKbazenf4VwfDCcaXmrOWJQ7d3uOx/vS7tznGR7bLyBlwTBcfsHMx81e9giK JjiQ== X-Gm-Message-State: AOAM530MrFZs2K+Egz63h081iutWrcs6DT2exvpCnz17JclmetivdiSu Fla5XR1a2NLtTTwf4cMwqAQvyA== X-Google-Smtp-Source: ABdhPJwTm1yndOwLCISLeXV6xrELKxrZ0XOEbu8T6v3lyPuUD6NwBtGpCXyMpFyHwFKZY9Yhbe21gQ== X-Received: by 2002:a17:90b:124d:: with SMTP id gx13mr2524445pjb.106.1635534915527; Fri, 29 Oct 2021 12:15:15 -0700 (PDT) Received: from google.com ([2620:15c:2ce:200:cc1b:3207:3348:1a2a]) by smtp.gmail.com with ESMTPSA id n11sm6167413pgm.74.2021.10.29.12.15.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 12:15:15 -0700 (PDT) Date: Fri, 29 Oct 2021 12:15:12 -0700 From: Fangrui Song To: "H.J. Lu" Cc: Carlos O'Donell , GNU C Library , Binutils Subject: Re: [PATCH v2] elf: Support DT_RELR relative relocation format [BZ #27924] Message-ID: <20211029191512.unestea3abnny6qt@google.com> References: <20211017005020.2645717-1-maskray@google.com> <1763c6f4-dfb9-e102-84d6-892ee2a3208a@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-18.3 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, FSL_HELO_FAKE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Fri, 29 Oct 2021 19:15:19 -0000 On 2021-10-29, H.J. Lu wrote: >On Fri, Oct 29, 2021 at 11:22 AM Carlos O'Donell via Binutils > wrote: >> >> On 10/16/21 20:50, Fangrui Song via Binutils wrote: >> > PIE and shared objects usually have many relative relocations. In >> > 2017/2018, SHT_RELR/DT_RELR was proposed on >> > https://groups.google.com/g/generic-abi/c/bX460iggiKg/m/GxjM0L-PBAAJ >> > ("Proposal for a new section type SHT_RELR") and is a pre-standard. RELR >> > usually takes 3% or smaller space than R_*_RELATIVE relocations. The >> > virtual memory size of a mostly statically linked PIE is typically 5~10% >> > smaller. >> >> We've been going over this patch on the weekly Monday patch queue review. >> >> I took a note to point out that one of the blockers here is that it is difficult >> to immediately test this work because it requires a working glibc build using >> ldd (which has support for DT_RELR). >> >> What is the status of the lld support patches for glibc? >> >> If we made progress on the lld support then we'd be able to more easily review >> a testable configuration and keep the review going forward. >> > >I raised the mysterious crash issue: > >https://groups.google.com/g/generic-abi/c/bX460iggiKg > >We need an updated proposal without mysterious crashes. One option is >that the linker should bump EI_ABIVERSION when generating DT_RELR. The generic ABI says : "EI_ABIVERSION: ... The interpretation of this version number is dependent on the ABI identified by the EI_OSABI field." Operating systems decide their EI_ABIVERSION. Having a linker option not bumping the ABI version can benefit some operating systems. We know that FreeBSD (ELFOSABI_FREEBSD)/Fuchsia/ChromeOS don't find it necessary (or don't want) to bump the ABI version. See https://groups.google.com/g/generic-abi/c/vdG_G4l3N-Y for Solaris' development model. They simply don't support (new object, old system) (I believe that means a diagnostic is good but not required). "it's been pretty drama free over many decades of SunOS." --- So many folks on binutils/glibc are more interested on Linux and let's discuss Linux: Even within ELFOSABI_GNU, different architectures may have different EI_ABIVERSION values. I know that mips may use EI_ABIVERSION==1 for (e_eflags & (EF_MIPS_PIC | EF_MIPS_CPIC)) == EF_MIPS_CPIC position-dependent executables. If you think a linker option like -z relr=glibc or --pack-dyn-relocs=relr-glibc is useful to rule out (DT_RELR object, glibc not supporting DT_RELR) loudly, you may choose the `_dl_have_relr` in .dynsym scheme (https://sourceware.org/pipermail/binutils/2021-October/118347.html). I will probably just make such an option an alias for --pack-dyn-relocs=relr because LLD has (1) some users who don't need this checking (2) --pack-dyn-relocs=relr semantic change would be unnecessary (3) I don't want them to migrate away from --pack-dyn-relocs=relr just because glibc has a different development model. >After this issue is resolved, I can look into the bfd linker support. Will the above said, I grealy appreciate that you can take a stab on the GNU ld support. This will benefit so many Linux distributions. I learned that my /usr/bin/perf_* can be 20% smaller if switching to DT_RELR :) Perhaps 5~10% is more typical for other executables.