Output of 'make' is a shared object and not an executable

橙三吉。 提交于 2019-12-02 01:06:07

This may happen when application is compiled with special CFLAGS e.g. -pie -fPIE:

$ echo 'int main() { return 0; }' | gcc -x c - -fPIE -pie
$ file a.out
a.out: ELF 64-bit LSB  shared object, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, 

Perhaps you could run your make with VERBOSE=1 and see if that's the case? In general file may use heuristics to identify filetype so you shouldn't rely on it too heavily.

As for your error with ld.so, you are using the wrong, 32-bit, dynamic linker to run 64-bit app. Use /lib64/ld-linux-x86-64.so.2 instead (as file told you).

EDIT: Another option is that your GCC is built with --enable-default-pie which seems to be the case for modern Ubuntu. You can disable this feature by cmaking with CFLAGS=-no-pie (or -nopie, depending on GCC version) but I'd rather not do that - PIE'ed executables make your system safer by allowing ASLR to do better job.

slone xin

I found the root cause is the -shared flag in CMAKE_EXE_LINKER_FLAGS. when I delete -shared, everything is ok.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!