Skip to content

.cfi_sections directives should go before CFI generation start #29387

Open
@llvmbot

Description

@llvmbot
Bugzilla Link 29017
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @compnerd,@echristo,@ismail,@kraj

Extended Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillacompiler-rt:cfiControl Flow Integrity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions