Skip to content

Commit

Permalink
Change mechanism for adapting section-specific relocations to rebasing (
Browse files Browse the repository at this point in the history
#470)

* Change mechanism for adapting section-specific relocations to rebasing

* Make IRelative relocations operate on global address space

I don't know why the prior commit produced this change

* Clean up the previous two commits

* weh
  • Loading branch information
rhelmot authored Apr 22, 2024
1 parent 568e4d1 commit f0d0bb2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cle/backends/elf/elf.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,15 +551,18 @@ def _load_segment(self, seg):

self.memory.add_backer(AT.from_lva(mapstart, self).to_rva(), data, overwrite=True)

def _make_reloc(self, readelf_reloc, symbol, dest_section=None):
def _make_reloc(self, readelf_reloc, symbol, dest_section: Optional[ELFSection] = None):
addend = readelf_reloc.entry.r_addend if readelf_reloc.is_RELA() else None
RelocClass = get_relocation(self.arch.name, readelf_reloc.entry.r_info_type)
if RelocClass is None:
return None

address = AT.from_lva(readelf_reloc.entry.r_offset, self).to_rva()
if dest_section is not None:
address += dest_section.remap_offset
# note to the intrepid explorer: this code was changed as per cle#467
# address += dest_section.remap_offset
if self.is_relocatable:
address += AT.from_mva(dest_section.vaddr, self).to_rva()

try:
return RelocClass(self, symbol, address, addend)
Expand Down

0 comments on commit f0d0bb2

Please sign in to comment.