Bug 108622 - x86 -fno-pic: use DW_EH_PE_indirect|DW_EH_PE_pcrel for personality/ttype encoding
Summary: x86 -fno-pic: use DW_EH_PE_indirect|DW_EH_PE_pcrel for personality/ttype enco...
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 13.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-02-01 06:58 UTC by Fangrui Song
Modified: 2023-09-18 20:55 UTC (History)
0 users

See Also:
Host:
Target: i386* x86_64*
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fangrui Song 2023-02-01 06:58:44 UTC
In .eh_frame and .gcc_except_table, the aarch64 and riscv ports use DW_EH_PE_indirect|DW_EH_PE_pcrel for both -fno-pic and PIC code to avoid canonical PLT entry/copy relocation, if the personality and typeinfo objects are defined in a shared object (common case, libstdc++.so.6 or libc++.so.?).

AIUI there is no drawback other than a negligible size increase.

% g++ -fno-pic -no-pie -fuse-ld=bfd a.cc -o a
% readelf -Wr a | grep COPY
0000000000403db8  0000000900000005 R_X86_64_COPY          0000000000403db8 _ZTIi@CXXABI_1.3 + 0
0000000000403dc8  0000000800000005 R_X86_64_COPY          0000000000403dc8 _ZTIPKc@CXXABI_1.3 + 0
% readelf -W --dyn-syms a | grep __gxx_personality_v
    10: 0000000000401060     0 FUNC    GLOBAL DEFAULT  UND __gxx_personality_v0@CXXABI_1.3 (2)

% g++ -fpic -no-pie -fuse-ld=bfd a.cc -o a
% readelf -Wr a | grep COPY
% readelf -W --dyn-syms a | grep __gxx_personality_v0
     7: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __gxx_personality_v0@CXXABI_1.3 (2)

Essentially this applies -mno-direct-extern-access unconditionally to -fno-pic, cleaning up gcc/config/i386/i386.cc:asm_preferred_eh_data_format
Comment 1 Fangrui Song 2023-02-01 07:39:40 UTC
https://gcc.gnu.org/pipermail/gcc-patches/2023-February/611081.html [PATCH] x86: Use DW_EH_PE_indirect|DW_EH_PE_pcrel encodings for -fno-pic code