diff options
author | David 'Digit' Turner <digit@android.com> | 2013-09-19 16:21:17 +0200 |
---|---|---|
committer | David 'Digit' Turner <digit@android.com> | 2013-09-19 16:21:17 +0200 |
commit | 41051de2c8fbb9c59b436f221544b2b22a93a034 (patch) | |
tree | 6a472928c76c4b5e9426ca94b790106a801f2b05 /sources/android/crazy_linker | |
parent | a3c5d104e9cfdf0da45fa4ef0ae79e73a704df51 (diff) | |
download | ndk-41051de2c8fbb9c59b436f221544b2b22a93a034.tar.gz |
crazy_linker: trivial reformatting.
Change-Id: I798d1993fe1a214ef16bb11a49278f6021451e19
Diffstat (limited to 'sources/android/crazy_linker')
9 files changed, 39 insertions, 53 deletions
diff --git a/sources/android/crazy_linker/include/crazy_linker.h b/sources/android/crazy_linker/include/crazy_linker.h index 4a579ef6c..9462b59c0 100644 --- a/sources/android/crazy_linker/include/crazy_linker.h +++ b/sources/android/crazy_linker/include/crazy_linker.h @@ -197,13 +197,12 @@ crazy_status_t crazy_system_can_share_relro(void); // the data. On failure, return false and set error message in |context|. // NOTE: On success, the caller becomes the owner of |*relro_fd| and is shall // close it appropriately. -crazy_status_t crazy_library_create_shared_relro( - crazy_library_t* library, - crazy_context_t* context, - size_t load_address, - size_t* relro_start, - size_t* relro_size, - int* relro_fd) _CRAZY_PUBLIC; +crazy_status_t crazy_library_create_shared_relro(crazy_library_t* library, + crazy_context_t* context, + size_t load_address, + size_t* relro_start, + size_t* relro_size, + int* relro_fd) _CRAZY_PUBLIC; // Use the shared RELRO section of the same library loaded in a different // address space. On success, return CRAZY_STATUS_SUCCESS and owns |relro_fd|. @@ -215,13 +214,13 @@ crazy_status_t crazy_library_create_shared_relro( // |context| will receive an error in case of failure. // NOTE: This will fail if this is a system library, or if the RELRO // parameters do not match the library's actual load address. -// NOTE: The caller is responsible for closing the file descriptor after this call. -crazy_status_t crazy_library_use_shared_relro( - crazy_library_t* library, - crazy_context_t* context, - size_t relro_start, - size_t relro_size, - int relro_fd) _CRAZY_PUBLIC; +// NOTE: The caller is responsible for closing the file descriptor after this +// call. +crazy_status_t crazy_library_use_shared_relro(crazy_library_t* library, + crazy_context_t* context, + size_t relro_start, + size_t relro_size, + int relro_fd) _CRAZY_PUBLIC; // Look for a library named |library_name| in the set of currently // loaded libraries, and return a handle for it in |*library| on success. diff --git a/sources/android/crazy_linker/src/crazy_linker_elf_relocations.h b/sources/android/crazy_linker/src/crazy_linker_elf_relocations.h index c2fb0f9d8..3973fc092 100644 --- a/sources/android/crazy_linker/src/crazy_linker_elf_relocations.h +++ b/sources/android/crazy_linker/src/crazy_linker_elf_relocations.h @@ -18,7 +18,7 @@ class Error; // An ElfRelocations instance holds information about relocations in a mapped // ELF binary. class ElfRelocations { -public: + public: ElfRelocations() { ::memset(this, 0, sizeof(*this)); } ~ElfRelocations() {} @@ -55,7 +55,7 @@ public: size_t map_addr, size_t size); -private: + private: bool ApplyRelocs(const ELF::Rel* relocs, size_t relocs_count, const ElfSymbols* symbols, @@ -88,10 +88,8 @@ private: bool has_text_relocations_; bool has_symbolic_; - }; } // namespace crazy -#endif //CRAZY_LINKER_ELF_RELOCATIONS_H - +#endif // CRAZY_LINKER_ELF_RELOCATIONS_H diff --git a/sources/android/crazy_linker/src/crazy_linker_elf_relro.h b/sources/android/crazy_linker/src/crazy_linker_elf_relro.h index e8d510a53..0f2591ad0 100644 --- a/sources/android/crazy_linker/src/crazy_linker_elf_relro.h +++ b/sources/android/crazy_linker/src/crazy_linker_elf_relro.h @@ -5,9 +5,9 @@ #ifndef CRAZY_LINKER_ELF_RELRO_H #define CRAZY_LINKER_ELF_RELRO_H -#include "crazy_linker_system.h" #include "crazy_linker_ashmem.h" #include "crazy_linker_memory_mapping.h" +#include "crazy_linker_system.h" #include "elf_traits.h" namespace crazy { @@ -32,25 +32,19 @@ class SharedRelro { // Return the ashmem region's file descriptor, and detach it from the object. // After this call, fd() will always return -1. - int DetachFd() { - return ashmem_.Release(); - } + int DetachFd() { return ashmem_.Release(); } // Allocate a new ashmem region of |relro_size| bytes for |library_name|. // This operation doesn't change the process' mappings. On error, return // false and set |error| message. - bool Allocate(size_t relro_size, - const char* library_name, - Error* error); + bool Allocate(size_t relro_size, const char* library_name, Error* error); // Copy the content of the current process' RELRO into the ashmem region. // |relro_start| is the RELRO address (page-aligned). // |relro_size| is the RELRO size in bytes (page-aligned), and must match // the allocation size passed to Allocate(). // On failure, return false and set |error| message. - bool CopyFrom(size_t relro_start, - size_t relro_size, - Error* error); + bool CopyFrom(size_t relro_start, size_t relro_size, Error* error); // Copy the contents of the current process' RELRO into the ashmem region // but adjust any relocation targets within it to correspond to a new diff --git a/sources/android/crazy_linker/src/crazy_linker_elf_symbols.h b/sources/android/crazy_linker/src/crazy_linker_elf_symbols.h index c8f5dc37d..9e79b22f7 100644 --- a/sources/android/crazy_linker/src/crazy_linker_elf_symbols.h +++ b/sources/android/crazy_linker/src/crazy_linker_elf_symbols.h @@ -13,7 +13,8 @@ namespace crazy { class ElfView; -// An ElfSymbols instance holds information about symbols in a mapped ELF binary. +// An ElfSymbols instance holds information about symbols in a mapped ELF +// binary. class ElfSymbols { public: ElfSymbols() { ::memset(this, 0, sizeof(*this)); } diff --git a/sources/android/crazy_linker/src/crazy_linker_elf_view.h b/sources/android/crazy_linker/src/crazy_linker_elf_view.h index 2dbf47bec..c60dd6ea4 100644 --- a/sources/android/crazy_linker/src/crazy_linker_elf_view.h +++ b/sources/android/crazy_linker/src/crazy_linker_elf_view.h @@ -18,7 +18,7 @@ class Error; // the crazy linker. This can be used to describe either system or crazy // libraries. class ElfView { -public: + public: ElfView() { ::memset(this, 0, sizeof(*this)); } ~ElfView() {} @@ -59,7 +59,7 @@ public: // } // } class DynamicIterator { - public: + public: DynamicIterator(const ElfView* view) { dyn_ = view->dynamic(); dyn_limit_ = dyn_ + view->dynamic_count(); @@ -84,7 +84,7 @@ public: return load_bias + dyn_->d_un.d_ptr; } - private: + private: const ELF::Dyn* dyn_; const ELF::Dyn* dyn_limit_; }; @@ -93,7 +93,7 @@ public: // ELF binary is mapped.On failure, return false and set |error| message. bool ProtectRelroSection(Error* error); -protected: + protected: const ELF::Phdr* phdr_; size_t phdr_count_; const ELF::Dyn* dynamic_; @@ -106,5 +106,4 @@ protected: } // namespace crazy - #endif // CRAZY_LINKER_ELF_VIEW_H diff --git a/sources/android/crazy_linker/src/crazy_linker_memory_mapping.h b/sources/android/crazy_linker/src/crazy_linker_memory_mapping.h index 13d793d00..5e6812c98 100644 --- a/sources/android/crazy_linker/src/crazy_linker_memory_mapping.h +++ b/sources/android/crazy_linker/src/crazy_linker_memory_mapping.h @@ -34,10 +34,7 @@ class MemoryMapping { // |prot| are the desired protection bit flags. // |fd| is -1 (for anonymous mappings), or a valid file descriptor. // on failure, return false and sets errno. - bool Allocate(void* address, - size_t size, - Protection prot, - int fd) { + bool Allocate(void* address, size_t size, Protection prot, int fd) { int flags = (fd >= 0) ? MAP_SHARED : MAP_ANONYMOUS; if (address) flags |= MAP_FIXED; diff --git a/sources/android/crazy_linker/src/crazy_linker_proc_maps.cpp b/sources/android/crazy_linker/src/crazy_linker_proc_maps.cpp index d089a90bd..6f2fe1efe 100644 --- a/sources/android/crazy_linker/src/crazy_linker_proc_maps.cpp +++ b/sources/android/crazy_linker/src/crazy_linker_proc_maps.cpp @@ -89,7 +89,7 @@ bool ParseProcMapsLine(const char* line, break; case 2: // protection bits - { + { int flags = 0; for (const char* t = tok_start; t < tok_end; ++t) { if (*t == 'r') diff --git a/sources/android/crazy_linker/src/crazy_linker_shared_library.h b/sources/android/crazy_linker/src/crazy_linker_shared_library.h index 9cadf3d24..8ce381e91 100644 --- a/sources/android/crazy_linker/src/crazy_linker_shared_library.h +++ b/sources/android/crazy_linker/src/crazy_linker_shared_library.h @@ -146,9 +146,7 @@ class SharedLibrary { class DependencyIterator { public: DependencyIterator(SharedLibrary* lib) - : iter_(&lib->view_), - symbols_(&lib->symbols_), - dep_name_(NULL) {} + : iter_(&lib->view_), symbols_(&lib->symbols_), dep_name_(NULL) {} bool GetNext(); diff --git a/sources/android/crazy_linker/tests/test_util.h b/sources/android/crazy_linker/tests/test_util.h index 0fef81341..28fd39fa9 100644 --- a/sources/android/crazy_linker/tests/test_util.h +++ b/sources/android/crazy_linker/tests/test_util.h @@ -10,8 +10,10 @@ #ifndef TEST_UTIL_H #define TEST_UTIL_H -#include <errno.h> +#include <crazy_linker.h> + #include <dirent.h> +#include <errno.h> #include <limits.h> #include <stdarg.h> #include <stdio.h> @@ -22,8 +24,6 @@ #include <sys/uio.h> #include <unistd.h> -#include <crazy_linker.h> - namespace { // Print an error message and exit the process. @@ -400,12 +400,11 @@ struct RelroLibrary { crazy_context_get_error(context)); } - printf( - "Parent %s relro info relro_start=%p relro_size=%p relro_fd=%d\n", - this->name, - (void*)this->relro.start, - (void*)this->relro.size, - this->relro.fd); + printf("Parent %s relro info relro_start=%p relro_size=%p relro_fd=%d\n", + this->name, + (void*)this->relro.start, + (void*)this->relro.size, + this->relro.fd); } void EnableSharedRelro(crazy_context_t* context) { @@ -418,7 +417,8 @@ struct RelroLibrary { Panic("Could not send %s RELRO fd: %s", this->name, strerror(errno)); } - int ret = TEMP_FAILURE_RETRY(::write(fd, &this->relro, sizeof(this->relro))); + int ret = + TEMP_FAILURE_RETRY(::write(fd, &this->relro, sizeof(this->relro))); if (ret != static_cast<int>(sizeof(this->relro))) { Panic("Parent could not send %s RELRO info: %s", this->name, |