Unfazed❗️🎯

ELF 파일? ELF 헤더? 본문

Operating System (운영체제)

ELF 파일? ELF 헤더?

9taetae9 2023. 9. 16. 22:55
728x90

이전 글 : https://9taetae9.tistory.com/2

 

The ELF (Executable and Linkable Format) and PE (Portable Executable) formats/ ELF 파일, PE 포맷?

The ELF (Executable and Linkable Format) and PE (Portable Executable) formats are two of the most common file formats for executables, shared libraries, and even some object files on various computer systems. They each serve to allow the OS and loader to u

9taetae9.tistory.com

 

ELF Header
Role: The ELF Header provides metadata about the file.
Location: Found at offset 0 of the file.
Structure:
The ELF header is defined by two types, depending on the architecture: Elf32_Ehdr for 32-bit systems and Elf64_Ehdr for 64-bit systems. 

The structure contains:

1. e_ident (array): Specifies how to interpret the file, independent of the processor or the file's remaining contents. The array's indices are named using macros starting with the EI_ prefix.

2. e_type: Specifies the type of the file.

3. e_machine: Indicates the architecture required to use the file.

4. e_version: Represents the version information of the object file.

5. e_entry: Provides the virtual address where the system should transfer control when executing. If there's no entry point in the file, it holds the value 0.

6. e_phoff: Represents the file offset, in bytes, of the program header table. If there's no program header table, it holds the value 0.

7. e_shoff: Indicates the file offset, in bytes, of the section header table. If there's no section header table, it holds the value 0.

8. e_flags: Contains processor-specific flags associated with the file.

9. e_ehsize: Denotes the size, in bytes, of the ELF header.

10. e_phentsize: Holds the size, in bytes, of one entry in the file's program header table. All entries have the same size.

11. e_phnum: Represents the number of entries in the program header table. If there's no program header table, it holds the value 0.

12. e_shentsize: Specifies the size, in bytes, of one section header. All section headers in the section header table have the same size.

13. e_shnum: Indicates the number of entries in the section header table. If there's no section header table, it holds the value 0.

14. e_shstrndx: Contains the section header table index associated with the string table describing the section names. If there's no string table for section names, it holds the value SHN_UNDEF.

Alignment and Padding:
The ELF format ensures that all its data structures adhere to natural size and alignment guidelines suitable for the architecture. When necessary, data structures have explicit padding for correct alignment.


The ELF format is pivotal in Unix like operating systems and serves as the cornerstone for executables, shared libraries, and even core dumps.

728x90