Index: third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.cpp |
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.cpp |
index 5f9252e3c5b9a82e1885d73591c6b05a42a71afc..a5e53feaee80d6e2ea91bb9fcdb3186d9e2da07a 100644 |
--- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.cpp |
+++ b/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.cpp |
@@ -66,6 +66,17 @@ |
#endif // __i386__ |
+#ifdef __x86_64__ |
+ |
+/* x86_64 relocations */ |
+#define R_X86_64_64 1 |
+#define R_X86_64_PC32 2 |
+#define R_X86_64_GLOB_DAT 6 |
+#define R_X86_64_JMP_SLOT 7 |
+#define R_X86_64_RELATIVE 8 |
+ |
+#endif // __x86_64__ |
+ |
namespace crazy { |
namespace { |
@@ -122,6 +133,19 @@ RelocationType GetRelocationType(ELF::Word r_type) { |
return RELOCATION_TYPE_PC_RELATIVE; |
#endif |
+#ifdef __x86_64__ |
+ case R_X86_64_JMP_SLOT: |
+ case R_X86_64_GLOB_DAT: |
+ case R_X86_64_64: |
+ return RELOCATION_TYPE_ABSOLUTE; |
+ |
+ case R_X86_64_RELATIVE: |
+ return RELOCATION_TYPE_RELATIVE; |
+ |
+ case R_X86_64_PC32: |
+ return RELOCATION_TYPE_PC_RELATIVE; |
+#endif |
+ |
#ifdef __mips__ |
case R_MIPS_REL32: |
return RELOCATION_TYPE_RELATIVE; |
@@ -473,6 +497,32 @@ bool ElfRelocations::ApplyRelaReloc(const ELF::Rela* rela, |
return false; |
#endif // __aarch64__ |
+#ifdef __x86_64__ |
+ case R_X86_64_JMP_SLOT: |
+ *target = sym_addr + addend; |
+ break; |
+ |
+ case R_X86_64_GLOB_DAT: |
+ *target = sym_addr + addend; |
+ break; |
+ |
+ case R_X86_64_RELATIVE: |
+ if (rela_symbol) { |
+ *error = "Invalid relative relocation with symbol"; |
+ return false; |
+ } |
+ *target = load_bias_ + addend; |
+ break; |
+ |
+ case R_X86_64_64: |
+ *target = sym_addr + addend; |
+ break; |
+ |
+ case R_X86_64_PC32: |
+ *target = sym_addr + (addend - reloc); |
+ break; |
+#endif // __x86_64__ |
+ |
default: |
error->Format("Invalid relocation type (%d)", rela_type); |
return false; |
@@ -815,6 +865,12 @@ void ElfRelocations::AdjustRelocation(ELF::Word rel_type, |
break; |
#endif |
+#ifdef __x86_64__ |
+ case R_X86_64_RELATIVE: |
+ *dst_ptr += map_delta; |
+ break; |
+#endif |
+ |
#ifdef __mips__ |
case R_MIPS_REL32: |
*dst_ptr += map_delta; |