I'm a beginner in compilers but I'm very interested in learning about how a program is structured (the binary) and how it is read and loaded in memory for execution. What ebooks/books/tutorials do you guys suggest me reading for a quick start?
An ELF file has two views:
- The program header shows the segments used at run-time
- The section header lists the set of sections of the binary
Each ELF file is made up of one ELF header, followed by file data.
The file data can include:
- Program header table, describing zero or more segments
- Section header table, describing zero or more sections
- Data referred to by entries in the program header table or section header table
The segments contain information that is necessary for runtime execution of the file, while sections contain important data for linking and relocation. Any byte in the entire file can be owned by at most one section, and there can be orphan bytes which are not owned by any section.
In computing, a loader is the part of an operating system that is responsible for loading programs.
It is one of the essential stages in the process of starting a program, as it places programs into memory and prepares them for execution.
Loading a program involves :
- reading the contents of executable file, the file containing the program text, into memory
- carrying out other required preparatory tasks to prepare the executable for running.
Once loading is complete, the operating system starts the program by passing control to the loaded program code.
In Unix, the loader is the handler for the system call
execve()
.The Unix loader's tasks include:
- validation (permissions, memory requirements etc.)
- copying the program image from the disk into main memory
- copying the command-line arguments on the stack
- initializing registers (e.g., the stack pointer)
- jumping to the program entry point (
_start
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With