https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99836
Bug ID: 99836 Summary: aarch64: -fpatchable-function-entry=N[,0] should place .cfi_startproc before NOPs Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: i at maskray dot me Target Milestone: --- Extracted from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92424#c8 % echo 'int main() {}' > a.c % clang --target=aarch64 -fpatchable-function-entry=2 -mbranch-protection=standard -S a.c -o - ... main: // @main .Lfunc_begin0: .cfi_startproc // %bb.0: // %entry hint #34 .Lpatch0: nop nop % /tmp/glibc-many/install/compilers/aarch64-linux-gnu/bin/aarch64-glibc-linux-gnu-g++ -fpatchable-function-entry=2 -mbranch-protection=standard -S a.c -o - .arch armv8-a .file "a.c" .text .align 2 .global main .type main, %function main: hint 34 // bti c .section __patchable_function_entries,"aw",@progbits .align 3 .8byte .LPFE1 .text .LPFE1: nop nop .LFB0: .cfi_startproc For -fpatchable-function-entry=N[,0], placing .cfi_startproc before NOPs makes more sense and can make unwinding work in that region. For N[,M] where M>0, that is a very narrow use case by the Linux kernel. I prefer not to place .cfi_startproc above the function label.