diff options
author | Doug Kwan <dougkwan@google.com> | 2011-11-10 00:41:53 +0000 |
---|---|---|
committer | Doug Kwan <dougkwan@google.com> | 2011-11-10 00:41:53 +0000 |
commit | 2c339f710d5c9dfa791386e1982c20cb09a334ad (patch) | |
tree | 5d0edca5ee677c244ecbdac42c64f540ea305d90 /gold/reloc.h | |
parent | eac29d46b776d0ac11961376f49c207f34eb5ebd (diff) | |
download | binutils-2c339f710d5c9dfa791386e1982c20cb09a334ad.zip binutils-2c339f710d5c9dfa791386e1982c20cb09a334ad.tar.gz binutils-2c339f710d5c9dfa791386e1982c20cb09a334ad.tar.bz2 |
2011-11-09 Doug Kwan <dougkwan@google.com>
PR gold/13362
* arm.cc (Arm_scan_relocatable_relocs::Default_scan_relocatable_relocs):
Use unaligned 4-byte relocs for static 32-bit data as required by EABI.
* reloc.h (Relocatable_relocs::Reloc_strategy): New enum
RELOC_ADJUST_FOR_SECTION_4_UNALIGNED.
(Relocate_functions::rel_unaligned): New.
(Relocate_functions::rel32_unaligned): New.
* target-reloc.h (relocate_for_relocatable): Add code to handle
RELOC_ADJUST_FOR_SECTION_4_UNALIGNED.
* testsuite/Makefile.am (arm_unaligned_reloc_r.stdout,
arm_unaligned_reloc_r): New targets.
* testsuite/Makefile.in: Regenerate.
* arm_unaligned_reloc.sh: Check unaligned relocs in relocatable
linking.
Diffstat (limited to 'gold/reloc.h')
-rw-r--r-- | gold/reloc.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/gold/reloc.h b/gold/reloc.h index 3a33c9b..fefcb3f 100644 --- a/gold/reloc.h +++ b/gold/reloc.h @@ -247,6 +247,8 @@ class Relocatable_relocs RELOC_ADJUST_FOR_SECTION_2, RELOC_ADJUST_FOR_SECTION_4, RELOC_ADJUST_FOR_SECTION_8, + // Like RELOC_ADJUST_FOR_SECTION_4 but for unaligned relocs. + RELOC_ADJUST_FOR_SECTION_4_UNALIGNED, // Discard the input reloc--process it completely when relocating // the data section contents. RELOC_DISCARD, @@ -347,6 +349,20 @@ private: elfcpp::Swap<valsize, big_endian>::writeval(wv, x); } + // Like the above but for relocs at unaligned addresses. + template<int valsize> + static inline void + rel_unaligned(unsigned char* view, + const Sized_relobj_file<size, big_endian>* object, + const Symbol_value<size>* psymval) + { + typedef typename elfcpp::Swap_unaligned<valsize, big_endian>::Valtype + Valtype; + Valtype x = elfcpp::Swap_unaligned<valsize, big_endian>::readval(view); + x = psymval->value(object, x); + elfcpp::Swap_unaligned<valsize, big_endian>::writeval(view, x); + } + // Do a simple relocation with the addend in the relocation. // VALSIZE is the size of the value. template<int valsize> @@ -558,6 +574,13 @@ public: const Symbol_value<size>* psymval) { This::template rel<32>(view, object, psymval); } + // Like above but for relocs at unaligned addresses. + static inline void + rel32_unaligned(unsigned char* view, + const Sized_relobj_file<size, big_endian>* object, + const Symbol_value<size>* psymval) + { This::template rel_unaligned<32>(view, object, psymval); } + // Do an 32-bit RELA relocation with the addend in the relocation. static inline void rela32(unsigned char* view, elfcpp::Elf_Word value, elfcpp::Elf_Word addend) |