After resolving bug #2225 the `objdump` and other binutils can't recognize a Cisco ELF object files. The `readelf` works fine. $ mips-unknown-elf-readelf.exe -v GNU readelf 2.16.91.0.5 20051219 $ mips-unknown-elf-objdump.exe -x c3640-is-mz.120-28a.bin mips-unknown-elf-objdump: c3640-is-mz.120-28a.bin: File format not recognized readelf : $ mips-unknown-elf-readelf.exe -a c3640-is-mz.120-28a.bin ELF Header: Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, big endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: <unknown>: 1e Version: 0x1 Entry point address: 0x80008000 Start of program headers: 52 (bytes into file) Start of section headers: 84 (bytes into file) Flags: 0x20000001 Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 1 Size of section headers: 40 (bytes) Number of section headers: 5 Section header string table index: 8 Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] <corrupt> PROGBITS 80008000 00011c 004000 00 AX 0 0 8 [ 1] <corrupt> PROGBITS 8000c000 00411c 000700 00 A 0 0 4 [ 2] <corrupt> PROGBITS 8000c700 00481c 0002e0 00 WA 0 0 4 [ 3] <corrupt> PROGBITS 8000c9e0 004afc 0000a0 00 WAp 0 0 8 [ 4] <corrupt> PROGBITS 8000ca80 004b9c 52e098 00 WAp 0 0 8 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings) I (info), L (link order), G (group), x (unknown) O (extra OS processing required) o (OS specific), p (processor specific) There are no section groups in this file. Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x00011c 0x80008000 0x80008000 0x532b18 0x55afc0 RWE 0x11c There is no dynamic section in this file. There are no relocations in this file. There are no unwind sections in this file. No version information found in this file.
may be #1219 depends on this, too
It looks like c3640-is-mz.120-28a.bin is corrupted. Can you upload it?
This file is good for CISCO and works just fine. Unfortunately, I can't upload it due to (c) issue. As far as I understand, this file is *very* simplified MIPS ELF and has no .shstrtab section at all (only bare ELF headers). So, all ELF sections are nameless. See a `readelf` output. Is it possible to use Binutils with such files ?
Hi Alec, Please could you try the uploaded patch. The problem is that the binary you have is corrupt. The e_shstrndx field in the ELF header is wrong. It says that the string table is held in section 8, but there is no section 8 in the object file! The patch updates the BFD library so that it can cope more gracefully with this sort of broken binary, and it also updates readelf to detect this kind of error and report it to the user. With the patch applied I get this result from running "objdump -p" on your test file: BFD: warning: C3640-IS.BIN has a corrupt string table index - ignoring C3640-IS.BIN: file format elf32-big Program Header: LOAD off 0x000000f4 vaddr 0x80008000 paddr 0x80008000 align 2**7 filesz 0x00d7e8e0 memsz 0x00e664c0 flags rwx and this result from running "readelf -h -S": ELF Header: Magic: 7f 45 4c 46 01 02 01 00 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, big endian Version: 1 (current) OS/ABI: UNIX - System V ABI Version: 0 Type: EXEC (Executable file) Machine: <unknown>: 1e Version: 0x1 Entry point address: 0x80008000 Start of program headers: 52 (bytes into file) Start of section headers: 84 (bytes into file) Flags: 0x10000001 Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 1 Size of section headers: 40 (bytes) Number of section headers: 4 Section header string table index: 8 <corrupt: out of range> Section Headers: [Nr] Name Type Addr Off Size ES Flg Lk Inf Al [ 0] <no-name> PROGBITS 80008000 0000f4 9a2000 00 AX 0 0 64 [ 1] <no-name> PROGBITS 809aa000 9a20f4 390e20 00 A 0 0 8 [ 2] <no-name> PROGBITS 80d3ae20 d32f14 044f00 00 WA 0 0 8 [ 3] <no-name> PROGBITS 80d7fd20 d77e14 006bc0 Note - do you know what type of architecture the 0x1e value in the e_machine field of the ELF header represents ? If so we could add it to the list of known values so that readelf can identify it. Cheers Nick
Created attachment 896 [details] Better handling of ELF object files with corrupt string indicies
Fixed by http://sourceware.org/ml/binutils/2006-04/msg00221.html