From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DBF8F3851C35; Thu, 21 Jan 2021 06:32:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DBF8F3851C35 From: "lvlin at mail dot ustc.edu.cn" To: gcc-bugs@gcc.gnu.org Subject: [Bug debug/98776] New: DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry Date: Thu, 21 Jan 2021 06:32:16 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: debug X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: lvlin at mail dot ustc.edu.cn X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone cf_gcctarget Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Jan 2021 06:32:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98776 Bug ID: 98776 Summary: DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: debug Assignee: unassigned at gcc dot gnu.org Reporter: lvlin at mail dot ustc.edu.cn Target Milestone: --- Target: x86,arm64 -fpatchable-function-entry will generate N NOPs at the beginning of each function. Observe the binary compiled by gcc, the function entry address is inconsistent with the value of DW_AT_low_pc in the corresponding DWARF data. I used a toy example to describe the issue; 1.Compile the source file toy_exam.c=20 $ gcc -o toy_exam.gcc toy_exam.c -g -gdwarf-4 -fpatchable-function-entry=3D2 -save-temps 2.Check the symbolic address of the function fun_a $ readelf -s toy_exam.gcc |grep -w fun_a 95: 00000000000007f0 80 FUNC GLOBAL DEFAULT 13 fun_a 3.Display assembler contents objdump -d toy_exam.gcc |grep -A 8 -w \: 00000000000007f0 : 7f0: d503201f nop 7f4: d503201f nop 7f8: a9be7bfd stp x29, x30, [sp, #-32]! 7fc: 910003fd mov x29, sp 800: 52800040 mov w0, #0x2 // #2 804: b90017e0 str w0, [sp, #20] 808: 528000a0 mov w0, #0x5 // #5 80c: b9001be0 str w0, [sp, #24] 4.dump dwarf info $ llvm-dwarfdump toy_exam.gcc |grep -C 10 -w fun_a 0x00000315: DW_TAG_subprogram DW_AT_external (true) DW_AT_name ("fun_a") DW_AT_decl_file ("/home/jianlin/code/test/toy_exam.c") DW_AT_decl_line (14) DW_AT_decl_column (0x06) DW_AT_low_pc (0x00000000000007f8) DW_AT_high_pc (0x0000000000000840) DW_AT_frame_base (DW_OP_call_frame_cfa) DW_AT_GNU_all_tail_call_sites (true) DW_AT_sibling (0x0000035d) 5. Assembler code fun_a: .section __patchable_function_entries .8byte .LPFE2 .text .LPFE2: nop nop .LFB7: .loc 1 15 1 .cfi_startproc stp x29, x30, [sp, -32]! .cfi_def_cfa_offset 32 .cfi_offset 29, -32 .cfi_offset 30, -24 mov x29, sp .loc 1 16 13 $ gcc -v Using built-in specs. COLLECT_GCC=3Dgcc COLLECT_LTO_WRAPPER=3D/usr/gcc-trunk/libexec/gcc/aarch64-unknown-linux-gnu/= 11.0.0/lto-wrapper Target: aarch64-unknown-linux-gnu Configured with: ../gcc/configure --prefix=3D/usr/gcc-trunk --enable-languages=3Dc,c++,fortran --disable-libquadmath --disable-libquadmath-support --disable-werror --disable-bootstrap --enable-gold Thread model: posix Supported LTO compression algorithms: zlib gcc version 11.0.0 20210119 (experimental) (GCC) the first instruction in the compile unit indicated by DW_AT_low_pc does not include NOP. GCC-9, GCC-10 and the latest master branch were respectively tested, and the results were the same.=