Summary: | DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry | ||
---|---|---|---|
Product: | gcc | Reporter: | JianlinLv <lvlin> |
Component: | debug | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | daniel.kiss, i, luis.machado, marxin, ndesaulniers, rguenth, spop, wcohen |
Priority: | P3 | ||
Version: | 11.0 | ||
Target Milestone: | --- | ||
Host: | Target: | x86_64-*-* aarch64 | |
Build: | Known to work: | 11.1.0 | |
Known to fail: | 10.3.0 | Last reconfirmed: | 2021-06-30 00:00:00 |
Description
JianlinLv
2021-01-21 06:32:16 UTC
*** Bug 99836 has been marked as a duplicate of this bug. *** Confirmed on today's master (June 29th - 2021). 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:
0x00000000004004a6 <+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
Martin, can you bisect what fixed it? (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? (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: 0x00000000004004a6 <+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: 0x0000000000400476 <+0>: nop 0x0000000000400477 <+1>: nop 0x0000000000400478 <+2>: nop 0x0000000000400479 <+3>: nop 0x000000000040047a <+4>: nop 0x000000000040047b <+5>: nop 0x000000000040047c <+6>: nop 0x000000000040047d <+7>: nop 0x000000000040047e <+8>: nop 0x000000000040047f <+9>: nop 0x0000000000400480 <+10>: nop 0x0000000000400481 <+11>: nop 0x0000000000400482 <+12>: nop 0x0000000000400483 <+13>: nop 0x0000000000400484 <+14>: nop 0x0000000000400485 <+15>: nop 0x0000000000400486 <+16>: ret End of assembler dump. Fixed on master with r11-1245-g3dcea658c9e2ac84. (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. 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. Patch for arm64: https://gcc.gnu.org/pipermail/gcc-patches/2022-December/607601.html The master branch has been updated by Sebastian Pop <spop@gcc.gnu.org>: https://gcc.gnu.org/g:09c91caeb84e7c3609a12a53b57e5219a1dd2b15 commit r13-4561-g09c91caeb84e7c3609a12a53b57e5219a1dd2b15 Author: Sebastian Pop <spop@amazon.com> Date: Wed Nov 30 19:45:24 2022 +0000 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. The releases/gcc-10 branch has been updated by Sebastian Pop <spop@gcc.gnu.org>: https://gcc.gnu.org/g:59bba6f9dc6dcfefe96e6fad677614f39928564e commit r10-11122-g59bba6f9dc6dcfefe96e6fad677614f39928564e Author: Sebastian Pop <spop@amazon.com> Date: Wed Nov 30 19:45:24 2022 +0000 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. The releases/gcc-11 branch has been updated by Sebastian Pop <spop@gcc.gnu.org>: https://gcc.gnu.org/g:50f7161448a19c4fa355c7c652e26b47ceb36cc4 commit r11-10422-g50f7161448a19c4fa355c7c652e26b47ceb36cc4 Author: Sebastian Pop <spop@amazon.com> Date: Wed Nov 30 19:45:24 2022 +0000 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. The releases/gcc-12 branch has been updated by Sebastian Pop <spop@gcc.gnu.org>: https://gcc.gnu.org/g:7525c9d7e72ac3818e08fe7aa98396bd41e4ec8c commit r12-8987-g7525c9d7e72ac3818e08fe7aa98396bd41e4ec8c Author: Sebastian Pop <spop@amazon.com> Date: Wed Nov 30 19:45:24 2022 +0000 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. Fixed for arm64 as well on master, and backported to active branches gcc-12, 11, and 10. |