Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

.cfi_sections directives should go before CFI generation start #29012

Open Quuxplusone opened 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR29017
Status NEW
Importance P normal
Reported by Artemiy Volkov (artemiyv@acm.org)
Reported on 2016-08-17 11:22:37 -0700
Last modified on 2016-10-14 06:50:37 -0700
Version trunk
Hardware PC Linux
CC compnerd@compnerd.org, echristo@gmail.com, ismail@i10z.com, llvm-bugs@lists.llvm.org, pjcoup@gmail.com, raj.khem@gmail.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Currently, the DwarfCFIException class writes the sections that the CFI emits
(via a .cfi_sections directive) within its endModule() method, after all the
other CFI info has already been output. This renders the resulting .s files
impossible for gnu as to process, since by the rules gnu as uses for the .cfi*
directives the last .cfi_sections directive must precede the first
.cfi_startproc directive (see 7.10.1 @
https://sourceware.org/binutils/docs/as/CFI-directives.html). This rule has
been enforced in gas since Feb 2016 (commit
bd5608dcc6a76876db06b1af1852252a4282aa2f), after the 2.26 release, and I've
been able to reproduce it for aarch64 and sparc, like this:

> cd binutils-build
> ../binutils-x86/configure --target=aarch64-linux && make
> cd ../t
> cat t.c
int main()
{
}
> ../clang-build/bin/clang 1.c -S -O0 -ggdb -target aarch64
> ../binutils-build/gas/as-new 1.s
t.s: Assembler messages:
t.s:142: Error: inconsistent uses of .cfi_sections

This problem has also been reported at http://lists.llvm.org/pipermail/llvm-
dev/2016-August/103519.html.
Quuxplusone commented 8 years ago
Yay. :\

commit bd5608dcc6a76876db06b1af1852252a4282aa2f
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu Feb 11 15:30:55 2016 +0000

    Allow the .cfi_sections directive to be reissued provided that CFI generation has not yet started.

        PR gas/19614
        * dw2gencfi.c (cfi_sections_set): Delay setting this variable
        until it is actually used.
        (cfi_set_sections): Set cfi_sections_set to true.
        (dot_cfi_startproc): Likewise.
        (dot_cfi_endproc): Likewise.
        (dot_cfi_fde_data): Likewise.
        (cfi_finish): Likewise.
        (dot_cfi_sections): Do not set cfi_sections_set.
        * doc/as.texinfo (.cfi_sections): Note that targets can provide
        their own cfi section name.  Also note that the directive can be
        reissued provided that CFI generation has not started.
        * testsuite/gas/mips/compact-eh-err2.s: Add .cfi_startproc and
        .cfi_endproc directives so that the redefinition of .cfi_sections
        will trigger the generation of the error message.
        * testsuite/gas/mips/compact-eh-err2.l: Update expected line
        number of error message.
Quuxplusone commented 8 years ago

I also needed to backport

https://sourceware.org/bugzilla/show_bug.cgi?id=20648

otherwise gas failed with same error with clang/trunk on armv7