CFI error with binutils 2.27

Hi,

:If I compile this file with debugging enabled (clang/LLVM TOT)

int main()
{
}

I get the error

Error: inconsistent uses of .cfi_sections

From the 2.27 binutils assemblers. It seems that 2.27 doesn't like the

.cfi_sections .debug_frame

directive following previous .cfi directives. The assemblers seem to be happy if the .cfi_sections directive precedes any other .cfi directive. Is this a bug in binutils or LLVM? It looks as if a fix might be to move the generation of the .cfi_sections directive from endModule() to somewhere else (maybe a non-existant beginModule()?).

Could someone give me some hints about what the right approach might be? It looks as if the ARM code generator might need special handling also since it appears to emit the .cfi_sections directive itself.

Thanks for any suggestions.

-Rich

As a work-around I modified DwarfCFIException.cpp and ARMException.cpp to send the .cfi_sections directive before the first function is processed. Seems to work.

-Rich

Copying Keith, the ARM dwarf expert. :slight_smile:

Cheers,
Renato

Was there any determination as to whether this is an LLVM bug or a Binutils bug?

I am using Binutils v2.26 plus some subsequent custom mods, and hoping to update to v2.27 soon so that I can ditch the mods and it would be good to know what I should expect.

Thanks,

  MartinO

Without any other feedback I went under the assumption that it was an LLVM error. The patch I made was pretty trivial and I'm happily using 2.27, but I'm waiting to see where people think the real bug is.

-Rich

It is perfectly reasonable to mix .eh_frame and .debug_frame even on
ARM. As such, I would call this a clear binutils bug.

Joerg

Hi,

:If I compile this file with debugging enabled (clang/LLVM TOT)

int main()
{
}

I get the error

Error: inconsistent uses of .cfi_sections

From the 2.27 binutils assemblers. It seems that 2.27 doesn't like the

.cfi_sections .debug_frame

directive following previous .cfi directives. The assemblers seem to be
happy if the .cfi_sections directive precedes any other .cfi directive. Is
this a bug in binutils or LLVM? It looks as if a fix might be to move the
generation of the .cfi_sections directive from endModule() to somewhere else
(maybe a non-existant beginModule()?).

Could someone give me some hints about what the right approach might be? It
looks as if the ARM code generator might need special handling also since it
appears to emit the .cfi_sections directive itself.

It doesn't seem like a GAS problem to me since they are adhering to
their documentation
(CFI directives (Using as)) that
says that all .cfi_sections directives
must precede the first .cfi_startproc directive. The check for this
rule was introduced to GAS in commit
bd5608dcc6a76876db06b1af1852252a4282aa2f on Feb 11 2016 (binutils
2.26+) and LLVM doesn't
work for me when using any version of binutils that contains this commit.

I went ahead and filed a bug for this with the LLVM bugzilla, it can be found at
https://llvm.org/bugs/show_bug.cgi?id=29017.

Thanks for any suggestions.

-Rich

Thanks,
Artemiy