From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by sourceware.org (Postfix) with ESMTPS id 41D113875DFD for ; Fri, 20 Mar 2020 07:11:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 41D113875DFD Received: by mail-pg1-x541.google.com with SMTP id t3so2631614pgn.1 for ; Fri, 20 Mar 2020 00:11:37 -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:user-agent; bh=iuyyM1TtvSVGGDik6RLdKKOrBHWcRogs7NCeHpKX0EI=; b=L5ztoiAdI3Jew4oeoo9GQauMHwhGvVQNyd38qA3Ny5aXTaPHoXzaydUuTdK3lBgL+q YVy/QOIVth1fyKFw7QP7PvtUKzrco3SIB5Q+PXKg1chiDCvQiYuXWdrK1CyYqOCq8451 7tn+uebFzFYANo0EAbEO/Vbsu64nK8a27FpdHka/+gIdjGRFkhK93Ik0Mlc3ZR6vV2L+ 81G89kWDn/HdFW67nkV3Tu9/+orOfHBNqFzH79KynaVzPNkbaGg3LCnWy+4aUN9pBXiz qKmgAFAKW5gdWzwx80pnIrheAnMKiECusXQWEbnVF8bojtc5TpUvHzUOWkrN6zlfWscV Oaqw== X-Gm-Message-State: ANhLgQ3axTCtd692lLBmEisG8KT4XNTHl+UAvv+XTqpBQ/zsiNeLgq6M sw7tiqOCmHTRxMTFaR0PYIo= X-Google-Smtp-Source: ADFU+vsNKY+Rix6DPn+M+4JYWOIDM6LcdgEqzwchdLnCODUKLDGqqZpgJ/5ltKv9a3w6X5AZDq8kFg== X-Received: by 2002:a63:f752:: with SMTP id f18mr7240391pgk.196.1584688296394; Fri, 20 Mar 2020 00:11:36 -0700 (PDT) Received: from bubble.grove.modra.org ([2406:3400:51d:8cc0:b503:54a1:9549:bbbb]) by smtp.gmail.com with ESMTPSA id q185sm3938615pfb.154.2020.03.20.00.11.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2020 00:11:35 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 45A5988E4E; Fri, 20 Mar 2020 17:41:31 +1030 (ACDT) Date: Fri, 20 Mar 2020 17:41:31 +1030 From: Alan Modra To: "H.J. Lu" Cc: binutils@sourceware.org, Kaylee Blake Subject: Re: [PATCH 1/7] ELF: Omit section header on ELF objects Message-ID: <20200320071131.GL4583@bubble.grove.modra.org> References: <20200310001224.131714-1-hjl.tools@gmail.com> <20200310001224.131714-3-hjl.tools@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200310001224.131714-3-hjl.tools@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS autolearn=ham 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: Fri, 20 Mar 2020 07:11:39 -0000 On Mon, Mar 09, 2020 at 05:12:18PM -0700, H.J. Lu wrote: > From: Kaylee Blake > > Section header isn't mandatory on ELF executable nor shared library. > This patch adds a new linker option, -z nosectionheader, to omit ELF > section header when building an executable or shared library, an > objcopy and strip option, --remove-section-header, to remove ELF > section header from an executable or shared library. > > bfd/ > > 2020-03-XX H.J. Lu > Kaylee Blake > > PR ld/25617 > * bfd.c (BFD_NO_SECTION_HEADER): New. > (BFD_FLAGS_SAVED): Add BFD_NO_SECTION_HEADER. > (BFD_FLAGS_FOR_BFD_USE_MASK): Likewise. > * elfcode.h (elf_swap_ehdr_out): Omit section header on > non-relocatable output with BFD_NO_SECTION_HEADER. > (elf_write_shdrs_and_ehdr): Likewise. > * elfxx-target.h (TARGET_BIG_SYM): Add BFD_NO_SECTION_HEADER > to object_flags. > (TARGET_LITTLE_SYM): Likewise. > * bfd-in2.h: Regenerated. > > binutils/ > > 2020-03-XX H.J. Lu > > PR ld/25617 > * NEWS: Mention --remove-section-header for objcopy and strip. > * doc/binutils.texi: Document --remove-section-header for objcopy > and strip. > * objcopy.c (remove_section_header): New. > (command_line_switch): Add OPTION_REMOVE_SECTION_HEADER. > (strip_options): Add --remove-section-header. > (copy_options): Likewise. > (copy_usage): Add --remove-section-header. > (strip_usage): Likewise. > (copy_object): Renamed to ... > (copy_object_1): This. Issue a warning for > --remove-section-header on non-ELF targets. > (copy_object): New. > (strip_main): Handle OPTION_REMOVE_SECTION_HEADER. > (copy_main): Likewise. > > ld/ > > 2020-03-XX H.J. Lu > Kaylee Blake > > PR ld/25617 > * NEWS: Mention -z nosectionheader. > * emultempl/elf.em: Support -z sectionheader and > -z nosectionheader. > * ld.h (ld_config_type): Add no_section_header. > * ld.texi: Document -z sectionheader and -z nosectionheader. > * ldlang.c (ldlang_open_output): Handle > config.no_section_header. > * lexsup.c (parse_args): Disallow -z nosectionheader with -r. > (elf_static_list_options): Add -z sectionheader and > -z nosectionheader. This looks mostly OK to me. The only nit I have to pick is the copy_object_1 extraction from copy_object. That seems unnecessary to me since it looks like --remove-section-header on a non-ELF object results in an error and the output file being deleted. So you could do without the new function and just set strip_symbols and merge_notes when decoding the new option. Also, I wouldn't restrict the operation to (EXEC_P | DYNAMIC) objects. Someone might find a reason to use --remove-section-header on a relocatable object. Allow people to shoot themselves in the foot if they so desire.. (Unless supporting --remove-section-header on a relocatable object requires more work.) -- Alan Modra Australia Development Lab, IBM