diff options
author | Fangrui Song <maskray@google.com> | 2021-12-07 18:24:14 -0800 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2022-01-10 05:05:22 -0800 |
commit | fb0b83d80d11c2501a9262198f26a820b09f5258 (patch) | |
tree | 8a636fd6eaee8a6ab83f2b9ecc026ed3d4081f7f | |
parent | 67609c9c701ea8a679d80e3352266b058b184f4b (diff) | |
download | gdb-fb0b83d80d11c2501a9262198f26a820b09f5258.zip gdb-fb0b83d80d11c2501a9262198f26a820b09f5258.tar.gz gdb-fb0b83d80d11c2501a9262198f26a820b09f5258.tar.bz2 |
bfd_section_from_shdr: Support SHT_RELR sections
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)
-rw-r--r-- | bfd/elf.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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. */ |