public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug debug/98776] New: DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry
@ 2021-01-21  6:32 lvlin at mail dot ustc.edu.cn
  2021-03-31 10:21 ` [Bug debug/98776] " rearnsha at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: lvlin at mail dot ustc.edu.cn @ 2021-01-21  6:32 UTC (permalink / raw)
  To: gcc-bugs

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

            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 
        $ gcc -o toy_exam.gcc toy_exam.c  -g -gdwarf-4
-fpatchable-function-entry=2 -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 \<fun_a\>:
00000000000007f0 <fun_a>:
 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=gcc
COLLECT_LTO_WRAPPER=/usr/gcc-trunk/libexec/gcc/aarch64-unknown-linux-gnu/11.0.0/lto-wrapper
Target: aarch64-unknown-linux-gnu
Configured with: ../gcc/configure --prefix=/usr/gcc-trunk
--enable-languages=c,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.

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-12-15 15:15 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21  6:32 [Bug debug/98776] New: DW_AT_low_pc is inconsistent with function entry address, when enabling -fpatchable-function-entry lvlin at mail dot ustc.edu.cn
2021-03-31 10:21 ` [Bug debug/98776] " rearnsha at gcc dot gnu.org
2021-06-29 17:06 ` luis.machado at linaro dot org
2021-06-30  6:28 ` rguenth at gcc dot gnu.org
2021-06-30  6:28 ` rguenth at gcc dot gnu.org
2021-06-30  7:12 ` marxin at gcc dot gnu.org
2021-06-30  8:06 ` rguenth at gcc dot gnu.org
2021-06-30  8:20 ` marxin at gcc dot gnu.org
2021-06-30  8:27 ` rguenth at gcc dot gnu.org
2022-09-29 20:50 ` spop at gcc dot gnu.org
2022-12-01  3:11 ` spop at gcc dot gnu.org
2022-12-08 17:12 ` cvs-commit at gcc dot gnu.org
2022-12-15 15:08 ` cvs-commit at gcc dot gnu.org
2022-12-15 15:10 ` cvs-commit at gcc dot gnu.org
2022-12-15 15:12 ` cvs-commit at gcc dot gnu.org
2022-12-15 15:15 ` spop at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).