diff options
author | Alan Modra <amodra@gmail.com> | 2015-12-09 10:18:30 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2015-12-09 10:36:43 +1030 |
commit | 91a65d2fe88fabe2d553a0362b2f76034f820175 (patch) | |
tree | afa6f7c0717f26c9cd56038d3c42eeacbcbc7002 /gold/sparc.cc | |
parent | b7a5f21d4f98e006ac98df0c3494a6b8380917bd (diff) | |
download | gdb-91a65d2fe88fabe2d553a0362b2f76034f820175.zip gdb-91a65d2fe88fabe2d553a0362b2f76034f820175.tar.gz gdb-91a65d2fe88fabe2d553a0362b2f76034f820175.tar.bz2 |
[GOLD] Relocate::relocate() params
Some linker code editing needs to change multiple insns. In some
cases multiple relocations are involved and it is not sufficient to
make the changes independently as relocations are processed, because
doing so might lead to a partial edit. So in order to safely edit we
need all the relocations available in relocate(). Also, to emit
edited relocs corresponding to the edited code sequence we need some
way to pass information from relocate() to relocate_relocs(),
particularly if the edit depends on insns. We can't modify input
relocs in relocate() as they are mmapped PROT_READ, nor it is
particularly clean to write relocs to the output at that stage. So
add a Relocatable_relocs* field to relinfo to mark edited relocs.
Given that relocate is passed the raw reloc pointer, it makes sense to
remove the rel/rela parameter and r_type too. However, that means the
mips relocate() needs to know whether SHT_REL or SHT_RELA relocs are
being processed. So add a rel_type for mips, which also has the
benefit of removing relocate() overloading there.
This patch adds the infrastructure without making use of it.
Note that relinfo->rr will be NULL if not outputting relocations.
* object.h (struct Relocate_info): Add "rr".
* reloc.h (Relocatable_relocs::set_strategy): New accessor.
* reloc.cc (Sized_relobj_file::do_relocate_sections): Init
relinfo.rr for relocate_section and relocate_relocs.
* powerpc.cc (relocate): Add rel_type and preloc parameters.
Delete rela and r_type params, instead recalculate these from
preloc.
(relocate_relocs): Delete Relocatable_relocs* param, instead
use relinfo->rr.
* aarch64.cc: Likewise.
* arm.cc: Likewise.
* i386.cc: Likewise.
* mips.cc: Likewise.
* s390.cc: Likewise.
* sparc.cc: Likewise.
* target.h: Likewise.
* tilegx.cc: Likewise.
* x86_64.cc: Likewise.
* testsuite/testfile.cc: Likewise.
* target-reloc.h (relocate_section): Adjust to suit.
(apply_relocation, relocate_relocs): Likewise.
Diffstat (limited to 'gold/sparc.cc')
-rw-r--r-- | gold/sparc.cc | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/gold/sparc.cc b/gold/sparc.cc index 2b11550..27ea552 100644 --- a/gold/sparc.cc +++ b/gold/sparc.cc @@ -140,7 +140,6 @@ class Target_sparc : public Sized_target<size, big_endian> Output_section* output_section, typename elfcpp::Elf_types<size>::Elf_Off offset_in_output_section, - const Relocatable_relocs*, unsigned char* view, typename elfcpp::Elf_types<size>::Elf_Addr view_address, section_size_type view_size, @@ -316,13 +315,10 @@ class Target_sparc : public Sized_target<size, big_endian> // Do a relocation. Return false if the caller should not issue // any warnings about this relocation. inline bool - relocate(const Relocate_info<size, big_endian>*, Target_sparc*, - Output_section*, size_t relnum, - const elfcpp::Rela<size, big_endian>&, - unsigned int r_type, const Sized_symbol<size>*, - const Symbol_value<size>*, - unsigned char*, - typename elfcpp::Elf_types<size>::Elf_Addr, + relocate(const Relocate_info<size, big_endian>*, unsigned int, + Target_sparc*, Output_section*, size_t, const unsigned char*, + const Sized_symbol<size>*, const Symbol_value<size>*, + unsigned char*, typename elfcpp::Elf_types<size>::Elf_Addr, section_size_type); private: @@ -3169,17 +3165,19 @@ template<int size, bool big_endian> inline bool Target_sparc<size, big_endian>::Relocate::relocate( const Relocate_info<size, big_endian>* relinfo, + unsigned int, Target_sparc* target, Output_section*, size_t relnum, - const elfcpp::Rela<size, big_endian>& rela, - unsigned int r_type, + const unsigned char* preloc, const Sized_symbol<size>* gsym, const Symbol_value<size>* psymval, unsigned char* view, typename elfcpp::Elf_types<size>::Elf_Addr address, section_size_type view_size) { + const elfcpp::Rela<size, big_endian> rela(preloc); + unsigned int r_type = elfcpp::elf_r_type<size>(rela.get_r_info()); bool orig_is_ifunc = psymval->is_ifunc_symbol(); r_type &= 0xff; @@ -4224,7 +4222,6 @@ Target_sparc<size, big_endian>::relocate_relocs( size_t reloc_count, Output_section* output_section, typename elfcpp::Elf_types<size>::Elf_Off offset_in_output_section, - const Relocatable_relocs* rr, unsigned char* view, typename elfcpp::Elf_types<size>::Elf_Addr view_address, section_size_type view_size, @@ -4239,7 +4236,6 @@ Target_sparc<size, big_endian>::relocate_relocs( reloc_count, output_section, offset_in_output_section, - rr, view, view_address, view_size, |