diff options
author | Dmitriy Ivanov <dimitry@google.com> | 2015-04-22 22:15:47 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-04-22 22:16:31 +0000 |
commit | ff18108981aa1fa73696d6db1919cdc38788bd4e (patch) | |
tree | 8f41a50086a97f88be5bf98d2a2806a26d854d5a | |
parent | 9ceec1a75dfcc8b032aa3a974b0cfc3bff5a306e (diff) | |
parent | 18870d350c29c83bdcecbe5cf3715b2c800275f7 (diff) | |
download | bionic-ff18108981aa1fa73696d6db1919cdc38788bd4e.zip bionic-ff18108981aa1fa73696d6db1919cdc38788bd4e.tar.gz bionic-ff18108981aa1fa73696d6db1919cdc38788bd4e.tar.bz2 |
Merge "Always use signed leb128 decoder"
-rw-r--r-- | linker/linker.cpp | 19 | ||||
-rw-r--r-- | linker/linker_mips.cpp | 7 | ||||
-rw-r--r-- | linker/linker_sleb128.h (renamed from linker/linker_leb128.h) | 37 |
3 files changed, 11 insertions, 52 deletions
diff --git a/linker/linker.cpp b/linker/linker.cpp index ebc0947..be7b10c 100644 --- a/linker/linker.cpp +++ b/linker/linker.cpp @@ -55,7 +55,7 @@ #include "linker_block_allocator.h" #include "linker_debug.h" #include "linker_environ.h" -#include "linker_leb128.h" +#include "linker_sleb128.h" #include "linker_phdr.h" #include "linker_relocs.h" #include "linker_reloc_iterators.h" @@ -2875,7 +2875,7 @@ bool soinfo::link_image(const soinfo_list_t& global_group, const soinfo_list_t& if (android_relocs_size_ > 3 && android_relocs_[0] == 'A' && android_relocs_[1] == 'P' && - (android_relocs_[2] == 'U' || android_relocs_[2] == 'S') && + android_relocs_[2] == 'S' && android_relocs_[3] == '2') { DEBUG("[ android relocating %s ]", get_soname()); @@ -2883,17 +2883,10 @@ bool soinfo::link_image(const soinfo_list_t& global_group, const soinfo_list_t& const uint8_t* packed_relocs = android_relocs_ + 4; const size_t packed_relocs_size = android_relocs_size_ - 4; - if (android_relocs_[2] == 'U') { - relocated = relocate( - packed_reloc_iterator<leb128_decoder>( - leb128_decoder(packed_relocs, packed_relocs_size)), - global_group, local_group); - } else { // android_relocs_[2] == 'S' - relocated = relocate( - packed_reloc_iterator<sleb128_decoder>( - sleb128_decoder(packed_relocs, packed_relocs_size)), - global_group, local_group); - } + relocated = relocate( + packed_reloc_iterator<sleb128_decoder>( + sleb128_decoder(packed_relocs, packed_relocs_size)), + global_group, local_group); if (!relocated) { return false; diff --git a/linker/linker_mips.cpp b/linker/linker_mips.cpp index c162111..0769f82 100644 --- a/linker/linker_mips.cpp +++ b/linker/linker_mips.cpp @@ -30,7 +30,7 @@ #include "linker_debug.h" #include "linker_relocs.h" #include "linker_reloc_iterators.h" -#include "linker_leb128.h" +#include "linker_sleb128.h" template bool soinfo::relocate<plain_reloc_iterator>(plain_reloc_iterator&& rel_iterator, const soinfo_list_t& global_group, @@ -41,11 +41,6 @@ template bool soinfo::relocate<packed_reloc_iterator<sleb128_decoder>>( const soinfo_list_t& global_group, const soinfo_list_t& local_group); -template bool soinfo::relocate<packed_reloc_iterator<leb128_decoder>>( - packed_reloc_iterator<leb128_decoder>&& rel_iterator, - const soinfo_list_t& global_group, - const soinfo_list_t& local_group); - template <typename ElfRelIteratorT> bool soinfo::relocate(ElfRelIteratorT&& rel_iterator, const soinfo_list_t& global_group, diff --git a/linker/linker_leb128.h b/linker/linker_sleb128.h index d5c6488..a34916f 100644 --- a/linker/linker_leb128.h +++ b/linker/linker_sleb128.h @@ -14,42 +14,14 @@ * limitations under the License. */ -#ifndef _LINKER_LEB128_H -#define _LINKER_LEB128_H +#ifndef _LINKER_SLEB128_H +#define _LINKER_SLEB128_H #include <stdint.h> // Helper classes for decoding LEB128, used in packed relocation data. // http://en.wikipedia.org/wiki/LEB128 -class leb128_decoder { - public: - leb128_decoder(const uint8_t* buffer, size_t count) - : current_(buffer), end_(buffer + count) { } - - size_t pop_front() { - size_t value = 0; - - size_t shift = 0; - uint8_t byte; - - do { - if (current_ >= end_) { - __libc_fatal("leb128_decoder ran out of bounds"); - } - byte = *current_++; - value |= static_cast<size_t>(byte & 127) << shift; - shift += 7; - } while (byte & 128); - - return value; - } - - private: - const uint8_t* current_; - const uint8_t* const end_; -}; - class sleb128_decoder { public: sleb128_decoder(const uint8_t* buffer, size_t count) @@ -64,7 +36,7 @@ class sleb128_decoder { do { if (current_ >= end_) { - __libc_fatal("leb128_decoder ran out of bounds"); + __libc_fatal("sleb128_decoder ran out of bounds"); } byte = *current_++; value |= (static_cast<size_t>(byte & 127) << shift); @@ -83,5 +55,4 @@ class sleb128_decoder { const uint8_t* const end_; }; -#endif // __LINKER_LEB128_H - +#endif // __LINKER_SLEB128_H |