diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2014-05-27 12:19:33 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2014-05-27 12:20:18 -0700 |
commit | c23dd3426c75fbf7fa9f30a4082be034818967c1 (patch) | |
tree | de616456e981ae0480f27a2c86fe71e03d177edc /gold/x86_64.cc | |
parent | add6c04d828e0f68ded81cfeec0fe74ca0107881 (diff) | |
download | gdb-c23dd3426c75fbf7fa9f30a4082be034818967c1.zip gdb-c23dd3426c75fbf7fa9f30a4082be034818967c1.tar.gz gdb-c23dd3426c75fbf7fa9f30a4082be034818967c1.tar.bz2 |
Properly handle 64-bit GOT relocations
This patch fixes 2 issues:
1. Since the GOT offset is always negative, we need to use signed int
to support 64-bit GOT relocations.
2. R_X86_64_PLTOFF64 uses the address of GLOBAL_OFFSET_TABLE, which is
the address of the .got.plt section, not the .got section.
Diffstat (limited to 'gold/x86_64.cc')
-rw-r--r-- | gold/x86_64.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gold/x86_64.cc b/gold/x86_64.cc index 479fb42..f58c843 100644 --- a/gold/x86_64.cc +++ b/gold/x86_64.cc @@ -3327,7 +3327,9 @@ Target_x86_64<size>::Relocate::relocate( // We need to subtract the size of the GOT section to get // the actual offset to use in the relocation. bool have_got_offset = false; - unsigned int got_offset = 0; + // Since the actual offset is always negative, we use signed int to + // support 64-bit GOT relocations. + int got_offset = 0; switch (r_type) { case elfcpp::R_X86_64_GOT32: @@ -3430,7 +3432,8 @@ Target_x86_64<size>::Relocate::relocate( gold_assert(gsym->has_plt_offset() || gsym->final_value_is_known()); typename elfcpp::Elf_types<size>::Elf_Addr got_address; - got_address = target->got_section(NULL, NULL)->address(); + // This is the address of GLOBAL_OFFSET_TABLE. + got_address = target->got_plt_section()->address(); Relocate_functions<size, false>::rela64(view, object, psymval, addend - got_address); } |