HexHive/retrowrite

[BUG] RetroWrite omits data sections

miksh opened this issue · 0 comments

miksh commented

Description:
RetroWrite did not create data sections, like .data.rel.ro.local, .fini.array
As a result, RetroWrite not only recover certain relocation information,
but also emit incorrect assembly code.

My test program has relocation information in .data.rel.ro.local

$ readelf -r  hello  | grep .data.rel.ro.local -A 20
Relocation section '.rela.data.rel.ro.local' at offset 0x9a3d8 contains 165 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
000000020360  000100000001 R_X86_64_64       0000000000003c90 .text + 26a0
000000020368  000100000001 R_X86_64_64       0000000000003c90 .text + 2d60
000000020370  000100000001 R_X86_64_64       0000000000003c90 .text + 26b0
000000020378  000100000001 R_X86_64_64       0000000000003c90 .text + 2e20
...

Its binary code refers .data.rel.ro.local section.

  • Disassembly code
    61ec:	48 8d 05 6d a1 01 00 	lea    0x1a16d(%rip),%rax        # 20360 <sort_functions>

However, RetroWrite emited weird assembly code.

  • Reassembled code
.LC61ec:
	leaq 41984+.LC15f60(%rip), %rax

I examined the reassembly file and found that RetroWrite did not create .data.rel.ro.local section.

I hope to fix the errors.

Thanks.