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-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham 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 B79B31F55B for ; Sun, 24 May 2020 20:58:18 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2DD18386F816; Sun, 24 May 2020 20:58:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2DD18386F816 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1590353896; bh=F8V5KSkOhE4G15BnywCrB0YfBVLNNJSM+kpyZnXsHe4=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=leLr5RATk7EBbyHW3e2iMK0YqNjt5kkGV7F8B7fXvlObN93Cz9IDYsZhde0Fmj5IQ FMIhXkttZHRS2Re+FkIMnZ1Kmu9giHOW7lxP2A/GcOxrNT1etBCnPOrPtCMEy/IE7i CKpVinaRMVkyW3VERbA+Lcmxfjxh349zx1G68Crw= Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by sourceware.org (Postfix) with ESMTPS id A6E57385BF81 for ; Sun, 24 May 2020 20:58:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A6E57385BF81 Received: by mail-pl1-x643.google.com with SMTP id x10so6737844plr.4 for ; Sun, 24 May 2020 13:58:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=F8V5KSkOhE4G15BnywCrB0YfBVLNNJSM+kpyZnXsHe4=; b=TKLJoRFl4wFKdG5AVe+e6TXqmxCPZJIntG91xLxqGpnkuKaOj/X+VOUKckRKdBs4CY sW/bxP8Ow7andjxL/hoQsLzeFT7plgeSUQGBLbNWEKF4HNmzAOit6diu51uuEbBSu62/ 4zD9xOTWs3c9do952aop+UWRkRX1tragRvJST+G5DlKipOF9GBRLRQN1ZTO7oRYXc+1h I9TIj1tbjZT8nSleF3BX0Ka68OShg7sFrTs/rZ4wy6+W7rbG2P0PXOtGFlPPoBK2HO6i kWInNQ1lZqke05mRixNo2PX8DUGxLEIzYnmUv8+FbDZOYCStd+jKiNloMP/IlGuxnjCp UFJA== X-Gm-Message-State: AOAM5324oQTv39GuRlZH2DlfoGtkySunU7FfOQxRVDhf6X0EA6VBm1Th 9kX8HPfrENTez/UQouZlzELsmuXW+NA= X-Google-Smtp-Source: ABdhPJye2K0e4vj2d/bmFaHMji9PwBBC6viOHKHeekvpacoBZKL81iSNdevZC0F/Sor+oAAn97qUcA== X-Received: by 2002:a17:90a:36a9:: with SMTP id t38mr17341058pjb.48.1590353889543; Sun, 24 May 2020 13:58:09 -0700 (PDT) Received: from google.com ([2620:15c:2ce:0:9efe:9f1:9267:2b27]) by smtp.gmail.com with ESMTPSA id o14sm11386727pfp.89.2020.05.24.13.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 13:58:08 -0700 (PDT) Date: Sun, 24 May 2020 13:58:05 -0700 To: binutils@sourceware.org, libc-alpha@sourceware.org Subject: Re: ld: -z rel and -z relr Message-ID: <20200524205805.j7cdh5pu4pqf227q@google.com> References: <20200515070454.xdlshf3qgqockrnx@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200515070454.xdlshf3qgqockrnx@google.com> 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: Fangrui Song via Libc-alpha Reply-To: Fangrui Song Cc: Cary Coutant , Roland McGrath Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" CC libc-alpha for feedback on the possibility * supporting both REL and RELA in ld.so ..... (musl supports both REL and RELA out of the box..) (FreeBSD rtld supports one format, like glibc) * supporting RELR for a compact R_*_RELATIVE representation -- CC Cary in case the wording from https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg "Proposal for a new section type SHT_RELR" can be placed in a more "official" place. On 2020-05-15, Fangrui Song wrote: >Many dynamic relocations have zero addend. IFAIK GLOB_DAT, >J[U]MP_SLOT and COPY always have 0 addend. An absolute relocation type >(R_X86_64_64 R_PPC64_ADDR64) can have non-0 addend but that is rare. > >(Some other relocation types: DTPOFF/DTPMOD, but they are few) > >I can understand that for object files, RELA is generally favorable >(though I'd like to know your thoughts). However, I wonder, if the >dyanmic loader supports REL, should we have a mode, -z rel, to generate >REL outstanding relocation types? The downside may be random access >reads (while with pure RELA, ld.so can blast out a bunch of writes). > >The benefit will be the code size savings. I understand that many ld.so >implementations don't support REL and RELA at the same time (FreeBSD >rtld and glibc; happy to be proved wrong ;-) ), but musl ld.so supports >REL+RELA out of the box. There may be PLT complexty for these ld.so >implementations which can't support both at the same time:) > >----- > >R_*_RELATIVE have non-zero relocation types but they can be compressed >in a better format: RELR https://groups.google.com/forum/#!topic/generic-abi/9OO5vhxb00Y >I suspect it is strictly superior to Firefox >https://wiki.mozilla.org/Elfhack but I haven't actually looked into Firefox (probably because I don't use it...) > >If GNU ld intends to support RELR, -z relr may be a good option name. I >think -z is nice because -z is reserved for ELF specific options.) > >(Yes, I know LLD has --pack-dyn-relocs (since July 2018, before my >serious involvement into LLD), but if we can achieve some agreement >here, maybe LLD can add an alias.) FWIW I created https://reviews.llvm.org/D80496 to add -z rel and -z rela to LLD. Copying useful description here for easy commenting. * COPY, GLOB_DAT and J[U]MP_SLOT always have 0 addend. A ld.so implementation does not need to read the implicit addend. REL is strictly better. * A RELATIVE has a non-zero addend. Such relocations can be packed compactly with the RELR relocation entry format, which is out of scope of this patch. * For other dynamic relocation types (e.g. symbolic relocation R_X86_64_64), a ld.so implementation needs to read the implicit addend. REL may have minor performance impact, because implicit addends force random access reads instead of being able to blast out a bunch of writes while chasing the relocation array.