diff options
author | Dmitriy Ivanov <dimitry@google.com> | 2015-03-30 18:43:38 -0700 |
---|---|---|
committer | Dmitriy Ivanov <dimitry@google.com> | 2015-03-31 11:49:25 -0700 |
commit | 20d89cb5b0d5eb7546a8fe8da44bbd91564dbdda (patch) | |
tree | 0dad262c1284ec393f11eae840e7603905a2204c /linker/linker_reloc_iterators.h | |
parent | 16c77212792808b9e4d8229e64c5b42f4327b6dc (diff) | |
download | android_bionic-20d89cb5b0d5eb7546a8fe8da44bbd91564dbdda.tar.gz android_bionic-20d89cb5b0d5eb7546a8fe8da44bbd91564dbdda.tar.bz2 android_bionic-20d89cb5b0d5eb7546a8fe8da44bbd91564dbdda.zip |
Fix long lines and replace macros with functions.
Change-Id: I4e1cab488d5b2c8e4289da617350a86e72a4ba12
Diffstat (limited to 'linker/linker_reloc_iterators.h')
-rw-r--r-- | linker/linker_reloc_iterators.h | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/linker/linker_reloc_iterators.h b/linker/linker_reloc_iterators.h index 5db31f9f6..f28c0e0d7 100644 --- a/linker/linker_reloc_iterators.h +++ b/linker/linker_reloc_iterators.h @@ -21,15 +21,10 @@ #include <string.h> -#define RELOCATION_GROUPED_BY_INFO_FLAG 1 -#define RELOCATION_GROUPED_BY_OFFSET_DELTA_FLAG 2 -#define RELOCATION_GROUPED_BY_ADDEND_FLAG 4 -#define RELOCATION_GROUP_HAS_ADDEND_FLAG 8 - -#define RELOCATION_GROUPED_BY_INFO(flags) (((flags) & RELOCATION_GROUPED_BY_INFO_FLAG) != 0) -#define RELOCATION_GROUPED_BY_OFFSET_DELTA(flags) (((flags) & RELOCATION_GROUPED_BY_OFFSET_DELTA_FLAG) != 0) -#define RELOCATION_GROUPED_BY_ADDEND(flags) (((flags) & RELOCATION_GROUPED_BY_ADDEND_FLAG) != 0) -#define RELOCATION_GROUP_HAS_ADDEND(flags) (((flags) & RELOCATION_GROUP_HAS_ADDEND_FLAG) != 0) +const size_t RELOCATION_GROUPED_BY_INFO_FLAG = 1; +const size_t RELOCATION_GROUPED_BY_OFFSET_DELTA_FLAG = 2; +const size_t RELOCATION_GROUPED_BY_ADDEND_FLAG = 4; +const size_t RELOCATION_GROUP_HAS_ADDEND_FLAG = 8; class plain_reloc_iterator { #if defined(USE_RELA) @@ -89,18 +84,19 @@ class packed_reloc_iterator { } } - if (RELOCATION_GROUPED_BY_OFFSET_DELTA(group_flags_)) { + if (is_relocation_grouped_by_offset_delta()) { reloc_.r_offset += group_r_offset_delta_; } else { reloc_.r_offset += decoder_.pop_front(); } - if (!RELOCATION_GROUPED_BY_INFO(group_flags_)) { + if (!is_relocation_grouped_by_info()) { reloc_.r_info = decoder_.pop_front(); } #if defined(USE_RELA) - if (RELOCATION_GROUP_HAS_ADDEND(group_flags_) && !RELOCATION_GROUPED_BY_ADDEND(group_flags_)) { + if (is_relocation_group_has_addend() && + !is_relocation_grouped_by_addend()) { reloc_.r_addend += decoder_.pop_front(); } #endif @@ -115,22 +111,23 @@ class packed_reloc_iterator { group_size_ = decoder_.pop_front(); group_flags_ = decoder_.pop_front(); - if (RELOCATION_GROUPED_BY_OFFSET_DELTA(group_flags_)) { + if (is_relocation_grouped_by_offset_delta()) { group_r_offset_delta_ = decoder_.pop_front(); } - if (RELOCATION_GROUPED_BY_INFO(group_flags_)) { + if (is_relocation_grouped_by_info()) { reloc_.r_info = decoder_.pop_front(); } - if (RELOCATION_GROUP_HAS_ADDEND(group_flags_) && RELOCATION_GROUPED_BY_ADDEND(group_flags_)) { + if (is_relocation_group_has_addend() && + is_relocation_grouped_by_addend()) { #if !defined(USE_RELA) // This platform does not support rela, and yet we have it encoded in android_rel section. DL_ERR("unexpected r_addend in android.rel section"); return false; #else reloc_.r_addend += decoder_.pop_front(); - } else if (!RELOCATION_GROUP_HAS_ADDEND(group_flags_)) { + } else if (!is_relocation_group_has_addend()) { reloc_.r_addend = 0; #endif } @@ -139,6 +136,22 @@ class packed_reloc_iterator { return true; } + bool is_relocation_grouped_by_info() { + return (group_flags_ & RELOCATION_GROUPED_BY_INFO_FLAG) != 0; + } + + bool is_relocation_grouped_by_offset_delta() { + return (group_flags_ & RELOCATION_GROUPED_BY_OFFSET_DELTA_FLAG) != 0; + } + + bool is_relocation_grouped_by_addend() { + return (group_flags_ & RELOCATION_GROUPED_BY_ADDEND_FLAG) != 0; + } + + bool is_relocation_group_has_addend() { + return (group_flags_ & RELOCATION_GROUP_HAS_ADDEND_FLAG) != 0; + } + decoder_t decoder_; size_t relocation_count_; size_t group_size_; |