判别ELF文件类型

ELF文件的三种类型是:

  • 可重定位文件:用户和其他目标文件一起创建可执行文件或者共享目标文件,例如lib*.a文件。
  • 可执行文件:用于生成进程映像,载入内存执行,例如编译好的可执行文件a.out。
  • 共享目标文件:用于和其他共享目标文件或者可重定位文件一起生成elf目标文件或者和执行文件一起创建进程映像,例如lib*.so文件。

对ELF类型判别方式:通过file命令可以看到哪种类型的ELF

        gcc -c helloworld.c
        file helloworld.o
        helloworld.o: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped #可重定向文件##

        gcc -o helloworld helloworld.o
        file helloworld
        helloworld: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped ##可执行文件##

        file libc.so
        libc.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped #共享目标文件##

转载地址: http://blog.chinaunix.net/uid-9525959-id-2001831.html

猜你喜欢

转载自blog.csdn.net/Lina_ACM/article/details/79767652