zoukankan      html  css  js  c++  java
  • ELF文件中section与segment的区别

    http://blog.csdn.net/joker0910/article/details/7655606

    1. ELF中的section主要提供给Linker使用, 而segment提供给Loader用,Linker需要关心.text, .rel.text, .data, .rodata等等,关键是Linker需要做relocation。而Loader只需要知道Read/Write/Execute的属性。a.out格式没有这种区分。(注意现在使用gcc编译出来的a.out文件只是取该名字而已,文件格式是elf的.)


    2.一个executable的ELF文件可以没有section,但必须有segment。ELF文件中间部分是共用的(也就是代码段、数据段等),如shared objects就可以同时拥有Program header table和Section Header Table,这样load完后还可以relocate。


    3. 这样设定之后,使得Loader需要做的工作大大减少了,一定程度上提高了程序加载的效率。

    下图标记为红色的字段,就是segment区分Read/Write/Execute的属性。

    ELF program header 
    int type; // loadable code or data, dynamic linking info, etc. 
    int offset; // file offset of segment 
    int virtaddr; // virtual address to map segment 
    int physaddr; // physical address, not used 
    int filesize; // size of segment in file 
    int memsize; // size of segment in memory (bigger if contains BSS) 
    int flags; // Read, Write, Execute bits
    int align; // required alignment, invariably hardware page size

  • 相关阅读:
    C# 中的栈和堆
    C# 中的基本数值类型
    多个 .NET 框架
    简单介绍托管执行和 CLI
    C# 控制台输入和输出
    在 C# 中使用变量
    C# 语法基础
    LeetCode 1482. 制作 m 束花所需的最少天数
    C# 基础(更新中)
    圆形靶内的最大飞镖数量
  • 原文地址:https://www.cnblogs.com/feng9exe/p/6899136.html
Copyright © 2011-2022 走看看