PATCH: PR binutils/6412: New binutils is incompatible with old object files

H.J. Lu
Sat Apr 19 01:17:00 GMT 2008


This is the patch for readelf to handle old object files. It checks if
one of sh_link in section header table >= number of sections. It
works on object files generated by GNU assembler and linker
since they put the .strtab section at the end of section header

I will use the similar approach in bfd. I think gold should also
support old object files.

2008-04-18  H.J. Lu  <>

        PR binutils/6412
        * readelf.c (hole_in_shndx): New.
        (original_shndx_info): Likewise.
        (original_shndx): Likewise.
        (SECTION_HEADER_INDEX_GAP): Likewise.
        (process_file_header): Move ELF magic bytes check to ...
        (get_file_header): Here.
        (get_32bit_section_headers): Set hole_in_shndx if sh_link
        >= number of sections.
        (get_64bit_section_headers): Likewise.
        (get_32bit_elf_symbols): Adjust st_shndx if hole_in_shndx
        isn't 0.
        (get_64bit_elf_symbols): Likewise.
        (process_section_headers): Adjust elf_header.e_shstrndx,
        sh_link and sh_info, save original sh_link and sh_info,
        display adjustment for sh_link and sh_info if hole_in_shndx
        isn't 0.
        (process_section_groups): Adjust member section index if
        hole_in_shndx isn't 0.
        (process_object): Free original_shndx if needed.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 64k.txt
URL: <>

More information about the Binutils mailing list