public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/101726] New: target_clone resolver does not generate PIC despite -fPIC
@ 2021-08-02 16:29 stefan.kneifel at bluewin dot ch
  2021-08-03 11:54 ` [Bug target/101726] " marxin at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: stefan.kneifel at bluewin dot ch @ 2021-08-02 16:29 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101726
           Summary: target_clone resolver does not generate PIC despite
                    -fPIC
           Product: gcc
           Version: 11.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: stefan.kneifel at bluewin dot ch
  Target Milestone: ---

Created attachment 51243
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51243&action=edit
Testcase: compile with -Os -fPIC

When compiling code using target_clones with -fPIC, the automatically generated
resolver refers to all the explicit targets correctly using
R_X86_64_REX_GOTPCRELX, whereas it refers to the default target incorrectly
using R_X86_64_PC32, resulting in an object file not linkable into a shared
library.

Compile the attached test.ii with:
gcc -Os -pipe -fPIC -c test.ii

and disassemble the output with:
objdump -rd test.o

--------------------------------------------
test.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <_Z3barv>:
   0:   e9 00 00 00 00          jmpq   5 <_Z3barv+0x5>
                        1: R_X86_64_PLT32       _Z3foov-0x4

Disassembly of section .text._Z3foov.resolver:

0000000000000000 <_Z3foov.resolver>:
   0:   51                      push   %rcx
   1:   e8 00 00 00 00          callq  6 <_Z3foov.resolver+0x6>
                        2: R_X86_64_PLT32       __cpu_indicator_init-0x4
   6:   48 8b 05 00 00 00 00    mov    0x0(%rip),%rax        # d
<_Z3foov.resolver+0xd>
                        9: R_X86_64_REX_GOTPCRELX       __cpu_model-0x4
   d:   8b 50 0c                mov    0xc(%rax),%edx
  10:   0f ba e2 0f             bt     $0xf,%edx
  14:   73 09                   jae    1f <_Z3foov.resolver+0x1f>
  16:   48 8b 05 00 00 00 00    mov    0x0(%rip),%rax        # 1d
<_Z3foov.resolver+0x1d>
                        19: R_X86_64_REX_GOTPCRELX      _Z3foov.avx512f.0-0x4
  1d:   eb 23                   jmp    42 <_Z3foov.resolver+0x42>
  1f:   0f ba e2 0a             bt     $0xa,%edx
  23:   73 09                   jae    2e <_Z3foov.resolver+0x2e>
  25:   48 8b 05 00 00 00 00    mov    0x0(%rip),%rax        # 2c
<_Z3foov.resolver+0x2c>
                        28: R_X86_64_REX_GOTPCRELX      _Z3foov.avx2.1-0x4
  2c:   eb 14                   jmp    42 <_Z3foov.resolver+0x42>
  2e:   0f ba e2 09             bt     $0x9,%edx
  32:   48 8d 05 00 00 00 00    lea    0x0(%rip),%rax        # 39
<_Z3foov.resolver+0x39>
                        35: R_X86_64_PC32       _Z3foov.default.3-0x4
  39:   73 07                   jae    42 <_Z3foov.resolver+0x42>
  3b:   48 8b 05 00 00 00 00    mov    0x0(%rip),%rax        # 42
<_Z3foov.resolver+0x42>
                        3e: R_X86_64_REX_GOTPCRELX      _Z3foov.avx.2-0x4
  42:   5a                      pop    %rdx
  43:   c3                      retq   
--------------------------------------------

This should be consistent, and _Z3foov.default.3 should also be read from the
GOT.

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

end of thread, other threads:[~2021-08-16 11:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-02 16:29 [Bug c/101726] New: target_clone resolver does not generate PIC despite -fPIC stefan.kneifel at bluewin dot ch
2021-08-03 11:54 ` [Bug target/101726] " marxin at gcc dot gnu.org
2021-08-03 16:42 ` stefan.kneifel at bluewin dot ch
2021-08-11 11:47 ` marxin at gcc dot gnu.org
2021-08-11 20:02 ` stefan.kneifel at bluewin dot ch
2021-08-12 13:53 ` marxin at gcc dot gnu.org
2021-08-12 15:33 ` [Bug ipa/101726] " marxin at gcc dot gnu.org
2021-08-13 14:10 ` stefan.kneifel at bluewin dot ch
2021-08-16  7:53 ` cvs-commit at gcc dot gnu.org
2021-08-16  7:55 ` marxin at gcc dot gnu.org
2021-08-16 11:14 ` cvs-commit at gcc dot gnu.org
2021-08-16 11:16 ` marxin 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).