diff --git a/linker/linker.cpp b/linker/linker.cpp index ebc0947c5..be7b10cc1 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(packed_relocs, packed_relocs_size)), - global_group, local_group); - } else { // android_relocs_[2] == 'S' - relocated = relocate( - packed_reloc_iterator( - sleb128_decoder(packed_relocs, packed_relocs_size)), - global_group, local_group); - } + relocated = relocate( + packed_reloc_iterator( + 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 c162111e9..0769f826e 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&& rel_iterator, const soinfo_list_t& global_group, @@ -41,11 +41,6 @@ template bool soinfo::relocate>( const soinfo_list_t& global_group, const soinfo_list_t& local_group); -template bool soinfo::relocate>( - packed_reloc_iterator&& rel_iterator, - const soinfo_list_t& global_group, - const soinfo_list_t& local_group); - template bool soinfo::relocate(ElfRelIteratorT&& rel_iterator, const soinfo_list_t& global_group, diff --git a/linker/linker_leb128.h b/linker/linker_sleb128.h similarity index 67% rename from linker/linker_leb128.h rename to linker/linker_sleb128.h index d5c6488c0..a34916f87 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 // 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(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(byte & 127) << shift); @@ -83,5 +55,4 @@ class sleb128_decoder { const uint8_t* const end_; }; -#endif // __LINKER_LEB128_H - +#endif // __LINKER_SLEB128_H