【发布时间】:2019-01-26 03:23:39
【问题描述】:
我正在学习 ELF 并且有一段时间有疑问。我试图寻找答案,但徒劳无功。如果有人可以给我答案或引导我去寻找答案的地方,我会很高兴的。
我读到的几乎所有关于 ELF 的文档都说 .text 部分包含可执行的二进制代码(而 .data 包含数据......)。但是,当我使用 readelf 查看 obj 文件中包含的部分时,我没有看到 .text 部分,而是一个名为 i.main 的部分,其中包含可执行代码(从本部分中包含的代码中,我找到了机器代码)。下面展示了readelf解析的部分
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] i.main PROGBITS 00000000 000034 00000a 00 AX 0 0 2
[ 2] .arm_vfe_header PROGBITS 00000000 000040 000004 00 0 0 4
[ 3] .comment PROGBITS 00000000 000044 0001c6 00 0 0 1
[ 4] .debug_frame PROGBITS 00000000 00020a 00003c 00 0 0 1
[ 5] .debug_info PROGBITS 00000000 000246 000088 00 0 0 1
[ 6] .debug_info PROGBITS 00000000 0002ce 0000dc 00 0 0 1
[ 7] .debug_line PROGBITS 00000000 0003aa 000030 00 0 0 1
[ 8] .debug_line PROGBITS 00000000 0003da 000044 00 0 0 1
[ 9] .debug_loc PROGBITS 00000000 00041e 000014 00 0 0 1
[10] .debug_macinfo PROGBITS 00000000 000432 000308 00 0 0 1
[11] .debug_pubnames PROGBITS 00000000 00073a 00001b 00 0 0 1
[12] __ARM_grp..debug_ GROUP 00000000 000758 000008 04 14 14 4
[13] .debug_abbrev PROGBITS 00000000 000760 0005a4 00 G 0 0 1
[14] .symtab SYMTAB 00000000 000d04 000110 10 21 13 4
[15] .rel.debug_frame REL 00000000 000e14 000010 08 14 4 4
[16] .rel.debug_info REL 00000000 000e24 000018 08 14 5 4
[17] .rel.debug_info REL 00000000 000e3c 000038 08 14 6 4
[18] .rel.debug_line REL 00000000 000e74 000008 08 14 8 4
[19] .rel.debug_pubnam REL 00000000 000e7c 000008 08 14 11 4
[20] .shstrtab STRTAB 00000000 000e84 0000f2 00 0 0 1
[21] .strtab STRTAB 00000000 000f76 0001b3 00 0 0 1
[22] .ARM.attributes ARM_ATTRIBUTES 00000000 001129 000044 00 0 0 1
看来段名是可以任意选择的(对吗?)如果是这样,那么我的问题是
如何判断哪个部分包含什么? (例如,哪个部分包含代码,哪个部分包含只读数据......)。
如何知道每个section的定义,比如我怎么知道“[12] __ARM_grp..debug_”这个section是干什么用的?
提前致谢。
【问题讨论】:
标签: elf