summaryrefslogtreecommitdiffstats
path: root/gold/object.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2010-08-19 22:50:16 +0000
committerIan Lance Taylor <ian@airs.com>2010-08-19 22:50:16 +0000
commit7223e9ca5a5ab5eecd2d14328ceade93bcb43f3d (patch)
tree81c490fb8d11c59cbbe1d34b4048a471e7fc6def /gold/object.cc
parent43f3e2ee9482fd01e24eea4fed81856518ec2329 (diff)
downloadppe42-binutils-7223e9ca5a5ab5eecd2d14328ceade93bcb43f3d.tar.gz
ppe42-binutils-7223e9ca5a5ab5eecd2d14328ceade93bcb43f3d.zip
PR 10893
* i386.cc (class Output_data_plt_i386): Update declarations. Define Global_ifunc and Local_ifunc types. Add global_ifuncs_ and local_ifuncs_ fields. (Target_i386::do_plt_section_for_global): New function. (Target_i386::do_plt_section_for_local): New function. (Output_data_plt_i386::Output_data_plt_i386): Add symtab parameter; change all callers. Initialize global_ifuncs_ and local_ifuncs_. If doing a static link define __rel_iplt_start and __rel_iplt_end. (Output_data_plt_i386::add_entry): Handle IFUNC symbols. (Output_data_plt_i386::add_local_ifunc_entry): New function. (Output_data_plt_i386::do_write): Fix GOT entries for IFUNC symbols. (Target_i386::make_plt_section): New function, broken out of make_plt_entry. Set sh_info field of .rel.plt to point to .plt. (Target_i386::make_plt_entry): Call make_plt_section. (Target_i386::make_local_ifunc_plt_entry): New function. (Target_i386::Scan::reloc_needs_iplt_for_ifunc): New function. (Target_i386::Scan::local): Handle IFUNC symbols. Add R_386_IRELATIVE to switch. (Target_i386::Scan::global): Likewise. (Target_i386::Relocate::relocate): Likewise. (Target_i386::Relocatable_size_for_reloc): Add R_386_IRELATIVE to switch. * x86_64.cc (class Output_data_plt_x86_64): Update declarations. (Target_x86_64::do_plt_section_for_global): New function. (Target_x86_64::do_plt_section_for_local): New function. (Output_data_plt_x86_64::Output_data_plt_x86_64): Add symtab parameter; change all callers. If doing a static link define __rela_iplt_start and __rela_iplt_end. (Output_data_plt_x86_64::add_entry): Handle IFUNC symbols. (Output_data_plt_x86_64::add_local_ifunc_entry): New function. (Target_x86_64::make_plt_section): Set sh_info field of .rel.plt to point to .plt. (Target_x86_64::make_local_ifunc_plt_entry): New function. (Target_x86_64::Scan::check_non_pic): Add R_X86_64_IRELATIVE to switch. (Target_x86_64::Scan::reloc_needs_iplt_for_ifunc): New function. (Target_x86_64::Scan::local): Handle IFUNC symbols. Add R_X86_64_IRELATIVE to switch. (Target_x86_64::Scan::global): Likewise. (Target_x86_64::Relocate::relocate): Likewise. (Target_x86_64::Relocatable_size_for_reloc): Add R_X86_64_IRELATIVE to switch. * target.h (class Target): Add plt_section_for_global and plt_section_for_local functions. Add do_plt_section_for_global and do_plt_section_for_local virtual functions. * symtab.h (Symbol::needs_plt_entry): Handle IFUNC symbol. Add clarifying comments. (Symbol::use_plt_offset): Handle IFUNC symbol. * object.cc (Sized_relobj::Sized_relobj): Initialize local_plt_offsets_. (Sized_relobj::local_has_plt_offset): New function. (Sized_relobj::local_plt_offset): New function. (Sized_relobj::set_local_plt_offset): New function. (Sized_relobj::do_count): Handle IFUNC symbol. * object.h (class Symbol_value): Add is_ifunc_symbol_ field. Take a bit away from input_shndx_ field. Add set_is_func_symbol and is_ifunc_symbol functions. (class Sized_relobj): Update declarations. Remove Tls_got_entry and Local_tls_got_offsets. Define Local_plt_offsets. Add local_plt_offsets_ field. (Sized_relobj::clear_local_symbols): Clear local_plt_offsets_. * output.h (class Output_section_data): Add non-const output_section function. (class Output_data_got): Update declarations. (class Output_data_got::Got_entry): Add use_plt_offset_ field. Add use_plt_offset parameter to global and local constructors. Change all callers. Change local_sym_index_ field to 31 bits. Change GSYM_CODE and CONSTANT_CODE accordingly. * output.cc (Output_data_reloc_base::do_adjust_output_section): If doing a static link don't set sh_link field. (Output_data_got::Got_entry::write): Use PLT offset if appropriate. (Output_data_got::add_global_plt): New function. (Output_data_got::add_local_plt): New function. * target-reloc.h (relocate_section): Handle IFUNC symbol. * defstd.cc (in_section): Remove entries for __rel_iplt_start, __rel_iplt_end, __rela_iplt_start, and __rela_iplt_end. * configure.ac: Set IFUNC automake conditional for glibc >= 2.11. * testsuite/Makefile.am: Add a bunch of IFUNC tests, all within IFUNC conditional. * testsuite/ifunc-sel.h: New file. * testsuite/ifuncmain1.c: New file. * testsuite/ifuncmain1vis.c: New file. * testsuite/ifuncmod1.c: New file. * testsuite/ifuncdep2.c: New file. * testsuite/ifuncmain2.c: New file. * testsuite/ifuncmain3.c: New file. * testsuite/ifuncmod3.c: New file. * testsuite/ifuncmain4.c: New file. * testsuite/ifuncmain5.c: New file. * testsuite/ifuncmod5.c: New file. * testsuite/ifuncmain6pie.c: New file. * testsuite/ifuncmod6.c: New file. * testsuite/ifuncmain7.c: New file. * configure, testsuite/Makefile.in: Rebuild.
Diffstat (limited to 'gold/object.cc')
-rw-r--r--gold/object.cc39
1 files changed, 38 insertions, 1 deletions
diff --git a/gold/object.cc b/gold/object.cc
index b3d987056c..5250fa3c2c 100644
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -391,6 +391,7 @@ Sized_relobj<size, big_endian>::Sized_relobj(
local_dynsym_offset_(0),
local_values_(),
local_got_offsets_(),
+ local_plt_offsets_(),
kept_comdat_sections_(),
has_eh_frame_(false),
discarded_eh_frame_shndx_(-1U),
@@ -1690,6 +1691,41 @@ Sized_relobj<size, big_endian>::do_should_include_member(Symbol_table* symtab,
return Archive::SHOULD_INCLUDE_UNKNOWN;
}
+// Return whether the local symbol SYMNDX has a PLT offset.
+
+template<int size, bool big_endian>
+bool
+Sized_relobj<size, big_endian>::local_has_plt_offset(unsigned int symndx) const
+{
+ typename Local_plt_offsets::const_iterator p =
+ this->local_plt_offsets_.find(symndx);
+ return p != this->local_plt_offsets_.end();
+}
+
+// Get the PLT offset of a local symbol.
+
+template<int size, bool big_endian>
+unsigned int
+Sized_relobj<size, big_endian>::local_plt_offset(unsigned int symndx) const
+{
+ typename Local_plt_offsets::const_iterator p =
+ this->local_plt_offsets_.find(symndx);
+ gold_assert(p != this->local_plt_offsets_.end());
+ return p->second;
+}
+
+// Set the PLT offset of a local symbol.
+
+template<int size, bool big_endian>
+void
+Sized_relobj<size, big_endian>::set_local_plt_offset(unsigned int symndx,
+ unsigned int plt_offset)
+{
+ std::pair<typename Local_plt_offsets::iterator, bool> ins =
+ this->local_plt_offsets_.insert(std::make_pair(symndx, plt_offset));
+ gold_assert(ins.second);
+}
+
// First pass over the local symbols. Here we add their names to
// *POOL and *DYNPOOL, and we store the symbol value in
// THIS->LOCAL_VALUES_. This function is always called from a
@@ -1756,6 +1792,8 @@ Sized_relobj<size, big_endian>::do_count_local_symbols(Stringpool* pool,
lv.set_is_section_symbol();
else if (sym.get_st_type() == elfcpp::STT_TLS)
lv.set_is_tls_symbol();
+ else if (sym.get_st_type() == elfcpp::STT_GNU_IFUNC)
+ lv.set_is_ifunc_symbol();
// Save the input symbol value for use in do_finalize_local_symbols().
lv.set_input_value(sym.get_st_value());
@@ -2065,7 +2103,6 @@ Sized_relobj<size, big_endian>::do_section_entsize(unsigned int shndx)
return shdr.get_sh_entsize();
}
-
// Write out the local symbols.
template<int size, bool big_endian>
OpenPOWER on IntegriCloud