Cheb57 / binutils-tricore

GNU/binutils revision 2.13 targetting Infineon tricore CPU architecture
GNU General Public License v2.0
20 stars 10 forks source link

readelf prints "Not an ELF file" #3

Closed karsten-burger closed 3 years ago

karsten-burger commented 3 years ago

Hi, I have two binaries for running with Infineon TriCore 1797.

when running the command tricore-readelf.exe -h <binary> I get the message: readelf: Error: Not an ELF file - it has the wrong magic bytes at the start

With tricore-objdump.exe -i I get some results, like

BFD header file version 2.13 elf32-tricore (header little endian, data little endian) TriCore:Rider-B ieee (header endianness unknown, data endianness unknown) TriCore:Rider-B elf32-little (header little endian, data little endian) TriCore:Rider-B elf32-big (header big endian, data big endian) TriCore:Rider-B srec (header endianness unknown, data endianness unknown) TriCore:Rider-B symbolsrec (header endianness unknown, data endianness unknown) TriCore:Rider-B tekhex (header endianness unknown, data endianness unknown) TriCore:Rider-B binary (header endianness unknown, data endianness unknown) TriCore:Rider-B ihex (header endianness unknown, data endianness unknown) TriCore:Rider-B elf32-tricore ieee elf32-little elf32-big srec symbolsrec TriCore:Rider-B elf32-tricore ieee elf32-little elf32-big srec symbolsrec tekhex binary ihex TriCore:Rider-B tekhex binary ihex>

The binary is not very recent, created about 2014. What is wrong?

Cheb57 commented 3 years ago

Hello,

It seems that your elf file is not recognized correctly due to wrong magic keys numbers into the header.

If you have got a msys or cygwin shell available on Windows, could you please simply run firstly a 'file ' command?

You should get for the TC1797 CPU an elf32-tricore file format.

Using binutils toolchains here with a valid elf file should indicate:

$ ./tricore-readelf.exe -e example.elf | head n20 ELF Header:   Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00   Class:                             ELF32   Data:                              2's complement, little endian   Version:                           1 (current)   OS/ABI:                            UNIX - System V   ABI Version:                       0   Type:                              EXEC (Executable file)   Machine:                           Siemens Tricore   Version:                           0x1   Entry point address:               0xa0000000   Start of program headers:          52 (bytes into file)   Start of section headers:          8124672 (bytes into file)   Flags:                             0x800000   Size of this header:               52 (bytes)   Size of program headers:           32 (bytes)   Number of program headers:         8603   Size of section headers:           40 (bytes)   Number of section headers:         11806   Section header string table index: 1

$ ./tricore-objdump.exe -m tricore -d example.elf | head -n20

example.elf:     file format elf32-tricore

Disassembly of section .text.DEFAULT_CODE_ROM:

8001f0c8 : 8001f0c8:       a0 04           mov.a %a4,0 8001f0ca:       1d 00 9c 01     j 8001f402

8001f0ce : 8001f0ce:       02 49           mov %d9,%d4 8001f0d0:       91 10 00 fd     movh.a %a15,53249

8001f0d4 : 8001f0d4:       d9 ff 36 49     lea %a15,[%a15]-28362 <d0009136

> 8001f0d8:       01 f9 00 f6     addsc.a %a15,%a15,%d9,0 8001f0dc:       14 f0           ld.bu %d0,[%a15] 8001f0de:       df 10 9f 00     jeq %d0,1,8001f21c Thanks, R. Chebah Le 08/04/2021 à 20:51, karsten-burger a écrit : > > Hi, > I have two binaries for running with Infineon TriCore 1797. > > when running the command |tricore-readelf.exe -h | I get the > message: > |readelf: Error: Not an ELF file - it has the wrong magic bytes at the > start| > > With |tricore-objdump.exe -i| I get some results, like > > BFD header file version 2.13 > elf32-tricore > (header little endian, data little endian) > TriCore:Rider-B > ieee > (header endianness unknown, data endianness unknown) > TriCore:Rider-B > elf32-little > (header little endian, data little endian) > TriCore:Rider-B > elf32-big > (header big endian, data big endian) > TriCore:Rider-B > srec > (header endianness unknown, data endianness unknown) > TriCore:Rider-B > symbolsrec > (header endianness unknown, data endianness unknown) > TriCore:Rider-B > tekhex > (header endianness unknown, data endianness unknown) > TriCore:Rider-B > binary > (header endianness unknown, data endianness unknown) > TriCore:Rider-B > ihex > (header endianness unknown, data endianness unknown) > TriCore:Rider-B > > |elf32-tricore ieee elf32-little elf32-big srec symbolsrec | > > TriCore:Rider-B elf32-tricore ieee elf32-little elf32-big srec symbolsrec > > |tekhex binary ihex | > > TriCore:Rider-B tekhex binary ihex> > > The binary is not very recent, created about 2014. > What is wrong? > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub > , or unsubscribe > . >
karsten-burger commented 3 years ago

Hello Chebah, I think it was stupid of me: "file" gives result "data". The ELF magic key is missing, the first 8 bytes are "C0 00 00 00 00 40 00 00", I have a binary which is directly loadable into the TriCore1797 ECU, so this is no ELF file but just a binary image. Sorry to have bothered you.