bfd_section_from_shdr: Support SHT_RELR sections
authorFangrui Song <maskray@google.com>
Wed, 8 Dec 2021 02:24:14 +0000 (18:24 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Mon, 10 Jan 2022 13:05:22 +0000 (05:05 -0800)
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

index 3d9c5ff03cc9f63807430cdfdc104d179c437da9..985167fd85c8a1bb164e08dce282bdcc818e5f76 100644 (file)
--- 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.  */
This page took 0.027332 seconds and 4 git commands to generate.