来自wiki Executable and Linkable Format:

段包含文件运行时执行所需的信息,而段包含链接和重新定位所需的重要数据.整个文件中的任何字节最多只能由一个节拥有,并且可能存在不属于任何节的孤立字节.

但是分段和分段之间有什么区别呢?

推荐答案

但是分段和分段之间有什么区别呢?

正如您所引用的:段包含运行时所需的信息,而节包含链接期间所需的信息.

段是否包含一个或多个段?

一个段可以包含0个或多个段.例子:

readelf -l /bin/date

Elf file type is EXEC (Executable file)
Entry point 0x402000
There are 9 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000400040 0x0000000000400040
                 0x00000000000001f8 0x00000000000001f8  R E    8
  INTERP         0x0000000000000238 0x0000000000400238 0x0000000000400238
                 0x000000000000001c 0x000000000000001c  R      1
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                 0x000000000000d5ac 0x000000000000d5ac  R E    200000
  LOAD           0x000000000000de10 0x000000000060de10 0x000000000060de10
                 0x0000000000000440 0x0000000000000610  RW     200000
  DYNAMIC        0x000000000000de38 0x000000000060de38 0x000000000060de38
                 0x00000000000001a0 0x00000000000001a0  RW     8
  NOTE           0x0000000000000254 0x0000000000400254 0x0000000000400254
                 0x0000000000000044 0x0000000000000044  R      4
  GNU_EH_FRAME   0x000000000000c700 0x000000000040c700 0x000000000040c700
                 0x00000000000002a4 0x00000000000002a4  R      4
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     8
  GNU_RELRO      0x000000000000de10 0x000000000060de10 0x000000000060de10
                 0x00000000000001f0 0x00000000000001f0  R      1

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .interp .note.ABI-tag .note.gnu.build-id .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame_hdr .eh_frame 
   03     .ctors .dtors .jcr .dynamic .got .got.plt .data .bss 
   04     .dynamic 
   05     .note.ABI-tag .note.gnu.build-id 
   06     .eh_frame_hdr 
   07     
   08     .ctors .dtors .jcr .dynamic .got 

这里,PHDR段包含0个部分,INTERP段包含.interp个部分,前LOAD段包含一整串部分.

Further reading加上漂亮的illustration:

enter image description here

Linux相关问答推荐

Arch_prctl的用例是什么

Linux 中大型 TSV 的条件编辑

运行系统命令失败,但相同的命令可以直接在 bash 中执行

线程创建会在 Linux 中触发页面错误吗?它与软脏 PTE 有什么关系?

X86 程序集 - struct 点 - 存储/返回不正确?

为什么我在从 Linux 通过 telnet 发送 Ctrl-C 后停止接收数据?

未找到 SDL_Vertex 和 SDL_RenderGeometry

为什么要命令; ls -l file_doesnot_exists > /dev/null 2>&1 正在工作; ls -l 2>&1 file_doesnot_exists > /dev/null 不是

如何在 Linux 上使用 -grep 构建过滤间隔的命令

使用打印命令 Select 子域

使用 AWS CLI 进行 Bash - 无法找到凭证

我需要 -D_REENTRANT 和 -pthreads 吗?

如何将执行的shell命令的结果存储在python的变量中?

Linux 应用程序分析

在 C 中设置环境变量

Linux:在目录下的文件列表中搜索特定单词

如何找到只对所有者具有特定权限的文件?

在 Linux 中的特定行向文件添加文本

使用 WGET 运行 cronjob PHP

内联 if shell 脚本