From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by sourceware.org (Postfix) with ESMTPS id 146E93857C63 for ; Tue, 29 Sep 2020 04:43:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 146E93857C63 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=emacsray@gmail.com Received: by mail-pf1-f196.google.com with SMTP id x22so3289536pfo.12 for ; Mon, 28 Sep 2020 21:43:56 -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:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=o/8qzf1dU9ntPuKAR2T7m6ZqeY0z7klyEUeUOWU6b8A=; b=CgODuAe8AHp+eQe/x0xaYJI6cS6YynVmzI33F4o6x8gFjQpP8FYZwNtgEczhUDH7zg xcz/OTLx2wBoHkAfsEvN69PesNXi9QB3rZPf/LxFuHo9tzPydfCU1Sry16+r81FtmOlj BoO+gXAUTtukDAbOLJ9oSmOqrnx+UpZYMyFPruEuibTZlsnuhQ6FgKfMJ9kLk3fRjJUL +g24mK+boTkxhJBRbf3yJMlFfxF05BvAeqc6qjhbGD4FpMj7HnaIxW3baqJNZVvtt5/2 JXFqYtFAJ7LHi03J4VmxT+sllKzmAq+vUDZfOYS7ow5uBA0q8aRe8a2yRLJydtNc4j9W /ovw== X-Gm-Message-State: AOAM530lLGNVy++LRCbfNe+7wkPuygQX+ounrtDEPNOMt/QDDzYJfkcF uv3DuitFMqlE6Uiu/df0q1rkY3LN+axPAg== X-Google-Smtp-Source: ABdhPJwTHViI5QfLeHXFUaTn2IBinwgP0BcSVnISXC9gGrKmYQZ7g580ircedUcOtWAWthtMkwdMJQ== X-Received: by 2002:a17:902:ff10:b029:d1:f8be:ac75 with SMTP id f16-20020a170902ff10b02900d1f8beac75mr2638441plj.81.1601354635052; Mon, 28 Sep 2020 21:43:55 -0700 (PDT) Received: from localhost ([2601:647:4b01:ae80::51fb]) by smtp.gmail.com with ESMTPSA id v5sm3228864pfu.151.2020.09.28.21.43.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Sep 2020 21:43:54 -0700 (PDT) Date: Mon, 28 Sep 2020 21:43:53 -0700 From: Fangrui Song To: binutils@sourceware.org Subject: Re: [PATCH v2] Support for SHF_GNU_RETAIN ELF Section Flag Message-ID: <20200929044353.vx26ypc2oioqbmfb@gmail.com> References: <20200928132613.btkqaoomv4fdnupn@jozef-acer-manjaro> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200928132613.btkqaoomv4fdnupn@jozef-acer-manjaro> X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_INFOUSMEBIZ, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Sep 2020 04:43:58 -0000 On 2020-09-28, Jozef Lawrynowicz wrote: >The attached patch is version 2 of the SHF_GNU_RETAIN patch that was >previously discussed here: >https://sourceware.org/pipermail/binutils/2020-September/113406.html > >The following changes have been made: >- Removed the .retain directive >- The assembler will create different input sections for sections with > the same name but SHF_GNU_RETAIN set/unset (thanks to H.J. for that). > This means the linker will be able to do a better job garbage > collecting input sections, as the "retain" attribute applied to a > symbol declaration in the source code will not cause other parts of > the program that are not required, but are in the same section, to be > unnecessarily retained. >- Added GNU OSABI handling (also thanks to H.J.). My point from https://sourceware.org/pipermail/binutils/2020-September/113466.html stands. Section flags are a bit cumbersome. If the following // a.h __attribute__((section("sec"))) inline void bar() { ... } // a.c #include "a.h" __attribute__((section("sec"), retain)) void foo() { } compiles to .section sec,"a",@progbits ... .section sec,"aR",@progbits ... You will get a gas error for changing section flags (https://sourceware.org/pipermail/binutils/2020-February/109945.html) .reloc is really convenience in this case. You can add as many .reloc directives as you like, each contributing one R_*_NONE to the object file but zero cost to the linked image.