第2次课后练习

第2次课后练习

郭高旭 2021010803

下面是我机器strace echo.out ooooooooosssssssss的输出结果(WSL2,ubuntu 22.04)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
execve("./a.out", ["./a.out", "ooooooooooooooooosssssssssssssss"...], 0x7ffcaa9a2218 /* 36 vars */) = 0
brk(NULL) = 0x55c596d21000
arch_prctl(0x3001 /* ARCH_??? */, 0x7ffc3320c950) = -1 EINVAL (Invalid argument)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1228025000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=62739, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 62739, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f1228015000
close(3) = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\237\2\0\0\0\0\0"..., 832) = 832
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
pread64(3, "\4\0\0\0 \0\0\0\5\0\0\0GNU\0\2\0\0\300\4\0\0\0\3\0\0\0\0\0\0\0"..., 48, 848) = 48
pread64(3, "\4\0\0\0\24\0\0\0\3\0\0\0GNU\0\302\211\332Pq\2439\235\350\223\322\257\201\326\243\f"..., 68, 896) = 68
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=2220400, ...}, AT_EMPTY_PATH) = 0
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
mmap(NULL, 2264656, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1227dec000
mprotect(0x7f1227e14000, 2023424, PROT_NONE) = 0
mmap(0x7f1227e14000, 1658880, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x28000) = 0x7f1227e14000
mmap(0x7f1227fa9000, 360448, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bd000) = 0x7f1227fa9000
mmap(0x7f1228002000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x215000) = 0x7f1228002000
mmap(0x7f1228008000, 52816, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f1228008000
close(3) = 0
mmap(NULL, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1227de9000
arch_prctl(ARCH_SET_FS, 0x7f1227de9740) = 0
set_tid_address(0x7f1227de9a10) = 2438
set_robust_list(0x7f1227de9a20, 24) = 0
rseq(0x7f1227dea0e0, 0x20, 0, 0x53053053) = 0
mprotect(0x7f1228002000, 16384, PROT_READ) = 0
mprotect(0x55c596980000, 4096, PROT_READ) = 0
mprotect(0x7f122805f000, 8192, PROT_READ) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
munmap(0x7f1228015000, 62739) = 0
write(1, "ooooooooooooooooosssssssssssssss"..., 35ooooooooooooooooossssssssssssssssss) = 35
write(1, "\n", 1
) = 1
exit_group(0) = ?
+++ exited with 0 +++

将所有系统调用以及查询得到的功能列在下面。

  1. execve:加载并执行新程序。

  2. brk:调整进程的数据段大小(通常用于动态内存分配)。

  3. arch_prctl:控制进程的内存映射和调试行为(这里出现了一个错误)。

  4. mmap:映射文件或设备到进程的内存空间。

  5. access:检查文件是否可访问。

  6. openat:打开文件或目录。

  7. newfstatat:获取文件状态信息。

  8. read:读取文件内容。

  9. mprotect:修改内存页的保护方式。

  10. write:向文件描述符写入数据。

  11. close:关闭文件描述符。

  12. set_tid_address:设置线程ID地址。

  13. set_robust_list:设置鲁棒性列表。

  14. rseq:Linux下的原子序列化操作。

  15. prlimit64:获取或修改进程资源限制。

  16. munmap:取消内存映射。

  17. exit_group:终止所有线程并退出进程。




本文总阅读量