Bug 24768 - Stop using __gnu_lto_slim symbol as a detection of a slim LTO object
Summary: Stop using __gnu_lto_slim symbol as a detection of a slim LTO object
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-04 14:42 UTC by Martin Liška
Modified: 2024-02-27 23:04 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Patch candidate (3.30 KB, patch)
2019-07-04 14:45 UTC, Martin Liška
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2019-07-04 14:42:58 UTC
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.
Comment 1 Martin Liška 2019-07-04 14:45:41 UTC
Created attachment 11883 [details]
Patch candidate

I would appreciate feedback about the patch before I'll send it to the mailing list.
Comment 2 Alan Modra 2019-07-13 08:05:41 UTC
+/* 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?
Comment 3 Martin Liška 2019-07-15 07:03:47 UTC
> 
> 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.
Comment 4 Sourceware Commits 2019-07-29 08:14:03 UTC
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.
Comment 5 Martin Liška 2019-07-29 08:17:32 UTC
Should be implemented now. Let's keep this issue to remove later the usage of __gnu_lto_slim.
Comment 6 Sourceware Commits 2019-07-30 03:49:01 UTC
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.
Comment 7 Sourceware Commits 2019-09-20 07:36:09 UTC
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.
Comment 8 Sourceware Commits 2019-09-20 08:37:15 UTC
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)
Comment 9 Alan Modra 2024-02-27 23:04:31 UTC
(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.