linux下可执行文件一般为elf格式,查看可执行文件的相关信息可用到的命令有:
1、file
$ file tvd_capture
tvd_capture: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, BuildID[sha1]=dabacca3bad5b85ebfb41d4f49ec535371efac76, not stripped
2、nm、readelf、 objdump
$ file tvd_capture
$ readelf -a tvd_capture
$ objdump -d tvd_capture
每种方式出来得到的信息都不同。基本都是整体信息的不同部分。其中很关键的是符号信息,通过这些符号信息可以推测到很多文件相关的功能,要消除符号信息有几种方式:
1、在链接的时候使用-s命令。这样就可以消除基本的函数名符号信息:
$ gcc -s -o tvd_capture tvd_capture.o
2、 网络上有人建议如下设置:参考(http://blog.sina.com.cn/s/blog_602f87700100t0t5.html)
2.1. 编译阶段使用:
-ffunction-sections
-fdata-sections
2.2. 链接阶段使用:
-Wl,--gc-sections