https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108622
Bug ID: 108622 Summary: x86 -fno-pic: use DW_EH_PE_indirect|DW_EH_PE_pcrel for personality/ttype encoding Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: i at maskray dot me Target Milestone: --- 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