cesena / ghidra2dwarf

🐉 Export ghidra decompiled code to dwarf sections inside ELF binary
MIT License
179 stars 17 forks source link

Output DW_LNS_set_isa commands for Thumb/ARM switch #22

Closed nneonneo closed 1 year ago

nneonneo commented 1 year ago

Currently, objdump on an exported Thumb binary shows all ARM code. ISA state is encoded in the line number table using the special DW_LNS_set_isa opcode. We can get the ISA mode from Ghidra's Tmode context register, and apply this opcode by using the isa argument to dwarf_add_line_entry_c.

nneonneo commented 1 year ago

After implementing it, it seems it doesn't affect objdump, actually, and GDB seems to use the low bit of PC to decide what mode to use. Not sure if this will be as useful as I thought it would be.

Additionally, due to a bug in libdwarf, implementing this bloats the line number table considerably: DW_LNS_set_isa is generated for every instruction because the library doesn't implement the prev_line check correctly.

Closing as WONTFIX for now.