Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(598)

Unified Diff: third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.cpp

Issue 346583004: crazy_linker: Add support for x86_64. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to master Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
« no previous file with comments | « third_party/android_crazy_linker/README.chromium ('k') | third_party/android_crazy_linker/src/src/elf_traits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698