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

            Bug ID: 113675
           Summary: %p modifier doesn't work with PIC
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
                CC: ubizjak at gmail dot com
  Target Milestone: ---
            Target: x86-64

[hjl@gnu-cfl-3 kso-1]$ cat foo.c
extern int key;

void
foo (void)
{
  asm (".pushsection __jump_table,\"aw\"\n\
        .quad %p0\n\
        .popsection" :: "g" (&key));
}
[hjl@gnu-cfl-3 kso-1]$ make CC=gcc
gcc -O2 -fPIC -S foo.c
gcc -O2 -fPIC -c foo.s
foo.c: Assembler messages:
foo.c:7: Error: junk at end of line, first unrecognized character is `('
make: *** [Makefile:25: foo.o] Error 1
[hjl@gnu-cfl-3 kso-1]$ cat foo.s
        .file   "foo.c"
        .text
        .p2align 4
        .globl  foo
        .type   foo, @function
foo:
.LFB0:
        .cfi_startproc
#APP
# 6 "foo.c" 1
        .pushsection __jump_table,"aw"
        .quad key@GOTPCREL(%rip)
        .popsection
# 0 "" 2
#NO_APP
        ret
        .cfi_endproc
.LFE0:
        .size   foo, .-foo
        .ident  "GCC: (GNU) 13.2.1 20231205 (Red Hat 13.2.1-6)"
        .section        .note.GNU-stack,"",@progbits
[hjl@gnu-cfl-3 kso-1]$ 

I was expecting

  p -- print raw symbol name.

to work with PIC.

Reply via email to