From: Fangrui Song <maskray@google.com>
To: gcc-patches@gcc.gnu.org
Cc: Fangrui Song <maskray@google.com>
Subject: [PATCH] x86: Use DW_EH_PE_indirect|DW_EH_PE_pcrel encodings for -fno-pic code
Date: Tue, 31 Jan 2023 23:38:59 -0800 [thread overview]
Message-ID: <20230201073859.3920910-1-maskray@google.com> (raw)
Follow aarch64 and riscv ports by using (global ? DW_EH_PE_indirect : 0)
| DW_EH_PE_pcrel for -fno-pic code. This avoids a canonical PLT entry
for a personality reference in .eh_frame and a copy relocation for a
typeinfo reference in .gcc_except_table, when the definition is in
libstdc++.so.6.
gcc/
PR target/108622
* config/i386/i386.cc (asm_preferred_eh_data_format): Always use the
PIC encoding. Use DW_EH_PE_indirect if global.
---
gcc/config/i386/i386.cc | 23 +++++++----------------
1 file changed, 7 insertions(+), 16 deletions(-)
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 3cacf738c4a..b572dd46a62 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -22851,22 +22851,13 @@ ix86_stack_protect_fail (void)
int
asm_preferred_eh_data_format (int code, int global)
{
- /* PE-COFF is effectively always -fPIC because of the .reloc section. */
- if (flag_pic || TARGET_PECOFF || !ix86_direct_extern_access)
- {
- int type = DW_EH_PE_sdata8;
- if (ptr_mode == SImode
- || ix86_cmodel == CM_SMALL_PIC
- || (ix86_cmodel == CM_MEDIUM_PIC && (global || code)))
- type = DW_EH_PE_sdata4;
- return (global ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | type;
- }
-
- if (ix86_cmodel == CM_SMALL
- || (ix86_cmodel == CM_MEDIUM && code))
- return DW_EH_PE_udata4;
-
- return DW_EH_PE_absptr;
+ int type = DW_EH_PE_sdata8;
+ if (ptr_mode == SImode || ix86_cmodel == CM_SMALL ||
+ ix86_cmodel == CM_SMALL_PIC ||
+ (ix86_cmodel == CM_MEDIUM && code) ||
+ (ix86_cmodel == CM_MEDIUM_PIC && (global || code)))
+ type = DW_EH_PE_sdata4;
+ return (global ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | type;
}
\f
/* Implement targetm.vectorize.builtin_vectorization_cost. */
--
2.39.1.456.gfc5497dd1b-goog
next reply other threads:[~2023-02-01 7:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 7:38 Fangrui Song [this message]
2023-02-01 9:01 ` Jakub Jelinek
2023-02-01 9:09 ` Jakub Jelinek
2023-02-02 5:50 ` Fangrui Song
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230201073859.3920910-1-maskray@google.com \
--to=maskray@google.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).