[LLVMdev] So what's the deal with debug_frame V eh_frame

David Blaikie dblaikie at gmail.com
Wed Mar 19 17:31:05 PDT 2014


While comparing debug info between GCC and Clang I found a section
that only Clang produces and GCC never produces: debug_frame.

It seems (though I haven't verified this with absolute certainty) as
though GCC just always uses eh_frame. LLVM on the other hand sometimes
uses eh_frame and sometimes uses debug_frame.

Here's an example:

int f1();
int i = f1();
void func() { }

Compiled with -fno-exceptions -g.

The first two lines produce a global ctor.

Clang is generous enough to flag the LLVM IR function for this global
ctor ("__cxx_global_var_init") as nounwind
(tools/clang/lib/CodeGen/CGDeclCXX.cpp:246), though "func" gets
flagged as nounwind but also as uwtable (why? I don't really
understand these semantics & haven't tracked down where that attribute
gets applied)

Without 'func' in this translation unit, LLVM emits a debug_frame
section (because no functions actually need an unwind table, but we're
compiling with debug info (without debug info LLVM emits no _frame
section at all)). With 'func', LLVM switches to emitting an eh_frame
section in both (-g and no -g) cases.

GCC on the other hand emits eh_frame in all 4 cases (with and without
-g and with and without 'func' defined).

Do we need all this logic? Should we just always use eh_frame? Should
we not have the 'uwtable' attribute on 'func'? Why is 'func' different
from the global ctor in this regard?

Confused,
- David



More information about the llvm-dev mailing list