填命令sh-5.1$ ls
main main.c read read.c write write.c
sh-5.1$ cat main.c
#include <stdio.h>
#include <stdlib.h>
int main(void) {
system("ls");
system("cat main.c");
system("readelf -l main");
return 0;
}
sh-5.1$ gcc -m32 -g3 -Wall -o main main.c
sh-5.1$ ./main
main main.c read read.c write write.c
#include <stdio.h>
#include <stdlib.h>
int main(void) {
system("ls");
system("cat main.c");
system("readelf -l main");
return 0;
}
Elf file type is DYN (Position-Independent Executable file)
Entry point 0x1060
There are 12 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x00000034 0x00000034 0x00180 0x00180 R 0x4
INTERP 0x0001b4 0x000001b4 0x000001b4 0x00013 0x00013 R 0x1
[Requesting program interpreter: /lib/ld-linux.so.2]
LOAD 0x000000 0x00000000 0x00000000 0x00428 0x00428 R 0x1000
LOAD 0x001000 0x00001000 0x00001000 0x00204 0x00204 R E 0x1000
LOAD 0x002000 0x00002000 0x00002000 0x000d4 0x000d4 R 0x1000
LOAD 0x002ee8 0x00003ee8 0x00003ee8 0x00128 0x0012c RW 0x1000
DYNAMIC 0x002ef0 0x00003ef0 0x00003ef0 0x000f0 0x000f0 RW 0x4
NOTE 0x0001c8 0x000001c8 0x000001c8 0x00078 0x00078 R 0x4
GNU_PROPERTY 0x0001ec 0x000001ec 0x000001ec 0x00034 0x00034 R 0x4
GNU_EH_FRAME 0x002028 0x00002028 0x00002028 0x00024 0x00024 R 0x4
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x10
GNU_RELRO 0x002ee8 0x00003ee8 0x00003ee8 0x00118 0x00118 R 0x1
Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .note.gnu.build-id .note.gnu.property .note.ABI-tag .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.dyn .rel.plt
03 .init .plt .text .fini
04 .rodata .eh_frame_hdr .eh_frame
05 .init_array .fini_array .dynamic .got .got.plt .data .bss
06 .dynamic
07 .note.gnu.build-id .note.gnu.property .note.ABI-tag
08 .note.gnu.property
09 .eh_frame_hdr
10
11 .init_array .fini_array .dynamic .got
sh-5.1$
|