From: "H.J. Lu" <hjl.tools@gmail.com>
To: binutils@sourceware.org
Cc: gdb-patches@sourceware.org, Fangrui Song <maskray@google.com>
Subject: [gdb-11-branch: Patch 3/3] bfd_section_from_shdr: Support SHT_RELR sections
Date: Sun, 9 Jan 2022 09:45:04 -0800 [thread overview]
Message-ID: <20220109174504.1120244-4-hjl.tools@gmail.com> (raw)
In-Reply-To: <20220109174504.1120244-1-hjl.tools@gmail.com>
From: Fangrui Song <maskray@google.com>
If a.so contains an SHT_RELR section, objcopy a.so will fail with:
a.so: unknown type [0x13] section `.relr.dyn'
This change allows objcopy to work.
bfd/
* elf.c (bfd_section_from_shdr): Support SHT_RELR.
(cherry picked from commit a619b58721f0a03fd91c27670d3e4c2fb0d88f1e)
---
bfd/elf.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/bfd/elf.c b/bfd/elf.c
index 3d9c5ff03cc..985167fd85c 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -2358,16 +2358,22 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex)
case SHT_REL:
case SHT_RELA:
+ case SHT_RELR:
/* *These* do a lot of work -- but build no sections! */
{
asection *target_sect;
Elf_Internal_Shdr *hdr2, **p_hdr;
unsigned int num_sec = elf_numsections (abfd);
struct bfd_elf_section_data *esdt;
+ bfd_size_type size;
- if (hdr->sh_entsize
- != (bfd_size_type) (hdr->sh_type == SHT_REL
- ? bed->s->sizeof_rel : bed->s->sizeof_rela))
+ if (hdr->sh_type == SHT_REL)
+ size = bed->s->sizeof_rel;
+ else if (hdr->sh_type == SHT_RELA)
+ size = bed->s->sizeof_rela;
+ else
+ size = bed->s->arch_size / 8;
+ if (hdr->sh_entsize != size)
goto fail;
/* Check for a bogus link to avoid crashing. */
--
2.34.1
next prev parent reply other threads:[~2022-01-09 17:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-09 17:45 [gdb-11-branch: Patch 0/3] Support SHT_RELR (.relr.dyn) section H.J. Lu
2022-01-09 17:45 ` [gdb-11-branch: Patch 1/3] readelf: Support RELR in -S and -d and output H.J. Lu
2022-01-09 17:45 ` [gdb-11-branch: Patch 2/3] readelf: Support SHT_RELR/DT_RELR for -r H.J. Lu
2022-01-09 17:45 ` H.J. Lu [this message]
2022-01-10 2:44 ` [gdb-11-branch: Patch 0/3] Support SHT_RELR (.relr.dyn) section Simon Marchi
2022-01-10 13:03 ` H.J. Lu
2022-01-16 9:44 ` Joel Brobecker
2022-01-16 10:21 ` Joel Brobecker
2022-01-16 13:30 ` H.J. Lu
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=20220109174504.1120244-4-hjl.tools@gmail.com \
--to=hjl.tools@gmail.com \
--cc=binutils@sourceware.org \
--cc=gdb-patches@sourceware.org \
--cc=maskray@google.com \
/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).