Implib.so
Implib.so copied to clipboard
question about cfi_adjust_cfa_offset after just entering into fuction
very thanks for your useful tool, i have a question about cfi https://github.com/yugr/Implib.so/blob/bbca01e0109d51ef1b870cbc8cf953372136b8ad/arch/x86_64/table.S.tpl#L29
.cfi_adjust_cfa_offset 8; should this offset be 16, since previous instruction call also push IP to stack?
Thank you for using Implib.so.
.cfi_adjust_cfa_offset tells debugger that pushq changes SP value by 8. If there's any previous instruction which changes SP, it should have it's own .cfi_adjust_cfa_offset directive. Debuggers "combines" different .cfi_adjust_cfa_offset directives so for code like
inst1
.cfi_adjust_cfa_offset 8
inst2
cfi_adjust_cfa_offset 8
it will understand that the final offset is 16.
https://github.com/yugr/Implib.so/blob/bbca01e0109d51ef1b870cbc8cf953372136b8ad/arch/x86_64/trampoline.S.tpl#L28 Really thank you for answering my newbie question. The call instruction will push RIP on stack and it change the SP but there is no matching .cfi_adjust_cfa_offset. where is call's .cfi_adjust_cfa_offset?
Hm, yes, I think you are right, I'll fix this. How did you run into this issue (so that I could test it myself locally)?
Honestly, i haven't met this issue. i just review code. I tried generate a core dump in basic test, but haven't seen any different😒.
I've added a simple fix on a branch but I'm hesitant to commit it just yet without fully understanding how to test it.
I've found a way to diagnose this issue (call stack would become broken without proper CFI directives) and was able to prepare a proper fix.
Thank you for the report and please let me know if you find other issues.
Hi Yugr,
I've found a way to diagnose this issue How do you do this test? can you share some information?
I've put a breakpoint in _XXX_tramp_resolve and checked that backtrace command works correctly (prints whole stack up to main) and variables in main are printed correctly. This didn't work without the fix.
thanks, yugr😊