Bug 99836 - aarch64: -fpatchable-function-entry=N[,0] should place .cfi_startproc before NOPs
Summary: aarch64: -fpatchable-function-entry=N[,0] should place .cfi_startproc before ...
Status: RESOLVED DUPLICATE of bug 98776
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 11.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-30 18:20 UTC by Fangrui Song
Modified: 2021-03-31 10:21 UTC (History)
0 users

See Also:
Host:
Target: aarch64
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2021-03-30 18:20:56 UTC
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.
Comment 1 Richard Earnshaw 2021-03-31 10:21:25 UTC
Dup

*** This bug has been marked as a duplicate of bug 98776 ***