问题
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:
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?Is it true or false that I can not link Linux/GNU together with SYSV ELF?
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