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

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

Issue 1072533002: crazy linker: convert relocation unpacking to Android style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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.h
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.h b/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.h
index 71ed33b1a60ba2be1eb5fb5a6c0d5e1818862285..e9481bd0e882a0cc7210d290272b2bbb6a010eef 100644
--- a/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.h
+++ b/third_party/android_crazy_linker/src/src/crazy_linker_elf_relocations.h
@@ -8,6 +8,7 @@
#include <string.h>
#include <unistd.h>
+#include "crazy_linker_leb128.h"
#include "elf_traits.h"
namespace crazy {
@@ -44,12 +45,6 @@ class ElfRelocations {
SymbolResolver* resolver,
Error* error);
-#if defined(__arm__) || defined(__aarch64__)
- // Register packed relocations to apply.
- // |packed_relocs| is a pointer to packed relocations data.
- void RegisterPackedRelocations(uint8_t* packed_relocations);
-#endif
-
// This function is used to adjust relocated addresses in a copy of an
// existing section of an ELF binary. I.e. |src_addr|...|src_addr + size|
// must be inside the mapped ELF binary, this function will first copy its
@@ -70,13 +65,21 @@ class ElfRelocations {
ELF::Addr reloc,
ELF::Addr* sym_addr,
Error* error);
+ bool ApplyResolvedRelaReloc(const ELF::Rela* rela,
+ ELF::Addr sym_addr,
+ bool resolved,
+ Error* error);
+ bool ApplyResolvedRelReloc(const ELF::Rel* rel,
+ ELF::Addr sym_addr,
+ bool resolved,
+ Error* error);
bool ApplyRelaReloc(const ELF::Rela* rela,
- ELF::Addr sym_addr,
- bool resolved,
+ const ElfSymbols* symbols,
+ SymbolResolver* resolver,
Error* error);
bool ApplyRelReloc(const ELF::Rel* rel,
- ELF::Addr sym_addr,
- bool resolved,
+ const ElfSymbols* symbols,
+ SymbolResolver* resolver,
Error* error);
bool ApplyRelaRelocs(const ELF::Rela* relocs,
size_t relocs_count,
@@ -100,17 +103,39 @@ class ElfRelocations {
size_t dst_addr,
size_t map_addr,
size_t size);
-
-#if defined(__arm__) || defined(__aarch64__)
- // Apply packed rel or rela relocations. On error, return false.
- bool ApplyPackedRel(const uint8_t* packed_relocations, Error* error);
- bool ApplyPackedRela(const uint8_t* packed_relocations, Error* error);
-
- // Apply packed relocations.
- // On error, return false and set |error| message. No-op if no packed
- // relocations were registered.
- bool ApplyPackedRelocations(Error* error);
-#endif
+ void RelocateAndroidReloc(const ELF::Rela* relocation,
+ size_t src_addr,
+ size_t dst_addr,
+ size_t map_addr,
+ size_t size);
+
+ // Android packed relocations unpacker. Calls the given handler for
+ // each relocation in the unpacking stream.
+ typedef bool (*RelocationHandler)(ElfRelocations* relocations,
+ const ELF::Rela* relocation,
+ void* opaque);
+ bool ForEachAndroidRelocation(RelocationHandler handler,
+ void* opaque);
+
+ // Apply Android packed relocations.
+ // On error, return false and set |error| message.
+ // The static function is the ForEachAndroidRelocation() handler.
+ bool ApplyAndroidRelocations(const ElfSymbols* symbols,
+ SymbolResolver* resolver,
+ Error* error);
+ static bool ApplyAndroidRelocation(ElfRelocations* relocations,
+ const ELF::Rela* relocation,
+ void* opaque);
+
+ // Relocate Android packed relocations.
+ // The static function is the ForEachAndroidRelocation() handler.
+ void RelocateAndroidRelocations(size_t src_addr,
+ size_t dst_addr,
+ size_t map_addr,
+ size_t size);
+ static bool RelocateAndroidRelocation(ElfRelocations* relocations,
+ const ELF::Rela* relocation,
+ void* opaque);
#if defined(__mips__)
bool RelocateMipsGot(const ElfSymbols* symbols,
@@ -137,9 +162,8 @@ class ElfRelocations {
ELF::Word mips_gotsym_;
#endif
-#if defined(__arm__) || defined(__aarch64__)
- uint8_t* packed_relocations_;
-#endif
+ uint8_t* android_relocations_;
+ size_t android_relocations_size_;
bool has_text_relocations_;
bool has_symbolic_;

Powered by Google App Engine
This is Rietveld 408576698