Recently I've added a new LTO section that is emitted by GCC: .gnu.lto_.lto.*. Purpose of the section is to provide meta information about a LTO object. One of the information is about slim or fat LTO object. For the future, I would like to remote emission of __gnu_lto_slim in the GCC compiler. I know it's an 'ABI' break and we still want to support a new GCC with an older binutils. However, I would like to teach binutils about the new LTO section soon.
Created attachment 11883 [details] Patch candidate I would appreciate feedback about the patch before I'll send it to the mailing list.
+/* This a copy of lto_section defined in GCC (lto-streamer.h). */ + +struct lto_section +{ + int16_t major_version; + int16_t minor_version; + unsigned char slim_object: 1; + unsigned int compression: 4; + int32_t reserved0: 27; +}; + The layout of this struct depends on the host compiler. Won't that cause problems in object file portability?
> > The layout of this struct depends on the host compiler. Won't that cause > problems in object file portability? You are right, I will change streaming of the structure to be always LE in a ELF file. I'll then send patches to binutils mailing list.
The master branch has been updated by Martin Liska <marxin@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cc5277b173701364c10204f316db28198f2c683b commit cc5277b173701364c10204f316db28198f2c683b Author: Martin Liska <mliska@suse.cz> Date: Thu Jul 4 16:39:08 2019 +0200 Support .gnu.lto_.lto section in ELF files (PR 24768). bfd/ChangeLog: 2019-07-22 Martin Liska <mliska@suse.cz> PR 24768 * archive.c (_bfd_compute_and_write_armap): Come up with report_plugin_err variable. * bfd-in2.h (struct bfd): Add lto_slim_object flag. * elf.c (struct lto_section): New. (_bfd_elf_make_section_from_shdr): Parse content of .gnu_lto_.lto section. * elflink.c: Report error for a missing LTO plugin. * linker.c (_bfd_generic_link_add_one_symbol): Likewise. binutils/ChangeLog: 2019-07-22 Martin Liska <mliska@suse.cz> PR 24768 * nm.c (filter_symbols): Set report_plugin_err if error is reported. (display_rel_file): Report error for a missing LTO plugin. gold/ChangeLog: 2019-07-22 Martin Liska <mliska@suse.cz> PR 24768 * layout.h (class Layout): Add is_lto_slim_object and set_lto_slim_object. * object.cc (struct lto_section): Add lto_slim_object_. (big_endian>::do_layout): Parse content of .gnu_lto_.lto section. (big_endian>::do_add_symbols): Report error for a missing LTO plugin.
Should be implemented now. Let's keep this issue to remove later the usage of __gnu_lto_slim.
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=34d5c40a07be4bc195d5ed9aecf4eb2faa1482bc commit 34d5c40a07be4bc195d5ed9aecf4eb2faa1482bc Author: Alan Modra <amodra@gmail.com> Date: Tue Jul 30 13:14:36 2019 +0930 Re: Support .gnu.lto_.lto section in ELF files PR 24768 * bfd.c (struct bfd): Add lto_slim_object flag. * bfd-in2.h: Regenerate.
The master branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4c51dacacf8a97194a1241ad5e1cbf7be00a59a3 commit 4c51dacacf8a97194a1241ad5e1cbf7be00a59a3 Author: Alan Modra <amodra@gmail.com> Date: Fri Sep 20 14:52:54 2019 +0930 [GOLD] Fix spurious "plugin needed to handle lto object" warnings lto_slim_object_ was unitialized. I also thought it worth adding a sanity check on the .gnu.lto_.lto.* section size, and made some other tidies. PR 24768 * layout.cc (Layout::Layout): Init lto_slim_object_. * object.cc (Sized_relobj_file::do_layout): Wrap overlong line. Don't use C cast. Validate section size. Don't copy contents.
The binutils-2_33-branch branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0a9fdbbfd319c09e48ac176fd6386b445534cf42 commit 0a9fdbbfd319c09e48ac176fd6386b445534cf42 Author: Alan Modra <amodra@gmail.com> Date: Fri Sep 20 14:52:54 2019 +0930 [GOLD] Fix spurious "plugin needed to handle lto object" warnings lto_slim_object_ was unitialized. I also thought it worth adding a sanity check on the .gnu.lto_.lto.* section size, and made some other tidies. PR 24768 * layout.cc (Layout::Layout): Init lto_slim_object_. * object.cc (Sized_relobj_file::do_layout): Wrap overlong line. Don't use C cast. Validate section size. Don't copy contents. (cherry picked from commit 4c51dacacf8a97194a1241ad5e1cbf7be00a59a3)
(In reply to Martin Liška from comment #5) > Should be implemented now. Let's keep this issue to remove later the usage > of __gnu_lto_slim. I don't think we should remove the __gnu_lto_slim tests in the linker or binutils, unless we get to a point where we need to kill support for older gcc versions in binutils for other reasons.