-
Notifications
You must be signed in to change notification settings - Fork 143
Commit 555f842
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 e3ce090 commit 555f842Copy full SHA for 555f842
File tree
Expand file treeCollapse file tree
1 file changed
+149
-113
lines changedFilter options
- src
Expand file treeCollapse file tree
1 file changed
+149
-113
lines changed
0 commit comments