Fix long lines and replace macros with functions.
Change-Id: I4e1cab488d5b2c8e4289da617350a86e72a4ba12
diff --git a/linker/linker_reloc_iterators.h b/linker/linker_reloc_iterators.h
index 5db31f9..f28c0e0 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 @@
}
}
- 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 @@
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 @@
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_;