aboutsummaryrefslogtreecommitdiff
path: root/gold/object.h
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.h
parent43f3e2ee9482fd01e24eea4fed81856518ec2329 (diff)
downloadgdb-7223e9ca5a5ab5eecd2d14328ceade93bcb43f3d.zip
gdb-7223e9ca5a5ab5eecd2d14328ceade93bcb43f3d.tar.gz
gdb-7223e9ca5a5ab5eecd2d14328ceade93bcb43f3d.tar.bz2
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.h')
-rw-r--r--gold/object.h51
1 files changed, 34 insertions, 17 deletions
diff --git a/gold/object.h b/gold/object.h
index 94ad643..3412aec 100644
--- a/gold/object.h
+++ b/gold/object.h
@@ -39,6 +39,7 @@ class General_options;
class Task;
class Cref;
class Layout;
+class Output_data;
class Output_section;
class Output_file;
class Output_symtab_xindex;
@@ -1151,7 +1152,7 @@ class Symbol_value
Symbol_value()
: output_symtab_index_(0), output_dynsym_index_(-1U), input_shndx_(0),
is_ordinary_shndx_(false), is_section_symbol_(false),
- is_tls_symbol_(false), has_output_value_(true)
+ is_tls_symbol_(false), is_ifunc_symbol_(false), has_output_value_(true)
{ this->u_.value = 0; }
// Get the value of this symbol. OBJECT is the object in which this
@@ -1364,11 +1365,21 @@ class Symbol_value
set_is_tls_symbol()
{ this->is_tls_symbol_ = true; }
- // Return TRUE if this is a TLS symbol.
+ // Return true if this is a TLS symbol.
bool
is_tls_symbol() const
{ return this->is_tls_symbol_; }
+ // Record that this is an IFUNC symbol.
+ void
+ set_is_ifunc_symbol()
+ { this->is_ifunc_symbol_ = true; }
+
+ // Return true if this is an IFUNC symbol.
+ bool
+ is_ifunc_symbol() const
+ { return this->is_ifunc_symbol_; }
+
private:
// The index of this local symbol in the output symbol table. This
// will be 0 if no value has been assigned yet, and the symbol may
@@ -1381,7 +1392,7 @@ class Symbol_value
unsigned int output_dynsym_index_;
// The section index in the input file in which this symbol is
// defined.
- unsigned int input_shndx_ : 28;
+ unsigned int input_shndx_ : 27;
// Whether the section index is an ordinary index, not a special
// value.
bool is_ordinary_shndx_ : 1;
@@ -1389,6 +1400,8 @@ class Symbol_value
bool is_section_symbol_ : 1;
// Whether this is a STT_TLS symbol.
bool is_tls_symbol_ : 1;
+ // Whether this is a STT_GNU_IFUNC symbol.
+ bool is_ifunc_symbol_ : 1;
// Whether this symbol has a value for the output file. This is
// normally set to true during Layout::finalize, by
// finalize_local_symbols. It will be false for a section symbol in
@@ -1692,6 +1705,19 @@ class Sized_relobj : public Relobj
return p->second;
}
+ // Return whether the local symbol SYMNDX has a PLT offset.
+ bool
+ local_has_plt_offset(unsigned int symndx) const;
+
+ // Return the PLT offset for a local symbol. It is an error to call
+ // this if it doesn't have one.
+ unsigned int
+ local_plt_offset(unsigned int symndx) const;
+
+ // Set the PLT offset of the local symbol SYMNDX.
+ void
+ set_local_plt_offset(unsigned int symndx, unsigned int plt_offset);
+
// Get the offset of input section SHNDX within its output section.
// This is -1 if the input section requires a special mapping, such
// as a merge section. The output section can be found in the
@@ -2108,6 +2134,7 @@ class Sized_relobj : public Relobj
{
this->local_values_.clear();
this->local_got_offsets_.clear();
+ this->local_plt_offsets_.clear();
}
// Record a mapping from discarded section SHNDX to the corresponding
@@ -2139,20 +2166,8 @@ class Sized_relobj : public Relobj
// for tp-relative offsets for TLS symbols.
typedef Unordered_map<unsigned int, Got_offset_list*> Local_got_offsets;
- // The TLS GOT offsets of local symbols. The map stores the offsets
- // for either a single GOT entry that holds the module index of a TLS
- // symbol, or a pair of GOT entries containing the module index and
- // dtv-relative offset.
- struct Tls_got_entry
- {
- Tls_got_entry(int got_offset, bool have_pair)
- : got_offset_(got_offset),
- have_pair_(have_pair)
- { }
- int got_offset_;
- bool have_pair_;
- };
- typedef Unordered_map<unsigned int, Tls_got_entry> Local_tls_got_offsets;
+ // The PLT offsets of local symbols.
+ typedef Unordered_map<unsigned int, unsigned int> Local_plt_offsets;
// Saved information for sections whose layout was deferred.
struct Deferred_layout
@@ -2197,6 +2212,8 @@ class Sized_relobj : public Relobj
// GOT offsets for local non-TLS symbols, and tp-relative offsets
// for TLS symbols, indexed by symbol number.
Local_got_offsets local_got_offsets_;
+ // PLT offsets for local symbols.
+ Local_plt_offsets local_plt_offsets_;
// For each input section, the offset of the input section in its
// output section. This is INVALID_ADDRESS if the input section requires a
// special mapping.