From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by server2.sourceware.org (Postfix) with ESMTPS id E2111394B008 for ; Sun, 8 Mar 2020 18:07:09 +0000 (GMT) Received: by mail-oi1-x243.google.com with SMTP id q81so7952848oig.0 for ; Sun, 08 Mar 2020 11:07:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pqihJYFPbai3rgPcPLMCaLn8tMV3G1G+ndlSBcmhYUA=; b=ZTWrr274ZttqN8c5O7Rwk7d3GV9WfhfRO73x0XRUNhSp4dA8ztNoml4A7hhTcMqWdo IZ7ypgCdTX2zl8pkuclKvfpFHLtQlyQo+aVWX9HVxZEuKzd14HMqSbWSxSr7JmyCe0v+ WVVf11y4CijoWikYEABbMIImHEYfEZPQRlGPVlfoaxvysihmJzMm9mQ2JGR7RRSl8gYP zd1bHE7Rv8dRSShlSpQgqVYtoy+FQj3IuSwtycIhX+KmdCnV7i0oN1ZNpliiD/cO8jmC NWCXxQKZ69HPFabbbu/vFMzRsvs9vnvx31xR4cODLmDNyx1zfdsoJBX1g3E3Si3izqaD ao5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pqihJYFPbai3rgPcPLMCaLn8tMV3G1G+ndlSBcmhYUA=; b=lnsEMmypw722HoGvGMKVY5aY7TdPelMibWJjcfJQrBfI41nq/M+IZxRGCwTd8IGQYF jwril7y62G5yq4YN+a0HJC4FFOFlAldA3xQ+jBS6KEwjvSHlKWGKU8myKMlRUIatDCTN iWTbzV8Nl7xMawY2OR/kPD7QspeyH7uEZPfQh87Vz8bjx3aLxymgeu5+VrlG1F075jBF YDidZ5zarSIp4bqpspGVVbb+j52S9oArXVz9o4zrpgEyq2+e5TgB+/LbKockopHiIOpR tYZCMXCFak5FeZmx9iwcY5gs2hekNzRKJofves7zWP5C7aw4a/PGL6z3NMxjMmnYn9CL L2yw== X-Gm-Message-State: ANhLgQ06xNzlGaKpywLINQwrZgkD7jaVbahlgIU1Kp11KL+bpT8UAsCv pvuBbuLPGYe40Ld/+RWtbyzvcsXhG40YUYKwxGugu7KH X-Google-Smtp-Source: ADFU+vtl6KUuRXlVn4WFSNqSgdf8beaR3iqJs5zRRCKuNtGjcBde4f4pEjWZ/ahXqjc0RQE/g684+7UvSMv82whnv/s= X-Received: by 2002:a05:6808:64d:: with SMTP id z13mr9267695oih.104.1583690829080; Sun, 08 Mar 2020 11:07:09 -0700 (PDT) MIME-Version: 1.0 References: <20200308175947.GA911529@gmail.com> In-Reply-To: <20200308175947.GA911529@gmail.com> From: "H.J. Lu" Date: Sun, 8 Mar 2020 11:06:33 -0700 Message-ID: Subject: Re: RFC: [PATCH] ELF: Don't require section header on ELF objects To: Binutils Cc: Kaylee Blake Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_1, GIT_PATCH_2, 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: Sun, 08 Mar 2020 18:07:11 -0000 On Sun, Mar 8, 2020 at 10:59 AM H.J. Lu wrote: > > Any comments? > > Kaylee, do you have copyright paper with FSF? > > H.J. > --- > 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, adds > an objcopy and strip option, --remove-section-header, to remove ELF > section header from an executable or shared library. > > The PT_DYNAMIC segment contains DT_HASH/DT_GNU_HASH/DT_MIPS_XHASH, > DT_STRTAB, DT_SYMTAB, DT_STRSZ and DT_SYMENT, which can be used to > reconstruct dynamic symbol table when section header isn't available. > For DT_HASH, the number of dynamic symbol table entries equals the > number of chains. For DT_GNU_HASH/DT_MIPS_XHASH, only defined symbols > with non-STB_LOCAL indings are in hash table. Since in dynamic symbol > table, all symbols with STB_LOCAL binding are placed before symbols with > other bindings and all defined symbols are placed before undefined ones, It should read --- all symbols with STB_LOCAL binding are placed before symbols with other bindings and all undefined symbols are placed before defined ones, --- The complete patch set is on users/hjl/pr25617/master branch at https://gitlab.com/x86-binutils/binutils-gdb > the highest symbol index in DT_GNU_HASH/DT_MIPS_XHASH is the highest > dynamic symbol table index. > > 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. > -- H.J.