mahaloz / decomp2dbg

A plugin to introduce interactive symbols into your debugger from your decompiler
BSD 2-Clause "Simplified" License
621 stars 39 forks source link

Ghidra: Unable to decompile after rebasing addreses of PIE binary #70

Open Angelo942 opened 1 year ago

Angelo942 commented 1 year ago

Hi,

this is similar to #60

Rebasing causes the debugger to tell the decompiler that it's PIE, which means that it needs to rebase everything. But then the decompiler has essentially turned the binary into a Non-PIE address layout, which conflicts with what the debugger is telling the decompiler.

but the second part of your answer there seems to describe a different problem, so I'm opening a new issue specific to this plugin.

This causes both to send massive addresses (the ones seen inside the debugger), which both causes a mismatch and a number too large to send on XML.

In this case, after rebasing a binary to 0x555555554000, I get the following error: Decompiler server sent back a response without decompilation lines for 0x4360. I think GDB is sending the relative address to de decompiler, but Ghidra uses that value as an absolute address and not an offset, so if I set 0x0 as a base everything still works fine, but otherwise I get the wrong code or nothing at all.

For what I've seen in the source code the plugin does use the new base in ghidra, so I don't know where is the problem. https://github.com/mahaloz/d2d-ghidra-plugin/blob/5bd8a4cadf2e7fbb29e6c801ccf117ad3d0b1550/src/main/java/decomp2dbg/D2DGhidraServerAPI.java#L46 https://github.com/mahaloz/d2d-ghidra-plugin/blob/5bd8a4cadf2e7fbb29e6c801ccf117ad3d0b1550/src/main/java/decomp2dbg/D2DPlugin.java#L139-L155

mahaloz commented 1 year ago

Hi, I’m going to transfer this issue for easier tracking, since I plan on archiving this repo and moving all the code into the d2d repo.