[Bug lto/104617] Bug in handling of 64k+ sections

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Feb 21 20:04:18 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104617

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Untested fix:
2022-02-21  Jakub Jelinek  <jakub@redhat.com>

        PR lto/104617
        * simple-object-elf.c (simple_object_elf_match): Fix up URL
        in comment.
        (simple_object_elf_copy_lto_debug_sections): Remap sh_info and
        sh_link even if they are in the SHN_LORESERVE .. SHN_HIRESERVE
        range (inclusive).

--- libiberty/simple-object-elf.c.jj    2022-01-11 23:11:23.967267993 +0100
+++ libiberty/simple-object-elf.c       2022-02-21 20:37:12.815202845 +0100
@@ -528,7 +528,7 @@ simple_object_elf_match (unsigned char h
             not handle objects with more than SHN_LORESERVE sections
             correctly.  All large section indexes were offset by
             0x100.  There is more information at
-            http://sourceware.org/bugzilla/show_bug.cgi?id-5900 .
+            http://sourceware.org/bugzilla/show_bug.cgi?id=5900 .
             Fortunately these object files are easy to detect, as the
             GNU binutils always put the section header string table
             near the end of the list of sections.  Thus if the
@@ -1559,17 +1559,13 @@ simple_object_elf_copy_lto_debug_section
          {
            sh_info = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
                                       shdr, sh_info, Elf_Word);
-           if (sh_info < SHN_LORESERVE
-               || sh_info > SHN_HIRESERVE)
-             sh_info = sh_map[sh_info];
+           sh_info = sh_map[sh_info];
            ELF_SET_FIELD (type_functions, ei_class, Shdr,
                           shdr, sh_info, Elf_Word, sh_info);
          }
        sh_link = ELF_FETCH_FIELD (type_functions, ei_class, Shdr,
                                   shdr, sh_link, Elf_Word);
-       if (sh_link < SHN_LORESERVE
-           || sh_link > SHN_HIRESERVE)
-         sh_link = sh_map[sh_link];
+       sh_link = sh_map[sh_link];
        ELF_SET_FIELD (type_functions, ei_class, Shdr,
                       shdr, sh_link, Elf_Word, sh_link);
       }

SHN_LORESERVE .. SHN_HIRESERVE is something only relevant for the 16-bit field,
i.e. st_shndx, e_shnum and e_shstrndx.  The latter two are moved to sh_size and
sh_link of the shdr[0], the first one into .symtab_shndx section.


More information about the Gcc-bugs mailing list