






























| 节名称 | 作用(通俗解释) | 代码示例 |
|---|---|---|
| 段类型(Type) | 通俗名称 | 作用解释 | 包含的典型节 |
|---|---|---|---|
text
【可执行文件典型映射】
┌─────────────────────────────────────────────┐
│ ELF文件 (磁盘上) │
│ │
│ 节(Section) 段(Segment) │
│ ───────────────────────────────────────── │
│ .interp ──► PT_INTERP │
│ .interp ──► PT_LOAD[0] (只读段) │
│ .note ──► PT_NOTE │
│ .text ──► PT_LOAD[0] (只读段) │
│ .rodata ──► PT_LOAD[0] (只读段) │
│ .eh_frame_hdr ──► PT_GNU_EH_FRAME │
│ .eh_frame ──► PT_LOAD[0] (只读段) │
│ .init_array ──► PT_LOAD[1] (读写段) │
│ .fini_array ──► PT_LOAD[1] (读写段) │
│ .dynamic ──► PT_DYNAMIC │
│ .dynamic ──► PT_LOAD[1] (读写段) │
│ .got ──► PT_GNU_RELRO │
│ .got.plt ──► PT_LOAD[1] (读写段) │
│ .data ──► PT_LOAD[1] (读写段) │
│ .bss ──► PT_LOAD[1] (读写段) │
│ .tdata ──► PT_TLS │
│ .tbss ──► PT_TLS │
└─────────────────────────────────────────────┘
| 节名称 | 所属段(Segment) | 内存权限 | 原因说明 |
|---|---|---|---|
text
磁盘文件 内存布局
─────────────────────────────────────────────────────────
ELF Header
Program Headers
┌──────────────────────┐
.interp ┐ │ 只读可执行段 │
.text │ PT_LOAD[0] ──► │ (r-x) │
.plt │ r-x │ .interp │
.rodata │ │ .text / .plt │
.eh_frame ┘ │ .rodata / .eh_frame │
└──────────────────────┘
┌──────────────────────┐
.init_array ┐ │ 读写数据段 │
.fini_array │ │ (rw-) │
.dynamic │ PT_LOAD[1] ──► │ .init_array (→只读) │
.got │ rw- │ .got (→只读) │
.got.plt │ │ .dynamic │
.data │ │ .got.plt │
.bss ┘ │ .data / .bss │
└──────────────────────┘
Section Headers
.symtab (不加载到内存)
.strtab (不加载到内存)
.debug_info (不加载到内存)
Bash
# 查看所有节
readelf -S ./a.out
# 查看所有段
readelf -l ./a.out
# 查看节和段的映射关系(最直观!)
readelf -l ./a.out
# 输出中 "Section to Segment mapping" 部分就是映射关系
# 查看符号表
readelf -s ./a.out
# 查看动态链接信息
readelf -d ./a.out
text
# readelf -l 输出示例:
Section to Segment mapping:
Segment Sections...
00 .interp
01 .interp .note .text .rodata .eh_frame ← PT_LOAD[0]
02 .init_array .fini_array .dynamic .got .data .bss ← PT_LOAD[1]
03 .dynamic ← PT_DYNAMIC
04 .note ← PT_NOTE
05 .eh_frame_hdr ← PT_GNU_EH_FRAME
06 ← PT_GNU_STACK
07 .init_array .fini_array .dynamic .got ← PT_GNU_RELRO
免责声明 本文档所有内容仅供安全研究、学术交流与技术学习使用,严禁用于任何未经授权的逆向破解、网络攻击、隐私窃取、恶意软件开发及其他违反《中华人民共和国网络安全法》《数据安全法》等法律法规的行为,使用者应确保已获得目标软件权利人的合法授权并自行承担因使用本文档内容所产生的一切法律责任与后果,作者不对任何直接或间接损害承担任何责任,继续阅读即视为您已知悉并同意上述全部条款。
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。