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

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

Issue 1072533002: crazy linker: convert relocation unpacking to Android style. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates to gn to match gyp. Created 5 years, 6 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
« no previous file with comments | « third_party/android_crazy_linker/src/src/crazy_linker_shared_library.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/android_crazy_linker/src/src/crazy_linker_shared_library.cpp
diff --git a/third_party/android_crazy_linker/src/src/crazy_linker_shared_library.cpp b/third_party/android_crazy_linker/src/src/crazy_linker_shared_library.cpp
index f45824cb9ad1e529f805426b84a17d799ba6e4b7..b982a7d63cf65a9335e0919b59897e34ccfe29a9 100644
--- a/third_party/android_crazy_linker/src/src/crazy_linker_shared_library.cpp
+++ b/third_party/android_crazy_linker/src/src/crazy_linker_shared_library.cpp
@@ -58,18 +58,6 @@
#define DT_PREINIT_ARRAYSZ 33
#endif
-#ifndef DT_LOOS
-#define DT_LOOS 0x6000000d
-#endif
-
-// Extension dynamic tags for packed relocations.
-#if defined(__arm__) || defined(__aarch64__)
-
-#define DT_ANDROID_REL_OFFSET (DT_LOOS)
-#define DT_ANDROID_REL_SIZE (DT_LOOS + 1)
-
-#endif // __arm__ || __aarch64__
-
namespace crazy {
namespace {
@@ -194,57 +182,6 @@ class SharedLibraryResolver : public ElfRelocations::SymbolResolver {
Vector<LibraryView*>* dependencies_;
};
-#if defined(__arm__) || defined(__aarch64__)
-
-// Helper class to provide a simple scoped buffer. ScopedPtr is not
-// usable here because it calls delete, not delete [].
-class ScopedBuffer {
- public:
- explicit ScopedBuffer(size_t bytes) : buffer_(new uint8_t[bytes]) { }
- ~ScopedBuffer() { delete [] buffer_; }
-
- uint8_t* Get() { return buffer_; }
-
- uint8_t* Release() {
- uint8_t* ptr = buffer_;
- buffer_ = NULL;
- return ptr;
- }
-
- private:
- uint8_t* buffer_;
-};
-
-// Read an .android.rel.dyn packed relocations section.
-// Returns an allocated buffer holding the data, or NULL on error.
-uint8_t* ReadPackedRelocations(const char* full_path,
- off_t offset,
- size_t bytes,
- Error* error) {
- FileDescriptor fd;
- if (!fd.OpenReadOnly(full_path)) {
- error->Format("Error opening file '%s'", full_path);
- return NULL;
- }
- if (fd.SeekTo(offset) == -1) {
- error->Format("Error seeking to %d in file '%s'", offset, full_path);
- return NULL;
- }
-
- ScopedBuffer buffer(bytes);
- const ssize_t bytes_read = fd.Read(buffer.Get(), bytes);
- if (static_cast<size_t>(bytes_read) != bytes) {
- error->Format("Error reading %d bytes from file '%s'", bytes, full_path);
- return NULL;
- }
- fd.Close();
-
- uint8_t* packed_data = buffer.Release();
- return packed_data;
-}
-
-#endif // __arm__ || __aarch64__
-
} // namespace
SharedLibrary::SharedLibrary() { ::memset(this, 0, sizeof(*this)); }
@@ -253,10 +190,6 @@ SharedLibrary::~SharedLibrary() {
// Ensure the library is unmapped on destruction.
if (view_.load_address())
munmap(reinterpret_cast<void*>(view_.load_address()), view_.load_size());
-
-#if defined(__arm__) || defined(__aarch64__)
- delete [] packed_relocations_;
-#endif
}
bool SharedLibrary::Load(const char* full_path,
@@ -312,11 +245,6 @@ bool SharedLibrary::Load(const char* full_path,
phdr(), phdr_count(), load_bias(), &arm_exidx_, &arm_exidx_count_);
#endif
-#if defined(__arm__) || defined(__aarch64__)
- off_t packed_relocations_offset = 0;
- size_t packed_relocations_size = 0;
-#endif
-
LOG("%s: Parsing dynamic table for %s\n", __FUNCTION__, base_name_);
ElfView::DynamicIterator dyn(&view_);
for (; dyn.HasNext(); dyn.GetNext()) {
@@ -375,16 +303,6 @@ bool SharedLibrary::Load(const char* full_path,
if (dyn_value & DF_SYMBOLIC)
has_DT_SYMBOLIC_ = true;
break;
-#if defined(__arm__) || defined(__aarch64__)
- case DT_ANDROID_REL_OFFSET:
- packed_relocations_offset = dyn.GetOffset();
- LOG(" DT_ANDROID_REL_OFFSET addr=%p\n", packed_relocations_offset);
- break;
- case DT_ANDROID_REL_SIZE:
- packed_relocations_size = dyn.GetValue();
- LOG(" DT_ANDROID_REL_SIZE=%d\n", packed_relocations_size);
- break;
-#endif
#if defined(__mips__)
case DT_MIPS_RLD_MAP:
*dyn.GetValuePointer() =
@@ -396,32 +314,6 @@ bool SharedLibrary::Load(const char* full_path,
}
}
-#if defined(__arm__) || defined(__aarch64__)
- // If packed relocations are present in the target library, read the
- // section data and save it in packed_relocations_.
- if (packed_relocations_offset && packed_relocations_size) {
- LOG("%s: Packed relocations found at offset %d, %d bytes\n",
- __FUNCTION__,
- packed_relocations_offset,
- packed_relocations_size);
-
- packed_relocations_ =
- ReadPackedRelocations(full_path,
- packed_relocations_offset + file_offset,
- packed_relocations_size,
- error);
- if (!packed_relocations_)
- return false;
-
- LOG("%s: Packed relocations stored at %p\n",
- __FUNCTION__,
- packed_relocations_);
-
- // Add packed relocations to the view.
- view_.RegisterPackedRelocations(packed_relocations_);
- }
-#endif
-
LOG("%s: Load complete for %s\n", __FUNCTION__, base_name_);
return true;
}
« no previous file with comments | « third_party/android_crazy_linker/src/src/crazy_linker_shared_library.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698