Loading of executable programs
I. Preprocessing, compiling, linking, and formatting of the target file
1. How does the executable program come from?
Pretreatment:
GCC-E-O hello.cpp hello.c-m32
* Responsible for inclusion and macro replacement of include files
Compile:
Gcc-x cpp-output-s-o hello.s hello.cpp-m32
Gcc-x assembler-c Hello.s 0o hello.o-m32
HELLO.S Assembly Code
hello.o binary files
Link:
Gcc-o Hello hello.o--m32
2. Format of the target file elf
A.out COFF (pe+elf)
Three different types:
can relocate files
Executable file
Share files
Entry start of the point address program
3. Statically linked Elf
Static linking puts all your code in one code snippet
Dynamic links will have multiple code snippets
II. executable programs, shared libraries, and dynamic links
1. Work before loading the executable program
Execution Environment: command line + parameters
*shell itself does not limit the number of command-line arguments
*shell calls Execve to pass command-line arguments and environment parameters to the main function
Shell>execve>sys_exceve
* Copy in the new program stack when initializing
* First function call parameter pass, then system call parameter Pass
2. Load-time dynamic linking and example
Iii. Loading of executable programs
1. Analysis of related key issues
Fork first returns to the parent process once, then returns ret_from_fork to start execution and then returns to the user state
SYS_EXECVE:
Do_exceve>do_execve_common>exec_binprm
By modifying the value of an EIP in the kernel stack as a starting point for a new program
Internal processing of 2.sys_exceve
For statically linked file Elf_entry is the starting point for new program execution
3.GDB Tracking
NEW_IP is the address of the first instruction returned to the user state
Experiment:
Linux kernel Analysis (seventh week)