aboutsummaryrefslogtreecommitdiff
path: root/gold/x86_64.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2011-07-15 15:31:54 +0000
committerIan Lance Taylor <ian@airs.com>2011-07-15 15:31:54 +0000
commit7d1726872032004915cd16e53cc781af2adb2873 (patch)
tree2073f1991cba644c41db0bb9fc44c49284fb3daf /gold/x86_64.cc
parent2b1260ab1758b95f36263c48961bb4a113b0f238 (diff)
downloadgdb-7d1726872032004915cd16e53cc781af2adb2873.zip
gdb-7d1726872032004915cd16e53cc781af2adb2873.tar.gz
gdb-7d1726872032004915cd16e53cc781af2adb2873.tar.bz2
* i386.cc (class Output_data_plt_i386): Add layout_ field.
(Output_data_plt_i386::Output_data_plt_i386): Initialize layout_. (Output_data_plt_i386::do_write): Write address of .dynamic section to first entry in .got.plt section. * x86_64.cc (class Output_data_plt_x86_64): Add layout_ field. (Output_data_plt_x86_64::Output_data_plt_x86_64) [both versions]: Initialize layout_. (Output_data_plt_x86_64::do_write): Write address of .dynamic section to first entry in .got.plt section. * layout.h (Layout::dynamic_section): New function.
Diffstat (limited to 'gold/x86_64.cc')
-rw-r--r--gold/x86_64.cc28
1 files changed, 20 insertions, 8 deletions
diff --git a/gold/x86_64.cc b/gold/x86_64.cc
index 4025527..e6b0021 100644
--- a/gold/x86_64.cc
+++ b/gold/x86_64.cc
@@ -57,9 +57,10 @@ class Output_data_plt_x86_64 : public Output_section_data
Output_data_plt_x86_64(Layout* layout, Output_data_got<64, false>* got,
Output_data_space* got_plt,
Output_data_space* got_irelative)
- : Output_section_data(16), tlsdesc_rel_(NULL), irelative_rel_(NULL),
- got_(got), got_plt_(got_plt), got_irelative_(got_irelative), count_(0),
- irelative_count_(0), tlsdesc_got_offset_(-1U), free_list_()
+ : Output_section_data(16), layout_(layout), tlsdesc_rel_(NULL),
+ irelative_rel_(NULL), got_(got), got_plt_(got_plt),
+ got_irelative_(got_irelative), count_(0), irelative_count_(0),
+ tlsdesc_got_offset_(-1U), free_list_()
{ this->init(layout); }
Output_data_plt_x86_64(Layout* layout, Output_data_got<64, false>* got,
@@ -67,9 +68,9 @@ class Output_data_plt_x86_64 : public Output_section_data
Output_data_space* got_irelative,
unsigned int plt_count)
: Output_section_data((plt_count + 1) * plt_entry_size, 16, false),
- tlsdesc_rel_(NULL), irelative_rel_(NULL), got_(got), got_plt_(got_plt),
- got_irelative_(got_irelative), count_(plt_count), irelative_count_(0),
- tlsdesc_got_offset_(-1U), free_list_()
+ layout_(layout), tlsdesc_rel_(NULL), irelative_rel_(NULL), got_(got),
+ got_plt_(got_plt), got_irelative_(got_irelative), count_(plt_count),
+ irelative_count_(0), tlsdesc_got_offset_(-1U), free_list_()
{
this->init(layout);
@@ -205,6 +206,9 @@ class Output_data_plt_x86_64 : public Output_section_data
void
do_write(Output_file*);
+ // A pointer to the Layout class, so that we can find the .dynamic
+ // section when we write out the GOT PLT section.
+ Layout* layout_;
// The reloc section.
Reloc_section* rel_;
// The TLSDESC relocs, if necessary. These must follow the regular
@@ -1306,8 +1310,16 @@ Output_data_plt_x86_64::do_write(Output_file* of)
unsigned char* got_pov = got_view;
- memset(got_pov, 0, 24);
- got_pov += 24;
+ // The first entry in the GOT is the address of the .dynamic section
+ // aka the PT_DYNAMIC segment. The next two entries are reserved.
+ // We saved space for them when we created the section in
+ // Target_x86_64::got_section.
+ Output_section* dynamic = this->layout_->dynamic_section();
+ uint32_t dynamic_addr = dynamic == NULL ? 0 : dynamic->address();
+ elfcpp::Swap<64, false>::writeval(got_pov, dynamic_addr);
+ got_pov += 8;
+ memset(got_pov, 0, 16);
+ got_pov += 16;
unsigned int plt_offset = plt_entry_size;
unsigned int got_offset = 24;