SYSV与Linux / GNU ELF格式 [英] SYSV vs. Linux/GNU ELF formats
问题描述
该问题与以下问题相关:为什么找不到库,即使它们显然在-L路径上也是如此?。看来我的库和目标文件具有不同的ELF格式,这可能会导致链接器无法找到库。
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:
-
似乎我的编译器通常会生成SYSV ELF文件。 (已通过
文件
检查)。但是,对于该特定C ++源,它将生成Linux / GNU ELF对象文件。我不知道为什么,所以我将该源简化为一个空的main方法-突然我得到了SYSV目标文件。 C ++源文件中的哪些内容会导致编译器切换ELF格式?
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?
这是对还是错?我不能将Linux / GNU与SYSV ELF链接在一起?
是否可以选择强制编译器创建某个ELF?格式?
我正在使用Cray g ++(GCC)5.3.020151204。
I'm working with a Cray g++ (GCC) 5.3.0 20151204.
推荐答案
关于问题1:答案之一似乎是 STT_GNU_IFUNC $ c类型的函数$ c>将导致编译器/链接器将相应目标文件的
ELF
文件格式从 SYSV
切换为 GNU / Linux
。
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
.
但是,我仍然找不到在对象文件中如何识别函数的方法。的类型为 STT_GNU_IFUNC
。查看具有 objdump
, readelf $ c $的
GNU / Linux
的目标文件c>和 nm
仍然没有显示类型为 STT_GNU_IFUNC
的单个函数。
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
.
有关 STT_GNU_IFUNC
的更多信息,请访问 https://www.airs.com/blog/archives/403 以及以下相关问题:
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?
这篇关于SYSV与Linux / GNU ELF格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!