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.
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 aJUMP_SLOT
relocation type, which are handled nearly identically inrelaTargetX86_64
,relocARM32Abs
, andrelaTargetARM64
, 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.