GaloisInc / macaw

Open source binary analysis tools.
BSD 3-Clause "New" or "Revised" License
203 stars 20 forks source link

Deduplicate relocation resolution code in `ElfLoader` #347

Open RyanGlScott opened 11 months ago

RyanGlScott commented 11 months ago

The code in Data.Macaw.Memory.ElfLoader which resolves relocations (here) is quite long, and unnecessarily so. While each architecture has its own relocation types, many of them are handled in a very similar matter. For instance, all supported architectures have a JUMP_SLOT relocation type, which are handled nearly identically in relaTargetX86_64, relocARM32Abs, and relaTargetARM64, with only minor differences in the relocation size and endianness (which could be inferred from the architecture).

As much as possible, we should strive to use the same logic to resolve each category of relocation type across different architectures.