https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103525

Nelson Chu <nelsonc1225 at sourceware dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nelsonc1225 at sourceware dot 
org

--- Comment #2 from Nelson Chu <nelsonc1225 at sourceware dot org> ---
I think this should be hard to fix in binutils, since the debug info looks
wrong in the generated assembly code.  I notice that there is a similar pr as
follows,
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776

And here should be one of the solution of x86,
https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=3dcea658c9e2ac84

The patchable area should be placed before both .cfi_startproc and ENDBR. For
example,

$ cat tmp.c
void main ()
{}
$ riscv64-unknown-linux-gnu-gcc -fpatchable-function-entry=8,3 -S -g tmp.c

        .text
.Ltext0:
        .cfi_sections   .debug_frame
        .file 0 "/home/nelsonc" "tmp.c"
        .align  1
        .globl  main
        .section        __patchable_function_entries,"awo",@progbits,main
        .align  3
        .8byte  .LPFE1
        .text
.LPFE1:
        nop
        nop
        nop
        .type   main, @function
main:

<------ I think the .LFB0 ~ .cfi_startproc should be moved here ---------

        nop
        nop
        nop
        nop
        nop
.LFB0:
        .file 1 "tmp.c"
        .loc 1 2 1
        .cfi_startproc
        addi    sp,sp,-16

If I move the patchable area forward, then the DW_AT_low_pc looks correct.

Reply via email to