- Elf_Rela_Iter rela_begin(const Elf_Shdr *sec) const {
- return Elf_Rela_Iter(sec->sh_entsize,
- (const char *)(base() + sec->sh_offset));
+ typedef iterator_range<const Elf_Rela *> Elf_Rela_Range;
+
+ Elf_Rela_Range dyn_relas() const {
+ return make_range(dyn_rela_begin(), dyn_rela_end());
+ }
+
+ const Elf_Rela *rela_begin(const Elf_Shdr *sec) const {
+ if (sec->sh_entsize != sizeof(Elf_Rela))
+ report_fatal_error("Invalid relocation entry size");
+ return reinterpret_cast<const Elf_Rela *>(base() + sec->sh_offset);
+ }
+
+ const Elf_Rela *rela_end(const Elf_Shdr *sec) const {
+ uint64_t Size = sec->sh_size;
+ if (Size % sizeof(Elf_Rela))
+ report_fatal_error("Invalid relocation table size");
+ return rela_begin(sec) + Size / sizeof(Elf_Rela);
+ }
+
+ Elf_Rela_Range relas(const Elf_Shdr *Sec) const {
+ return make_range(rela_begin(Sec), rela_end(Sec));