From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by sourceware.org (Postfix) with ESMTPS id 974543858403 for ; Mon, 7 Nov 2022 18:51:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 974543858403 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f173.google.com with SMTP id c2so11870289plz.11 for ; Mon, 07 Nov 2022 10:51:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dfrq+WXA3ZSSENYZZhwJ4f0prc/FQHMebjjhVPPngP4=; b=mPlzgsAzoxZq4sfGXG8pHawwNdRI+OkZEpjX+x3XVcpFT8iIs/q8i05XyFYs6wsrTo 2lIec20Jip9vPLcph5OrMK5KCXubZCb0v51fZls6YnyrI1nWMq3n0aVP7IbOdPV6iT75 XS3JPOyzwWUDQ1X36H3uggHUCXhaIczcEFQVoAKE2M3R5/FsnDEzB6if8VzM0pikdOP3 KulPQFVr38VVk0pr371RQiRsPDUVb8c8vi5uFKejmNI/8gx4GrTHjcbyoLZZoKuNrnRf 7klvXZp22IPBaFDflmM+cnZtnIJYhZKZx5vmXQJIG+os7bWJTB2j+mezdzlDKJ+Ee1B3 Mglg== X-Gm-Message-State: ACrzQf13BHJRz8sZFXqTw9Ac6SvapOU92fNWIE31KoYWtbHsQZxR4B/c Rr2FPgm36dVC3qtEU9yk6gw= X-Google-Smtp-Source: AMsMyM4C8RwZ42HFyrtHPAl8OBV5vK7lJdI1ylwLSyEa9D8FMI919LPanrImqh6yw8DnLG0PkWv+qA== X-Received: by 2002:a17:90a:ca13:b0:213:b85a:3bdb with SMTP id x19-20020a17090aca1300b00213b85a3bdbmr48030018pjt.97.1667847098516; Mon, 07 Nov 2022 10:51:38 -0800 (PST) Received: from localhost ([2601:647:6300:b760:1c3d:291c:9f5a:17d1]) by smtp.gmail.com with ESMTPSA id a84-20020a621a57000000b0056283e2bdbdsm4812888pfa.138.2022.11.07.10.51.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 10:51:37 -0800 (PST) Date: Mon, 7 Nov 2022 10:51:36 -0800 From: Fangrui Song To: Nick Clifton Cc: Michael Matz , gnu-gabi@sourceware.org, "Guillermo E. Martinez" Subject: Re: Using section flags to indicate stripable or persistent sections Message-ID: <20221107185136.5zpzi4gnnzmbqxrm@gmail.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.6 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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 2022-11-07, Michael Matz via Gnu-gabi wrote: >Hey, > >On Mon, 7 Nov 2022, Nick Clifton via Gnu-gabi wrote: > >> We would like to suggest an extension the ELF section flags which can be >> used to indicate sections that should, or should not, be stripped when >> removing debug information. > >Okay, so stripping of sections intended for debug purposes ... > >> The problem we are trying to address is that different stripping tools >> (strip, eu-strip, llvm-strip) have different heuristics for deciding >> which sections should be removed when stripping debug information. In >> order to fix this we are proposing two new section flags: >> >> GNU_SHF_CAN_BE_STRIPPED >> GNU_SHF_DO_NOT_STRIP > >... but here you have "can be stripped?". The immediate question is: for >which purposes? A section might be strippable in other context than debug >info. And other sections might be non-strippable for still other >purposes. Just saying "please don't strip this one" conveys no useful >information, except of course to inhibit each and all stripping. But was >it perhaps set for other reasons than debug info? Even with those flags >tools will continue to wonder if maybe this-and-that DO_NOT_STRIP option >can actually be stripped in some cases. > >IOW: if you really want what you said, make the flags more specific (to >debug info purposes). But then of course it's unclear why you wouldn't >want still other flags to mean "strip-for-something-else" purposes. At >which point you quickly come to the conclusion that one wants to specify >some sort of type per section, and not lump everything under SHT_PROGBITS. > >So, I think two flag bits are not the right solution. Maybe we could use >some bits of sh_type to specify a more detailed type: the low bits would >just be set to the ELF SHT_xxx as appropriate, and higher bits would >contain a detailed type: > > 0x60XXYYZZ > >(ZZ would be the old SHT_xxx type, and XX/YY be a detail type). > > >Ciao, >Michael. Agree that the different purposes can be difficult to capture with just one or two bits. As a concrete example, llvm-strip/llvm-objcopy has this piece of logic for various --strip-* modes: --strip-dwo, --strip-debug, --strip-sections, --strip-all-gnu, --strip-all https://github.com/llvm/llvm-project/blob/c997fe658655b42237f556c11c7f5bc8ec60658b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp#L380-L446 --strip-all-gnu exists because it is determined GNU strip's default --strip-all doesn't strip all :( https://github.com/llvm/llvm-project/commit/6ad72d05f5ebaada700487d3d0fe1d107b32468a I feel that whether .ctf is strippable in various strip modes may be a related question. (I tend to suggest a more intuitive rule instead of doing some magic to ease the adoption of a new section. Let users do --keep-section=xxx for new sections.) >> >> These would be set by the assembler and/or linker to indicate sections >> that should be removed when stripping and sections which must not be >> removed when stripping. It would be an error if both flags were present >> on a given section, and if neither flag is present then the stripping >> tool would fall back on its built in heuristics. >> >> In addition we need new flags for the assembler's .section directive >> (suggestion: 'D': can be stripped, 'K' do not strip). >> This email is to ask if you think that this idea has merit, and if so, >> are there any guidelines for writing and submitting a formal specification >> ? >> >> Cheers >> Nick >>