I am trying to learn more about strace. I use strace to understand the calls a c program makes. The c program is:
void
_start ()
{
for (;;)
{
}
}
The program gets compiled with
clang -nostdlib littletest.c
The system calls are traced with
strace ./a.out
The expected output is. Source at 3:55
execve("./a.out", ["./a.out"], 0x7ffdf74a7720 /* 42 vars */) = 0
The actual output is
execve("./a.out", ["./a.out"], 0x7ffdf74a7720 /* 42 vars */) = 0
brk(NULL) = 0x55a722f48000
arch_prctl(0x3001 /* ARCH_??? */, 0x7fff7444a540) = -1 EINVAL (Invalid argument)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f85ea9b2000
arch_prctl(ARCH_SET_FS, 0x7f85ea9b2b00) = 0
set_tid_address(0x7f85ea9b2dd0) = 10888
set_robust_list(0x7f85ea9b2de0, 24) = 0
rseq(0x7f85ea9b34a0, 0x20, 0, 0x53053053) = 0
mprotect(0x55a722e3c000, 4096, PROT_READ) = 0
Why there are more than one system-call?
Edit1:
clang -nostdlib -static littletest.c
Produces the expected output. Thank you @ilkkachu
Edit2:
clang --version
clang version 13.0.1
Edit3:
@Stephen Kitt gets the expected output without adding "-static". His clang version is also 13.0.1.