最終更新:2019-10-06 (日) 10:44:23 (66d)  

ELFヘッダ はてなブックマークを見る
Top / ELFヘッダ

内容

ELF/プログラムヘッダテーブル

ELF/セクションヘッダテーブル

確認

  • readelf -h? : Display the ELF file header
    $ readelf -h hello
    ELF Header:
      Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
      Class:                             ELF64
      Data:                              2's complement, little endian
      Version:                           1 (current)
      OS/ABI:                            UNIX - System V
      ABI Version:                       0
      Type:                              EXEC (Executable file)
      Machine:                           Advanced Micro Devices X86-64
      Version:                           0x1
      Entry point address:               0x400430
      Start of program headers:          64 (bytes into file)
      Start of section headers:          6680 (bytes into file)
      Flags:                             0x0
      Size of this header:               64 (bytes)
      Size of program headers:           56 (bytes)
      Number of program headers:         9
      Size of section headers:           64 (bytes)
      Number of section headers:         31
      Section header string table index: 28

定義

  • elf.h?
    • Elf32_Ehdr?ELF32?
      Elf64_Ehdr?ELF64?
      #define EI_NIDENT (16)
      
      typedef struct
      {
        unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
        Elf32_Half	e_type;			/* Object file type */
        Elf32_Half	e_machine;		/* Architecture */
        Elf32_Word	e_version;		/* Object file version */
        Elf32_Addr	e_entry;		/* Entry point virtual address */
        Elf32_Off	e_phoff;		/* Program header table file offset */
        Elf32_Off	e_shoff;		/* Section header table file offset */
        Elf32_Word	e_flags;		/* Processor-specific flags */
        Elf32_Half	e_ehsize;		/* ELF header size in bytes */
        Elf32_Half	e_phentsize;		/* Program header table entry size */
        Elf32_Half	e_phnum;		/* Program header table entry count */
        Elf32_Half	e_shentsize;		/* Section header table entry size */
        Elf32_Half	e_shnum;		/* Section header table entry count */
        Elf32_Half	e_shstrndx;		/* Section header string table index */
      } Elf32_Ehdr;
      
      typedef struct
      {
        unsigned char	e_ident[EI_NIDENT];	/* Magic number and other info */
        Elf64_Half	e_type;			/* Object file type */
        Elf64_Half	e_machine;		/* Architecture */
        Elf64_Word	e_version;		/* Object file version */
        Elf64_Addr	e_entry;		/* Entry point virtual address */
        Elf64_Off	e_phoff;		/* Program header table file offset */
        Elf64_Off	e_shoff;		/* Section header table file offset */
        Elf64_Word	e_flags;		/* Processor-specific flags */
        Elf64_Half	e_ehsize;		/* ELF header size in bytes */
        Elf64_Half	e_phentsize;		/* Program header table entry size */
        Elf64_Half	e_phnum;		/* Program header table entry count */
        Elf64_Half	e_shentsize;		/* Section header table entry size */
        Elf64_Half	e_shnum;		/* Section header table entry count */
        Elf64_Half	e_shstrndx;		/* Section header string table index */
      } Elf64_Ehdr;
      バイト名前
      unsigned chare_identMagic number and other info
      Elf64_Half?e_type?Object file type
      Elf64_Half?e_machine?Architecture
      Elf64_Word?e_version?Object file version
      Elf64_Addr?e_entry?Entry point virtual address
      Elf64_Off?e_phoff?Program header table file offset
      Elf64_Off?e_shoff?Section header table file offset
      Elf64_Word?e_flags?Processor-specific flags
      Elf64_Half?e_ehsize?ELF header size in bytesELFヘッダのサイズ64
      Elf64_Half?e_phentsize?Program header table entry sizeELF/プログラムヘッダテーブルのエントリのサイズ56
      Elf64_Half?e_phnum?Program header table entry countELF/プログラムヘッダテーブルのエントリ数9
      Elf64_Half?e_shentsize?Section header table entry sizeELF/セクションヘッダテーブルのエントリ(Elf64_Shdr)のサイズ64
      Elf64_Half?e_shnumSection header table entry countELF/セクションヘッダテーブルのエントリ数31
      Elf64_Half?e_shstrndx?Section header string table index.shstrtab (SHT_STRTAB)がどのセクションヘッダに格納されているかを示すインデックス28

参考