Bug 24853 - OSABI not set when STT_GNU_IFUNC or STB_GNU_UNIQUE symbols output
Summary: OSABI not set when STT_GNU_IFUNC or STB_GNU_UNIQUE symbols output
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.33
: P2 normal
Target Milestone: 2.34
Assignee: Alan Modra
URL: https://sourceware.org/ml/binutils/20...
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-26 06:42 UTC by Alan Modra
Modified: 2019-11-19 01:37 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Modra 2019-07-26 06:42:38 UTC
STT_GNU_IFUNC and STB_GNU_UNIQUE are both defined in the relevant LOOS to HIOS range.  That means interpretation of symbols with this type or binding is dependent on the value of the header EI_OSABI byte, and that object files using these symbols should not be created having ELFOSABI_NONE.

Since git commit df3a023bd6, readelf has not displayed "IFUNC" for object files with ELFOSABI_NONE, exposing this bug in gold by the failure of ver_test_pr16504.
Comment 1 cvs-commit@gcc.gnu.org 2019-11-18 21:26:37 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=aa465b19c80b660b4d4fe6608fb66ebeb469f38b

commit aa465b19c80b660b4d4fe6608fb66ebeb469f38b
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Oct 2 10:41:01 2019 +0930

    [GOLD] OSABI not set when STT_GNU_IFUNC or STB_GNU_UNIQUE symbols output
    
    This patch arranges to have OSABI set to ELFOSABI_GNU (if not set to
    some other non-zero value) when gold outputs an ifunc local or global
    symbol, or a unique global symbol to either .dynsym or .symtab.
    STT_GNU_IFUNC and STB_GNU_UNIQUE have values in the LOOS to HIOS range
    and therefore require interpretation according to OSABI.
    
    I'm not sure why parameters->target() is const Target& while
    parameters->sized_target() is Sized_target*, but it's inconvenient to
    use the latter in Symbol_table::finalize.  So this patch adds another
    const_cast complained about in layout.cc and gold.cc.
    
    	PR 24853
    	* symtab.h (set_has_gnu_output, has_gnu_output_): New.
    	* symtab.cc (Symbol_table::Symbol_table): Init has_gnu_output_.
    	(Symbol_table::finalize): Set ELFOSABI_GNU when has_gnu_output_.
    	(Symbol_table::set_dynsym_indexes, Symbol_table::sized_finalize):
    	Call set_has_gnu_output for STT_GNU_IFUNC and STB_GNU_UNIQUE globals.
    	* object.cc (Sized_relobj_file::do_finalize_local_symbols): Call
    	set_has_gnu_output when STT_GNU_IFUNC locals will be output.
Comment 2 Alan Modra 2019-11-19 01:37:45 UTC
Fixed.