[Bug debug/98776] DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776 Sebastian Pop changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #15 from Sebastian Pop --- Fixed for arm64 as well on master, and backported to active branches gcc-12, 11, and 10.
[Bug debug/98776] DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776 --- Comment #14 from CVS Commits --- The releases/gcc-12 branch has been updated by Sebastian Pop : https://gcc.gnu.org/g:7525c9d7e72ac3818e08fe7aa98396bd41e4ec8c commit r12-8987-g7525c9d7e72ac3818e08fe7aa98396bd41e4ec8c Author: Sebastian Pop Date: Wed Nov 30 19:45:24 2022 + AArch64: Add UNSPECV_PATCHABLE_AREA [PR98776] Currently patchable area is at the wrong place on AArch64. It is placed immediately after function label, before .cfi_startproc. This patch adds UNSPECV_PATCHABLE_AREA for pseudo patchable area instruction and modifies aarch64_print_patchable_function_entry to avoid placing patchable area before .cfi_startproc. gcc/ PR target/98776 * config/aarch64/aarch64-protos.h (aarch64_output_patchable_area): Declared. * config/aarch64/aarch64.cc (aarch64_print_patchable_function_entry): Emit an UNSPECV_PATCHABLE_AREA pseudo instruction. (aarch64_output_patchable_area): New. * config/aarch64/aarch64.md (UNSPECV_PATCHABLE_AREA): New. (patchable_area): Define. gcc/testsuite/ PR target/98776 * gcc.target/aarch64/pr98776.c: New. * gcc.target/aarch64/pr92424-2.c: Adjust pattern. * gcc.target/aarch64/pr92424-3.c: Adjust pattern.
[Bug debug/98776] DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776 --- Comment #13 from CVS Commits --- The releases/gcc-11 branch has been updated by Sebastian Pop : https://gcc.gnu.org/g:50f7161448a19c4fa355c7c652e26b47ceb36cc4 commit r11-10422-g50f7161448a19c4fa355c7c652e26b47ceb36cc4 Author: Sebastian Pop Date: Wed Nov 30 19:45:24 2022 + AArch64: Add UNSPECV_PATCHABLE_AREA [PR98776] Currently patchable area is at the wrong place on AArch64. It is placed immediately after function label, before .cfi_startproc. This patch adds UNSPECV_PATCHABLE_AREA for pseudo patchable area instruction and modifies aarch64_print_patchable_function_entry to avoid placing patchable area before .cfi_startproc. gcc/ PR target/98776 * config/aarch64/aarch64-protos.h (aarch64_output_patchable_area): Declared. * config/aarch64/aarch64.c (aarch64_print_patchable_function_entry): Emit an UNSPECV_PATCHABLE_AREA pseudo instruction. (aarch64_output_patchable_area): New. * config/aarch64/aarch64.md (UNSPECV_PATCHABLE_AREA): New. (patchable_area): Define. gcc/testsuite/ PR target/98776 * gcc.target/aarch64/pr98776.c: New. * gcc.target/aarch64/pr92424-2.c: Adjust pattern. * gcc.target/aarch64/pr92424-3.c: Adjust pattern.
[Bug debug/98776] DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776 --- Comment #12 from CVS Commits --- The releases/gcc-10 branch has been updated by Sebastian Pop : https://gcc.gnu.org/g:59bba6f9dc6dcfefe96e6fad677614f39928564e commit r10-11122-g59bba6f9dc6dcfefe96e6fad677614f39928564e Author: Sebastian Pop Date: Wed Nov 30 19:45:24 2022 + AArch64: Add UNSPECV_PATCHABLE_AREA [PR98776] Currently patchable area is at the wrong place on AArch64. It is placed immediately after function label, before .cfi_startproc. This patch adds UNSPECV_PATCHABLE_AREA for pseudo patchable area instruction and modifies aarch64_print_patchable_function_entry to avoid placing patchable area before .cfi_startproc. gcc/ PR target/98776 * config/aarch64/aarch64-protos.h (aarch64_output_patchable_area): Declared. * config/aarch64/aarch64.c (aarch64_print_patchable_function_entry): Emit an UNSPECV_PATCHABLE_AREA pseudo instruction. (aarch64_output_patchable_area): New. * config/aarch64/aarch64.md (UNSPECV_PATCHABLE_AREA): New. (patchable_area): Define. gcc/testsuite/ PR target/98776 * gcc.target/aarch64/pr98776.c: New. * gcc.target/aarch64/pr92424-2.c: Adjust pattern. * gcc.target/aarch64/pr92424-3.c: Adjust pattern.
[Bug debug/98776] DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776 --- Comment #11 from CVS Commits --- The master branch has been updated by Sebastian Pop : https://gcc.gnu.org/g:09c91caeb84e7c3609a12a53b57e5219a1dd2b15 commit r13-4561-g09c91caeb84e7c3609a12a53b57e5219a1dd2b15 Author: Sebastian Pop Date: Wed Nov 30 19:45:24 2022 + AArch64: Add UNSPECV_PATCHABLE_AREA [PR98776] Currently patchable area is at the wrong place on AArch64. It is placed immediately after function label, before .cfi_startproc. This patch adds UNSPECV_PATCHABLE_AREA for pseudo patchable area instruction and modifies aarch64_print_patchable_function_entry to avoid placing patchable area before .cfi_startproc. gcc/ PR target/98776 * config/aarch64/aarch64-protos.h (aarch64_output_patchable_area): Declared. * config/aarch64/aarch64.cc (aarch64_print_patchable_function_entry): Emit an UNSPECV_PATCHABLE_AREA pseudo instruction. (aarch64_output_patchable_area): New. * config/aarch64/aarch64.md (UNSPECV_PATCHABLE_AREA): New. (patchable_area): Define. gcc/testsuite/ PR target/98776 * gcc.target/aarch64/pr98776.c: New. * gcc.target/aarch64/pr92424-2.c: Adjust pattern. * gcc.target/aarch64/pr92424-3.c: Adjust pattern.
[Bug debug/98776] DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776 --- Comment #10 from Sebastian Pop --- Patch for arm64: https://gcc.gnu.org/pipermail/gcc-patches/2022-December/607601.html
[Bug debug/98776] DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776 Sebastian Pop changed: What|Removed |Added CC||spop at gcc dot gnu.org --- Comment #9 from Sebastian Pop --- Hi, is somebody working on fixing this on arm64? If not I will be working on it. The linux kernel needs this fixed for systemtap and perf probe.
[Bug debug/98776] DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776 --- Comment #8 from Richard Biener --- (In reply to Martin Liška from comment #7) > Fixed on master with r11-1245-g3dcea658c9e2ac84. OK, so that's target specific then, thus aarch64 could still be broken. assemble_start_function is the one invoking the target hook (and eventually its default implementation) that emits the patchable area.
[Bug debug/98776] DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776 Martin Liška changed: What|Removed |Added Keywords|needs-bisection | --- Comment #7 from Martin Liška --- Fixed on master with r11-1245-g3dcea658c9e2ac84.
[Bug debug/98776] DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776 --- Comment #6 from Richard Biener --- (In reply to Martin Liška from comment #5) > (In reply to Richard Biener from comment #4) > > Martin, can you bisect what fixed it? > > Sure. Please help me how to verify what is a correct output? Isn't that > related to DWARF 5 change done in GCC 11? It's consistent with -gdwarf-2 -gstrict-dwarf as well, so no. A broken executable will output a short disassembly from gdb: > gcc-10 t.c -g -O -fpatchable-function-entry=16 > gdb -ex 'disassemble foo' -batch ./a.out | wc -l 3 actual output is Dump of assembler code for function foo: 0x004004a6 <+0>: ret End of assembler dump. where a correctly working one is > gdb -ex 'disassemble foo' -batch ./a.out | wc -l 19 with output Dump of assembler code for function foo: 0x00400476 <+0>: nop 0x00400477 <+1>: nop 0x00400478 <+2>: nop 0x00400479 <+3>: nop 0x0040047a <+4>: nop 0x0040047b <+5>: nop 0x0040047c <+6>: nop 0x0040047d <+7>: nop 0x0040047e <+8>: nop 0x0040047f <+9>: nop 0x00400480 <+10>:nop 0x00400481 <+11>:nop 0x00400482 <+12>:nop 0x00400483 <+13>:nop 0x00400484 <+14>:nop 0x00400485 <+15>:nop 0x00400486 <+16>:ret End of assembler dump.
[Bug debug/98776] DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776 --- Comment #5 from Martin Liška --- (In reply to Richard Biener from comment #4) > Martin, can you bisect what fixed it? Sure. Please help me how to verify what is a correct output? Isn't that related to DWARF 5 change done in GCC 11?
[Bug debug/98776] DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776 Richard Biener changed: What|Removed |Added CC||marxin at gcc dot gnu.org Keywords||needs-bisection --- Comment #4 from Richard Biener --- Martin, can you bisect what fixed it?
[Bug debug/98776] DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776
Richard Biener changed:
What|Removed |Added
Last reconfirmed||2021-06-30
Ever confirmed|0 |1
Known to work||11.1.0
CC||rguenth at gcc dot gnu.org
Known to fail||10.3.0
Target|x86,arm64 |x86_64-*-* aarch64
Status|UNCONFIRMED |NEW
--- Comment #3 from Richard Biener ---
Confirmed.
void __attribute__((noipa)) foo() { }
int main() { foo (); }
> gcc-10 t.c -g -fpatchable-function-entry=16 -O
> gdb ./a.out
GNU gdb (GDB; SUSE Linux Enterprise 15) 10.1
...
(gdb) disassemble foo
Dump of assembler code for function foo:
0x004004a6 <+0>: ret
End of assembler dump.
(gdb) b foo
Breakpoint 1 at 0x400496 (2 locations)
so the symbol is at 0x400496 but low-pc is 0x4004a6
On trunk the FDE start/end labels look correct:
foo:
.LFB0:
.cfi_startproc
.section__patchable_function_entries,"awo",@progbits,foo
.align 8
.quad .LPFE1
.text
.LPFE1:
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ret
.cfi_endproc
.LFE0:
and it seems to work there. Quick verification shows it works with GCC 11+
but fails with GCC 10 which has
foo:
.section__patchable_function_entries,"aw",@progbits
.align 8
.quad .LPFE1
.text
.LPFE1:
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
.LFB0:
.file 1 "t.c"
.loc 1 1 35 view -0
.cfi_startproc
.loc 1 1 37 view .LVU1
ret
.cfi_endproc
.LFE0:
.size foo, .-foo
[Bug debug/98776] DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776 Luis Machado changed: What|Removed |Added CC||luis.machado at linaro dot org --- Comment #2 from Luis Machado --- Confirmed on today's master (June 29th - 2021).
[Bug debug/98776] DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98776 Richard Earnshaw changed: What|Removed |Added CC||i at maskray dot me --- Comment #1 from Richard Earnshaw --- *** Bug 99836 has been marked as a duplicate of this bug. ***
