Skip to content

Commit 1de282b

Browse files
committed
Refine ELF segments
This commit refines the program headers to generate a better ELF executable file, with the following changes: - Always create two load segments, regardless of static or dynamic linking. - The first load segment is readable and executable, and includes the read-only sections such as .text, .rodata, etc. - The second load segment is readable and writable, and contains the remaining sections, including .data and .bss. - In dynamic linking mode, the .rel.plt and .plt sections reside in the first segment, while the other dynamic sections are placed in the second segment. - Set the alignment value of both load segments to 0x1000 (the default page size) to meet the alignment requirement when the ELF interpreter loads the executable. - Adjust the offset and virtual address of the first load segment to ensure that dynamically linked executable can be correctly loaded by the kernel program loader. - Now, the ELF header and program headers are also loaded into the first segment but they are never used. - Update other segments as necessary to reflect the above changes.
1 parent d7896a1 commit 1de282b

File tree

1 file changed

+141
-113
lines changed

1 file changed

+141
-113
lines changed

0 commit comments

Comments
 (0)