2

I am trying to learn and use Elfreader by compiling a simple hello world program to a elf file as-

gcc -o test test.c

The file compiles correctly and runs perfect. But when I try to run ReadElf on it by

readelf -h test

it returns

readelf: Error: Not and ELF file - it has the wrong magic bytes at the start

What do you think I am doing wrong, or is there a problem with my linker script? Let me know if you need any additional info from me.

Steve H
  • 461
  • 2
  • 10
  • 18
  • 1
    It was pretty dumb question from my part. The answer is pretty straight forward (Or I should say the question did not specify that I was using a Windows-Cygwin environment). I was using cygwin on Windows. The executable thus produced was a .exe and not an ELF format file. Obviously readelf returned that error since undertaken file is not a valid ELF. – Steve H Jun 28 '13 at 04:31

1 Answers1

-1

You can check file format type follow as :

$ objdump -t hello.exe

hello.exe: file format pei-i386

Maybe I guess your file is not elf format.

EzLo
  • 13,780
  • 10
  • 33
  • 38