SYSV vs. Linux/GNU ELF formats

给你一囗甜甜゛ 提交于 2019-12-08 19:16:12

问题


The question is in the context of the following question: Why are libraries not found, even though they are clearly on the -L path? . It seems that my libraries and my object file have a different ELF format, which might cause the linker to not "find" the libraries.

Now, this leads to a couple of questions:

  1. It seems that my compiler normally generates SYSV ELF files. (Checked with file). However, for that particular C++ source, it generates a Linux/GNU ELF object file. I wonder why, so I reduced that source to an empty main method - and suddenly I get a SYSV object file. What inside a C++ source file can cause the compiler to switch the ELF format?

  2. Is it true or false that I can not link Linux/GNU together with SYSV ELF?

  3. Is there an option to force the compiler to create a certain ELF format?

I'm working with a Cray g++ (GCC) 5.3.0 20151204.


回答1:


Regarding question 1: one of the answer seems to be that functions of type STT_GNU_IFUNC will cause the compiler/linker to switch the ELF file format of the corresponding object file from SYSV to GNU/Linux.

However, I still couldn't find out how I can identify functions in an object file which have type STT_GNU_IFUNC. Looking at object files which are GNU/Linux with objdump, readelf and nm still don't show a single function of type STT_GNU_IFUNC.

Some more information on STT_GNU_IFUNC can be found at https://www.airs.com/blog/archives/403 and in the following related question: How do I compile on linux to share with all distributions?



来源:https://stackoverflow.com/questions/45783759/sysv-vs-linux-gnu-elf-formats

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