GrammaTech / gtirb-rewriting

Python API for rewriting GTIRB files
GNU General Public License v3.0
16 stars 3 forks source link

CFI directive lost in rewrote binary #4

Closed StarGazerM closed 9 months ago

StarGazerM commented 2 years ago

Hi:

I am trying to rewrite some c++ binary which contain exception handling, but seems stack unwinding always fails, and I found

https://github.com/GrammaTech/gtirb-rewriting/blob/main/gtirb_rewriting/rewriting.py#L1062

in code, will these CFI removing cause .eh_frame information lost?

jranieri-grammatech commented 2 years ago

Yeah.

gtirb-rewriting definitely breaks C++ exception handling due to this. It's possible that the underlying problem has since been fixed, so I'd encourage you to try deleting that line in rewriting.py and testing it out. I don't have high hopes of it working, but it seems worth a try.

StarGazerM commented 2 years ago

ah..... seems not working, I saw cfi added, but seems still something wrong, cause segfault...

jranieri-grammatech commented 2 years ago

Unfortunately I don't have any workaround for this. It's something that I'd like to address but I suspect it's a fairly sizable task and I won't be able to get to it for some time.

StarGazerM commented 2 years ago

Sorry for reply late, what I found is in below:

So, how I solve it in my code is always throw error when insertion break function prologue and epilogue. Maybe in master, CFI removing line can be commented, and throw warning/error when user try to insert to a block has .cfi_startproc in it?

jranieri-grammatech commented 9 months ago

This has been resolved in the latest release of gtirb-rewriting.