From: Jan Beulich <jbeulich@suse.com>
To: Binutils <binutils@sourceware.org>
Subject: [PATCH v2 2/3] x86-64/ELF: use new reloc override model to deal with x32 special case
Date: Fri, 4 Mar 2022 14:35:21 +0100 [thread overview]
Message-ID: <ac776cb8-e4bf-fbe8-c062-8ea8243a3368@suse.com> (raw)
In-Reply-To: <af880e85-7b81-b9b5-e914-95ce9e317565@suse.com>
Fold the two custom adjustments into a single new case block in
elf_x86_64_reloc_override().
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -185,12 +185,13 @@ static reloc_howto_type x86_64_elf_howto
HOWTO (R_X86_64_GNU_VTENTRY, 0, 4, 0, false, 0, complain_overflow_dont,
_bfd_elf_rel_vtable_reloc_fn, "R_X86_64_GNU_VTENTRY", false, 0, 0,
false),
+};
/* Use complain_overflow_bitfield on R_X86_64_32 for x32. */
+static reloc_howto_type x86_64_howto_32_x32 =
HOWTO(R_X86_64_32, 0, 2, 32, false, 0, complain_overflow_bitfield,
bfd_elf_generic_reloc, "R_X86_64_32", false, 0, 0xffffffff,
- false)
-};
+ false);
static reloc_howto_type x86_64_howto_pc32_lax =
HOWTO(R_X86_64_PC32, 0, 2, 32, true, 0, complain_overflow_bitfield,
@@ -266,6 +267,11 @@ elf_x86_64_reloc_override (const bfd *ab
default:
break;
+ case R_X86_64_32:
+ if (ABI_64_P (abfd))
+ break;
+ return &x86_64_howto_32_x32;
+
case R_X86_64_PC32:
if (params == NULL || params->pcrel_relocs != pcrel_relocs_lax)
break;
@@ -285,15 +291,8 @@ elf_x86_64_rtype_to_howto (bfd *abfd, un
{
unsigned i;
- if (r_type == (unsigned int) R_X86_64_32)
- {
- if (ABI_64_P (abfd))
- i = r_type;
- else
- i = ARRAY_SIZE (x86_64_elf_howto_table) - 1;
- }
- else if (r_type < (unsigned int) R_X86_64_GNU_VTINHERIT
- || r_type >= (unsigned int) R_X86_64_max)
+ if (r_type < (unsigned int) R_X86_64_GNU_VTINHERIT
+ || r_type >= (unsigned int) R_X86_64_max)
{
if (r_type >= (unsigned int) R_X86_64_standard)
{
@@ -334,15 +333,6 @@ elf_x86_64_reloc_name_lookup (bfd *abfd,
{
unsigned int i;
- if (!ABI_64_P (abfd) && strcasecmp (r_name, "R_X86_64_32") == 0)
- {
- /* Get x32 R_X86_64_32. */
- reloc_howto_type *reloc
- = &x86_64_elf_howto_table[ARRAY_SIZE (x86_64_elf_howto_table) - 1];
- BFD_ASSERT (reloc->type == (unsigned int) R_X86_64_32);
- return reloc;
- }
-
for (i = 0; i < ARRAY_SIZE (x86_64_elf_howto_table); i++)
if (x86_64_elf_howto_table[i].name != NULL
&& strcasecmp (x86_64_elf_howto_table[i].name, r_name) == 0)
next prev parent reply other threads:[~2022-03-04 13:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-04 13:33 [PATCH v2 0/3] x86: another take at PC-relative reloc overflow checking Jan Beulich
2022-03-04 13:34 ` [PATCH v2 1/3] x86-64/ELF: permit relaxed overflow checking for 32-bit PC-relative relocs Jan Beulich
2022-03-04 14:18 ` H.J. Lu
2022-03-09 8:21 ` Jan Beulich
2022-03-09 14:27 ` H.J. Lu
2022-03-09 14:38 ` Jan Beulich
2022-03-09 15:08 ` H.J. Lu
2022-03-09 15:17 ` Jan Beulich
2022-03-09 15:32 ` H.J. Lu
2022-03-09 15:41 ` Jan Beulich
2022-03-09 15:54 ` H.J. Lu
2022-03-09 16:49 ` Jan Beulich
2022-03-09 18:11 ` H.J. Lu
2022-03-04 13:35 ` Jan Beulich [this message]
2022-03-04 13:35 ` [PATCH v2 3/3] x86/ELF: permit correct overflow checking for 16-bit " Jan Beulich
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=ac776cb8-e4bf-fbe8-c062-8ea8243a3368@suse.com \
--to=jbeulich@suse.com \
--cc=binutils@sourceware.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).