Through an accident Fedora rawhide created various ELF files with thousands of sections. This showed various issues in libelf, libdw and some of the elfutils tools. When an ELF file has more than SHN_LORESERVE (0xff00, 65280) sections then the Ehdr e_shnum and e_shshstrndx fields are too small to hold the section number directly. They will then be stored in the Shdr sh_info and sh_link fields of section zero. The following patches make sure the correct values are read and setup. Various test cases have been added that create files with ten thousand sections to check everything works as expected.
[PATCH 01/10] backends: Always use elf_getshdrstrndx in check_special_symbol [PATCH 02/10] backends: Use elf_getshdrstrndx to find .odp section in ppc64_init [PATCH 03/10] libebl: Use elf_getshdrstrndx in ebl_section_strip_p [PATCH 04/10] elfcmp: Get, check and shdrstrndx for section names [PATCH 05/10] libelf: Fix shnum and section zero handling [PATCH 06/10] elflint: Use shnum and shstrndx instead of ehdr field directly [PATCH 07/10] libdw: dwarf_begin_elf should use elf_getshdrstrndx to get names [PATCH 08/10] strip,unstrip: Use and set shdrstrndx consistently [PATCH 09/10] readelf: Use elf_getshdrnum in print_shdr and print_phdr [PATCH 10/10] libdwfl: Document core memory and remote memory ELF shdrs reading