This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH COMMITTED: Fix x86_64 with large addresses
- From: Ian Lance Taylor <iant at google dot com>
- To: binutils at sourceware dot org
- Date: Fri, 16 May 2008 08:30:22 -0700
- Subject: PATCH COMMITTED: Fix x86_64 with large addresses
There were a couple of bugs in handling binaries built with a base
address larger than 0x100000000. The first was an incorrect use of
section_offset_type which should have been the appropriately-sized
Elf_Addr. The second was an incorrect use of 32-bit types for section
addresses in x86_64.cc. I committed this patch to fix these problems.
Ian
2008-05-16 Ian Lance Taylor <iant@google.com>
* output.cc (Output_reloc::get_address): Change return type to
Elf_Addr.
* output.h (class Output_reloc): Update get_address declaration.
* x86_64.cc (Output_data_plt_x86_64::do_write): Use 64-bit types
for section addresses.
Index: output.cc
===================================================================
RCS file: /cvs/src/src/gold/output.cc,v
retrieving revision 1.75
diff -p -u -r1.75 output.cc
--- output.cc 6 May 2008 05:03:15 -0000 1.75
+++ output.cc 16 May 2008 15:26:54 -0000
@@ -854,7 +854,7 @@ Output_reloc<elfcpp::SHT_REL, dynamic, s
// Get the output address of a relocation.
template<bool dynamic, int size, bool big_endian>
-section_offset_type
+typename elfcpp::Elf_types<size>::Elf_Addr
Output_reloc<elfcpp::SHT_REL, dynamic, size, big_endian>::get_address() const
{
Address address = this->address_;
Index: output.h
===================================================================
RCS file: /cvs/src/src/gold/output.h,v
retrieving revision 1.68
diff -p -u -r1.68 output.h
--- output.h 6 May 2008 05:54:21 -0000 1.68
+++ output.h 16 May 2008 15:26:54 -0000
@@ -878,7 +878,7 @@ class Output_reloc<elfcpp::SHT_REL, dyna
get_symbol_index() const;
// Return the output address.
- section_offset_type
+ Address
get_address() const;
// Codes for local_sym_index_.
Index: x86_64.cc
===================================================================
RCS file: /cvs/src/src/gold/x86_64.cc,v
retrieving revision 1.66
diff -p -u -r1.66 x86_64.cc
--- x86_64.cc 6 May 2008 05:03:15 -0000 1.66
+++ x86_64.cc 16 May 2008 15:26:54 -0000
@@ -672,20 +672,22 @@ Output_data_plt_x86_64::do_write(Output_
unsigned char* pov = oview;
// The base address of the .plt section.
- elfcpp::Elf_types<32>::Elf_Addr plt_address = this->address();
+ elfcpp::Elf_types<64>::Elf_Addr plt_address = this->address();
// The base address of the .got section.
- elfcpp::Elf_types<32>::Elf_Addr got_base = this->got_->address();
+ elfcpp::Elf_types<64>::Elf_Addr got_base = this->got_->address();
// The base address of the PLT portion of the .got section,
// which is where the GOT pointer will point, and where the
// three reserved GOT entries are located.
- elfcpp::Elf_types<32>::Elf_Addr got_address = this->got_plt_->address();
+ elfcpp::Elf_types<64>::Elf_Addr got_address = this->got_plt_->address();
memcpy(pov, first_plt_entry, plt_entry_size);
// We do a jmp relative to the PC at the end of this instruction.
- elfcpp::Swap_unaligned<32, false>::writeval(pov + 2, got_address + 8
- - (plt_address + 6));
- elfcpp::Swap<32, false>::writeval(pov + 8, got_address + 16
- - (plt_address + 12));
+ elfcpp::Swap_unaligned<32, false>::writeval(pov + 2,
+ (got_address + 8
+ - (plt_address + 6)));
+ elfcpp::Swap<32, false>::writeval(pov + 8,
+ (got_address + 16
+ - (plt_address + 12)));
pov += plt_entry_size;
unsigned char* got_pov = got_view;