From aa465b19c80b660b4d4fe6608fb66ebeb469f38b Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 2 Oct 2019 10:41:01 +0930 Subject: [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. --- gold/symtab.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gold/symtab.h') diff --git a/gold/symtab.h b/gold/symtab.h index a9e8dd32783..dd931f5f041 100644 --- a/gold/symtab.h +++ b/gold/symtab.h @@ -1580,6 +1580,10 @@ class Symbol_table saw_undefined() const { return this->saw_undefined_; } + void + set_has_gnu_output() + { this->has_gnu_output_ = true; } + // Allocate the common symbols void allocate_commons(Layout*, Mapfile*); @@ -1981,6 +1985,8 @@ class Symbol_table // The number of global dynamic symbols (including forced-local symbols), // or 0 if none. unsigned int dynamic_count_; + // Set if a STT_GNU_IFUNC or STB_GNU_UNIQUE symbol will be output. + bool has_gnu_output_; // The symbol hash table. Symbol_table_type table_; // A pool of symbol names. This is used for all global symbols. -- cgit v1.2.1