Original Wu Zhangjin Linux Reading Field2019-12-02
This article briefly introduces the 15 new ways to execute the code, as well as a detailed introduction to all the experimental materials provided by the course. "
- Program execution tags:
- 360 elf
- Video course
- Experimental Materials
Background introduction
As a course that pays special attention to practice, the "360° Analysis of Linux ELF" video course has been iterating and updating experimental materials since it went live 1 month ago.
- Today, 15 new code execution methods have been added, including exec, shlib, dlopen, cscript, binfmt-misc, embed, load-malloc, load-mmap, etc.
- Compared to when the video was launched, nearly 30 experimental materials have been added, and more than 70 experimental materials have been provided so far.
- After the course was launched, a series of articles on Linux ELF have been serialized continuously. These articles are basically comprehensive experimental examples.
This article will briefly introduce these 15 code execution methods, and then show the current statistical results of the experimental materials of the course.
15 ways to execute code
In Chapter 7, the course introduces the code running and exiting in detail. In order to understand this part of the content more thoroughly, after careful preparation, we have added the following 15 experimental materials, respectively introducing 15 ways of code execution:
Experimental Materials | Material Description |
---|---|
exec | Compile into an executable file |
shlib | Compile into a shared library, and execute the shared library directly |
dlopen | Parse code symbols directly through dlopen and run |
cscript | Run C language programs in scripts |
emulator | Run executable files through the simulator |
binfmtc-extension | Run C language program directly by extension |
binfmtc-magic | Customize a magic number to run C language program directly |
embed-ldscript | Embedded in another program to run, assisted by ldscript |
embed-objcopy | Embedded in another program to run, assisted by objcopy |
embed-pic | Embedded in another program to run, the code itself is position-independent |
load-malloc-auto | After the program is loaded into the memory allocated by malloc and run, the data address t is determined at runtime |
load-malloc-pic | After the program is loaded into the memory allocated by malloc, it runs, using position-independent code |
load-mmap-auto | After loading into the memory requested by mmap through the program, run, and determine the data address at runtime |
load-mmap-fixed | Run after loading into the memory requested by mmap through the program, using a fixed address |
load-mmap-pic | Run after loading into the memory requested by mmap through the program, using position-independent code |
Each experimental material has a matching Makefile and corresponding C or assembly language code. These materials fully present the mystery of Linux program execution.
Other statistics
In addition to providing 8 demonstration slides (including dozens of newly designed charts) and 10 hours of video, the video course has more than 70 experimental materials, and it is still being iterated and updated.
Up to now, the corresponding statistics are as follows:
up to 25 standard documents
1. $ find ./ -name "*.pdf" | wc -l
2. 25
Up to 53 instructions
1.$ find ./ -name "*.md" | wc -l
2.53
Another 13 small demonstration videos
1.$ grep showterm.io -ur ./0* | wc -l
2.13
Up to 5351 lines of experimental code
After collecting statistics through cloc, we get the following more detailed data, which contains 55 C programs, 23 assembly codes, and 50 Makefiles.
1. $ cloc ./
2. 287 text files.
3. 264 unique files.
4. 605 files ignored.
5.
6 -------------------------------------------------------------------------------
7 Language files blank comment code
8 -------------------------------------------------------------------------------
9 C 55 451 166 1710
10 make 50 474 76 1329
11 Assembly 23 152 62 1044
12 C++ 3 127 135 971
13 CMake 9 51 25 286
14 C/C++ Header 2 2 1 6
15 Bourne Shell 1 2 0 5
16 -------------------------------------------------------------------------------
17 SUM: 143 1259 465 5351
18 -------------------------------------------------------------------------------
The detailed directory structure is as follows
1. $ tree -L 3 -d ./
2. ./
3. ├── 01-init
4. │ ├── hello-asm
5. │ ├── hello-c
6. │ ├── linux-lab
7. │ └── vim
8. ├── 02-born
9. │ ├── run-a.out
10. │ ├── run-arm
11. │ │ └── arm
12. │ ├── run-elf
13. │ ├── run-macho
14. │ └── run-pe
15. ├── 03-face
16. │ ├── elf-tools
17. │ ├── gcc-usage
18. │ ├── tcc-usage
19. │ ├── tiny-executables
20. │ │ ├── elf
21. │ │ ├── mach-o
22. │ │ └── pe
23. │ └── upx
24. ├── 04-basic
25. │ ├── addr-align
26. │ │ └── build
27. │ ├── big-little-endian
28. │ ├── c-std
29. │ ├── debug-example
30. │ ├── elf-objects
31. │ ├── exec-shlib
32. │ ├── inline-asm
33. │ ├── sections
34. │ └── shlib-pic
35. ├── 05-generate
36. │ ├── assembly
37. │ ├── dlopen
38. │ ├── gcc-compile-background
39. │ ├── mini-dynamic-linker
40. │ └── standalone-c
41.├── 06-execute
42. │ ├── args-and-env
43. │ ├── assembly
44. │ │ └── staged
45. │ ├── fork-and-exec
46. │ ├── myinit
47. │ └── tinyshell
48. ├── 07-running
49. │ ├── assembly -> ../06-execute/assembly/
50. │ ├── binfmtc
51. │ ├── c-variables
52. │ ├── mem-layout
53. │ ├── monitor-myself
54. │ ├── ptrace
55. │ ├── run-code
56. │ │ ├── binfmtc-extension
57. │ │ ├── binfmtc-magic
58. │ │ ├── cscript
59. │ │ ├── dlopen
60. │ │ ├── embed-ldscript
61. │ │ ├── embed-objcopy
62. │ │ ├── embed-pic
63. │ │ ├── emulator
64. │ │ ├── exec
65. │ │ ├── load-malloc-auto
66. │ │ ├── load-malloc-pic
67. │ │ ├── load-mmap-auto
68. │ │ ├── load-mmap-fixed
69. │ │ ├── load-mmap-pic
70. │ │ └── shlib
71. │ ├── tcc-run
72. │ └── weak
73. └── standards
74. └── svid
75.
76. 72 directories
summary
The 15 experimental materials mentioned above, along with other materials, have been uploaded to the code warehouse, which is currently only open to students.
Subscribe to the course: "360° Analysis of Linux ELF", you can download the above experimental materials immediately, and study and discuss the linking, loading and running of Linux programs with Teacher Wu and hundreds of students, and improve the efficiency of analyzing and solving practical problems.
All the above experimental materials can be directly tested in Linux Lab. Under normal circumstances, Linux Lab can be installed in just tens of minutes. It not only supports Linux, but can also run directly under the new version of Windows and MacOSX, as long as there is a Docker environment.
(Finish)