cle
cle copied to clipboard
Alternate implementation of R_PPC_JMP_SLOT for older ABI
Older PPC ABIs need their relocations, specifically R_PPC_JMP_SLOT implemented differently. The change to the current ABI, which we support well, is described here. You can detect the presence of the new ABI by the presence of the DT_PPC_GOT dynamic section tag, as indicated here. We can detect this right now (commit incoming), but the affect we need to implement based on this relocation in the old case is highly nontrivial, you can find a reference implementation in the ppc_fixup_plt function in the last link. It involves actually writing code into the PLT.
One cookie will be awarded to whoever implements this in CLE.
Super dumb workaround if you just want to get SimProcs working is to just hook the symbol address directly instead of inserting the code that would jump the address that is already hooked by CLE. Ugly code I used with binary ninja:
for sym in [ sym[1] for sym in bv.symbols.iteritems() if 'GOT' in sym[0] and "__" not in sym[0]]:
simproc = angr.SIM_PROCEDURES['libc'][sym.name[:-4]]
proj.hook(sym.address, hook=simproc())
To celebrate the one year anniversary of this issue, here is the expression to hook when using ghidra for symbols:
[ proj.hook(f.symbol.address.unsignedOffset, angr.SIM_PROCEDURES['libc'][f.name]()) for f in currentProgram.functionManager.getFunctions(True) if f.thunk and not f.name.startswith("__")]
The lingering thought that I could at least do this with CLE instead of some external tool will now distract me from what I actually want to do.
This issue has been marked as stale because it has no recent activity. Please comment or add the pinned tag to prevent this issue from being closed.
@rhelmot Can you provide an update to this issue?
This is still an issue exactly as described in the first post. This is a low priority issue, but it is a real missing feature that does prevent us from loading a certain class of binaries.
@rhelmot Does this PR solve this issue? https://github.com/angr/cle/pull/481