Refactoring: introduce reloc_iterators

 Replace rel/rela array with reloc_iterators.

Change-Id: I6165d062e0390b6bc60da2e8279aabbedf828ec9
diff --git a/linker/linker_reloc_iterators.h b/linker/linker_reloc_iterators.h
new file mode 100644
index 0000000..6388bb0
--- /dev/null
+++ b/linker/linker_reloc_iterators.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __LINKER_RELOC_ITERATORS_H
+#define __LINKER_RELOC_ITERATORS_H
+
+#include "linker.h"
+
+class plain_reloc_iterator {
+#if defined(USE_RELA)
+  typedef ElfW(Rela) rel_t;
+#else
+  typedef ElfW(Rel) rel_t;
+#endif
+ public:
+  plain_reloc_iterator(rel_t* rel_array, size_t count)
+      : begin_(rel_array), end_(begin_ + count), current_(begin_) {}
+
+  bool has_next() {
+    return current_ < end_;
+  }
+
+  rel_t* next() {
+    return current_++;
+  }
+ private:
+  rel_t* const begin_;
+  rel_t* const end_;
+  rel_t* current_;
+
+  DISALLOW_COPY_AND_ASSIGN(plain_reloc_iterator);
+};
+
+#endif  // __LINKER_RELOC_ITERATORS_H