[LLVMdev] CFI Directives
Rafael EspĂndola
rafael.espindola at gmail.com
Thu Sep 5 20:46:14 PDT 2013
On 5 September 2013 19:27, Bill Wendling <wendling at apple.com> wrote:
> Hi Rafael,
>
> I've been staring at the CFI directives and have a question. Some background: I want to generate the compact unwind information using just the CFI directives. I *think* that this should be doable. The issue I'm facing right now is that I need to know how much the stack pointer was adjusted. So when I have something like this:
>
> .cfi_startproc
> Lfunc_begin175:
> pushq %rbp
> Ltmp1532:
> .cfi_def_cfa_offset 16
> Ltmp1533:
> .cfi_offset %rbp, -16
> movq %rsp, %rbp
> Ltmp1534:
> .cfi_def_cfa_register %rbp
> pushq %r15
> pushq %r14
> pushq %rbx
> subq $3224, %rsp ## imm = 0xC98
> Ltmp1535:
> .cfi_offset %rbx, -40
> Ltmp1536:
> .cfi_offset %r14, -32
> Ltmp1537:
> .cfi_offset %r15, -24
>
> I need to be able to know that `%rsp' was adjusted by 3224. However, there are no CFI directives that encode this information. Is this something which cannot be encoded in CFI? or if it can be, what's the best way?
In this case that is not encoded because what is encoded is that the
call frame in that region is rbp. Without a frame pointer, compiling
void f(void *);
void g(void) {
f(alloca(100));
}
produces
pushq %rbx
Ltmp2:
.cfi_def_cfa_offset 16
subq $112, %rsp
Ltmp3:
.cfi_def_cfa_offset 128
Ltmp4:
.cfi_offset %rbx, -16
Which does contain the rsp updates. The two places I can think with
some documentation are
http://www.dwarfstd.org/doc/DWARF4.pdf (the 6.4 Call Frame Information
section). This is the old .debug_frame, but that is where the idea
came from.
http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/ehframechpt.html
http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/dwarfext.html#AEN1154
Cheers,
Rafael
More information about the llvm-dev
mailing list