用gcc编译的程序没有执行权限
风中之哨 2013-04-30 04:16:10 今天突然发现我在ubuntu中用gcc编译一个文件后,生成的可执行文件没有执行权限,就算chmod 777 后也无法执行!求教!
gcc -c pid.c -o pid
chmod a+x pid
./pid
结果:
bash: ./pid: cannot execute binary file
用file查看:
file pid
结果
pid: ELF 64-bit LSB relocatable, x86-64, version 1 (SYSV), not stripped
下面是用file命令查看以前写的一个测试程序,这个是好的。这个以前也是用同样的gcc命令编译的,而且编译的结果本身就有可执行权限。但是用file命令发现和上面的不样
file str-test
结果:
str-test: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x86469a8dac9963f16a4986ceec9fbf1f8f689372, not stripped
求解,谢谢