[英]Different types of object files
The e_type
in the ELF document lists the following available object file types: ELF 文档中的
e_type
列出了以下可用的目标文件类型:
Name Value Meaning
ET_NONE 0 No file type
ET_REL 1 Relocatable file
ET_EXEC 2 Executable file
ET_DYN 3 Shared object file
ET_CORE 4 Core file
ET_LOPROC 0xff00 Processor-specific
ET_HIPROC 0xffff Processor-specific
Where can I learn more about what each of these file types are?我在哪里可以详细了解这些文件类型是什么? For example, I've never heard of a "Processor-specific" file: what would be an example of that?
例如,我从来没有听说过“特定于处理器”的文件:有什么例子呢?
And in doing $ xxd -l 32 /bin/ls
, the object type is ET_DYN:在执行
$ xxd -l 32 /bin/ls
,对象类型为 ET_DYN:
00000000: 7f45 4c46 0201 0100 0000 0000 0000 0000 .ELF............
00000010: 0300 <-- object type = 3 or "shared object file"
Why is ls
not considered an executable, but a Shared object?为什么
ls
不被视为可执行文件,而是共享对象? (editor's note: this part is a duplicate of Why does GCC create a shared object instead of an executable binary according to file? Also, readelf -h /bin/ls
is an easier way to decode the ELF header, including the ELF type) (编者注:这部分是为什么 GCC 根据文件创建共享对象而不是可执行二进制文件的
readelf -h /bin/ls
?此外, readelf -h /bin/ls
是解码 ELF 标头的更简单方法,包括 ELF 类型)
And finally, what is a core
file?最后,什么是
core
文件? Is this like a stacktrace?这像堆栈跟踪吗? http://man.netbsd.org/core.5 , Get the address that caused segmentation fault from core dump using C .
http://man.netbsd.org/core.5 , 使用C从core dump中获取导致segmentation fault的地址。
(Editor's note: this part is a duplicate of What is a core dump file in Linux? What information does it provide? . Unfortunately this is 3 questions in 1 post so can't easily be marked as duplicates while answering the non-duplicate part) (编者注:这部分是什么是 Linux 中的核心转储文件?它提供什么信息?不幸的是,这是 1 个帖子中的 3 个问题,因此在回答非重复部分时不能轻易标记为重复部分)
There's two parts to your question:你的问题有两个部分:
These are left as "extension points" if a future CPU family wanted to define a new type of file.如果未来的 CPU 系列想要定义新类型的文件,这些将作为“扩展点”。 None of the main processor families ever used something from that range, so there's no example I can come up with even with a bit of searching.
没有一个主要的处理器系列使用过这个范围内的东西,所以即使稍微搜索一下,我也找不到任何例子。
ls
is ET_DYN
ls
是ET_DYN
The ET_DYN
constant just means that the object is runtime-relocatable. ET_DYN
常量仅表示该对象是运行时可重定位的。 Classically, this has been used for Shared Objects ( .so
), but for Position-Independent Executables (PIE) in glibc, they reused the same compiler and loader code as the shared objects to do the runtime-relocation, leading to this confusing situation where executables are reported as shared objects.传统上,这已用于共享对象 (
.so
),但对于 glibc 中的位置无关可执行文件 (PIE),它们重用与共享对象相同的编译器和加载器代码来进行运行时重定位,从而导致这种混乱的情况其中可执行文件被报告为共享对象。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.