Skip to content

Instantly share code, notes, and snippets.

@Ben-PH
Last active June 6, 2020 02:56
Show Gist options
  • Save Ben-PH/539fd19911cae424cc9f9484fd6b0da9 to your computer and use it in GitHub Desktop.
Save Ben-PH/539fd19911cae424cc9f9484fd6b0da9 to your computer and use it in GitHub Desktop.
Comaprison of C and Rust syscalls on startup/shutdown.

Abstract

For some situations, understanding system calls made during processes start-up and shut-down can be valuable. For example, consider a shell-scripts long-running hot loop that runs a very short-running process. Thus it is perhaps reasonable to hypothesise that a difference in system calls during process start-up/shut-down has a non-negligable impact on the run time of said hot-loop.

This write-up looks at how C and Rust programs differ in terms of system-calls for start-up/shutdown. It is not intended as a performance analysis and only looks at one target system.

At the end, we take a quick look at using statically linked libraries by building with # cargo build --target x86_64-unknown-linux-musl --release and removing even more syscalls by removing the main function

System

  • OS: Ubuntu 18.04 bionic
  • Kernel: x86_64 Linux 5.3.0-53-generic
  • Rust compiler: rustc 1.43.1 (8d69840ab 2020-05-04)
  • C compiler: gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

Source code

// /path/to/project/src/main.rs

fn main() {}
// /path/to/project/empty.c

int main(void) {}

Key findings

  • C and Rust have 24 and 89 system calls respectively (270% increase)
  • Building rust by statically linking with musl has 21 system-calls (1/8 decrease to C syscall count)
  • Aside from differences in pointer addresses, the list of C syscalls is a sub-list of Rusts syscalls (at least, very close to it).
  • Rusts extra syscalls are largely in two parts
    • Before linking in libc.so.6, links in 4 other .so.n files not done with C. (libdl, librt, libpthread, libgcc_s)
    • What looks like up process cleanup
  • If startup syscall minimisation is your goal
    • use muslibc to reduce the syscall count from 89 to 21
    • use #![feature(start)] and a #[start] annotated function instead of fn main to bring it down to 4
      • This becomes 5 when the code block is non-empty

Annotated outputs

  • = lines are the same
  • ~ lines seem to serve the exact same purpose. Diff only seem to be location in memory
  • ! line does not exist in its counterpart
  • # comment
$ # cargo build --release --verbose which runs the following rustc command
$ rustc --crate-name empty --edition=2018 src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C opt-level=3 -C metadata=3c9c96c11342dfee -C extra-filename=-3c9c96c11342dfee --out-dir /path/to/project/target/release/deps -L dependency=/path/to/project/target/release/deps
$ strace /path/to/project/target/release/empty
= execve("./target/release/empty", ["./target/release/empty"], 0x7ffd5c146570 /* 56 vars */) = 0
= brk(NULL)                               = 0x55bb7cffd000
= access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
= 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
= fstat(3, {st_mode=S_IFREG|0644, st_size=117640, ...}) = 0
= mmap(NULL, 117640, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f3ca203c000
= close(3)                                = 0

# libdl.so.2 used to set an ELF
! access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
! openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
! read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\16\0\0\0\0\0\0"..., 832) = 832
! fstat(3, {st_mode=S_IFREG|0644, st_size=14560, ...}) = 0
! mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3ca203a000
! mmap(NULL, 2109712, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f3ca1c2e000
! mprotect(0x7f3ca1c31000, 2093056, PROT_NONE) = 0
! mmap(0x7f3ca1e30000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f3ca1e30000
! close(3)    = 0

# librt.so.1 used to set up an ELF 
! access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
! openat(AT_FDCWD, "/lib/x86_64-linux-gnu/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
! read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\"\0\0\0\0\0\0"..., 832) = 832
! fstat(3, {st_mode=S_IFREG|0644, st_size=31680, ...}) = 0
! mmap(NULL, 2128864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f3ca1a26000
! mprotect(0x7f3ca1a2d000, 2093056, PROT_NONE) = 0
! mmap(0x7f3ca1c2c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7f3ca1c2c000
! close(3)                                = 0

# libpthread.so.0 used to setup an ELF
! access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
! openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
! read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000b\0\0\0\0\0\0"..., 832) = 832
! fstat(3, {st_mode=S_IFREG|0755, st_size=144976, ...}) = 0
! mmap(NULL, 2221184, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f3ca1807000
! mprotect(0x7f3ca1821000, 2093056, PROT_NONE) = 0
! mmap(0x7f3ca1a20000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0x7f3ca1a20000
! mmap(0x7f3ca1a22000, 13440, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f3ca1a22000
! close(3)                                = 0

# libgcc_s.so.1 for ELF
! access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
! openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
! read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300*\0\0\0\0\0\0"..., 832) = 832
! fstat(3, {st_mode=S_IFREG|0644, st_size=96616, ...}) = 0
! mmap(NULL, 2192432, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f3ca15ef000
! mprotect(0x7f3ca1606000, 2093056, PROT_NONE) = 0
! mmap(0x7f3ca1805000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f3ca1805000
! close(3)                                = 0

# libc.so.6 for ELF
= access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
= 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\0\260\34\2\0\0\0\0\0"..., 832) = 832
= fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
= mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f3ca11fe000
~ mprotect(0x7f3ca13e5000, 2097152, PROT_NONE) = 0
~ mmap(0x7f3ca15e5000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7f3ca15e5000

~ mmap(0x7f3ca15eb000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f3ca15eb000
= close(3)                                = 0

# This occurs as the first mmap for libc.so.6 handling in the C equivelent 
~ mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3ca2038000
~ arch_prctl(ARCH_SET_FS, 0x7f3ca20392c0) = 0

# libc.so.6 (the mmap after its mpratect)
~ mprotect(0x7f3ca15e5000, 16384, PROT_READ) = 0

# last mmap in libgcc_s.so.1 handling
! mprotect(0x7f3ca1805000, 4096, PROT_READ) = 0

# second last mmap of libpthread.so.0 handling
! mprotect(0x7f3ca1a20000, 4096, PROT_READ) = 0

# Four extra mprotects.

# last mmap in librt.so.1 handling
! mprotect(0x7f3ca1c2c000, 4096, PROT_READ) = 0

# last mmap in libdl.so.2 handling 
! mprotect(0x7f3ca1e30000, 4096, PROT_READ) = 0

# these two mprotect address args not found elsewhere
! mprotect(0x55bb7b77c000, 8192, PROT_READ) = 0
! mprotect(0x7f3ca2059000, 4096, PROT_READ) = 0

# address is result of first mmap of this output
= munmap(0x7f3ca203c000, 117640)          = 0

# My guess is this is for process cleanup
! set_tid_address(0x7f3ca2039590)         = 4773
! set_robust_list(0x7f3ca20395a0, 24)     = 0
! rt_sigaction(SIGRTMIN, {sa_handler=0x7f3ca180ccb0, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f3ca1819890}, NULL, 8) = 0
! rt_sigaction(SIGRT_1, {sa_handler=0x7f3ca180cd50, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7f3ca1819890}, NULL, 8) = 0
! rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
! prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
! rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f3ca123cf20}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
! brk(NULL)                               = 0x55bb7cffd000
! brk(0x55bb7d01e000)                     = 0x55bb7d01e000
! openat(AT_FDCWD, "/proc/self/maps", O_RDONLY|O_CLOEXEC) = 3
! prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
! fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
! read(3, "55bb7b54c000-55bb7b57c000 r-xp 0"..., 1024) = 1024
! read(3, "64-linux-gnu/libgcc_s.so.1\n7f3ca"..., 1024) = 1024
! read(3, "                 /lib/x86_64-lin"..., 1024) = 1024
! read(3, "                 /lib/x86_64-lin"..., 1024) = 424
! close(3)                                = 0
! sched_getaffinity(4773, 32, [0, 1, 2, 3]) = 8
! rt_sigaction(SIGSEGV, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
! rt_sigaction(SIGSEGV, {sa_handler=0x55bb7b557e20, sa_mask=[], sa_flags=SA_RESTORER|SA_ONSTACK|SA_SIGINFO, sa_restorer=0x7f3ca1819890}, NULL, 8) = 0
! rt_sigaction(SIGBUS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
! rt_sigaction(SIGBUS, {sa_handler=0x55bb7b557e20, sa_mask=[], sa_flags=SA_RESTORER|SA_ONSTACK|SA_SIGINFO, sa_restorer=0x7f3ca1819890}, NULL, 8) = 0
! sigaltstack(NULL, {ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=0}) = 0

# My guess is this sets up the process stack.
! mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3ca2057000
! sigaltstack({ss_sp=0x7f3ca2057000, ss_flags=0, ss_size=8192}, NULL) = 0
! sigaltstack({ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=8192}, NULL) = 0
~ munmap(0x7f3ca2057000, 8192)            = 0
= exit_group(0)                           = ?
# gcc -o empty -O3 empty.c &&
# strace ./empty
= execve("./empty", ["./empty"], 0x7fff4171f100 /* 56 vars */) = 0
= brk(NULL)                               = 0x56137cf2c000
= access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
= 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
= fstat(3, {st_mode=S_IFREG|0644, st_size=117640, ...}) = 0
= mmap(NULL, 117640, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5134995000
= close(3)                                = 0
= access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
= 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\0\260\34\2\0\0\0\0\0"..., 832) = 832
= fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
~ mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5134993000
~ mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f513439a000
~ mprotect(0x7f5134581000, 2097152, PROT_NONE) = 0
~ mmap(0x7f5134781000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7f5134781000
# in Rusts strace output, the .so stuff seems to happen here
~ mmap(0x7f5134787000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5134787000
= close(3)                                = 0
# rusts output adds an extra mmap here
~ arch_prctl(ARCH_SET_FS, 0x7f51349944c0) = 0
~ mprotect(0x7f5134781000, 16384, PROT_READ) = 0
~ mprotect(0x56137c2da000, 4096, PROT_READ) = 0
~ mprotect(0x7f51349b2000, 4096, PROT_READ) = 0
= munmap(0x7f5134995000, 117640)          = 0
# rust adds a whole munch of stuff here
# * a bunch of rt_sigactions
# * (i think) makes a new stack, disables it, then frees that stacks mem allocation.
= exit_group(0)                           = ?
+++ exited with 0 +++

No main for 5 syscalls

#![feature(start)]

#[start]
fn my_main(_: isize, _: *const *const u8) -> isize {
    std::process::exit(0);
}
# cargo +nightly build --target x86_64-unknown-linux-musl --release && 
# strace target/x86_64-unknown-linux-musl/release/empty

Output

execve("target/x86_64-unknown-linux-musl/release/empty", ["target/x86_64-unknown-linux-musl"...], 0x7ffc3eb56310 /* 56 vars */) = 0
mmap(NULL, 432, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7efde66b6000
arch_prctl(ARCH_SET_FS, 0x7efde66b60c0) = 0
set_tid_address(0x648c60)               = 12735
exit_group(0)                           = ?

Raw outputs

C

execve("./empty", ["./empty"], 0x7fff1435d530 /* 56 vars */) = 0
brk(NULL)                               = 0x56179ba74000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
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
fstat(3, {st_mode=S_IFREG|0644, st_size=117640, ...}) = 0
mmap(NULL, 117640, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f00f29f9000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
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\0\260\34\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f00f29f7000
mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f00f23fe000
mprotect(0x7f00f25e5000, 2097152, PROT_NONE) = 0
mmap(0x7f00f27e5000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7f00f27e5000
mmap(0x7f00f27eb000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f00f27eb000
close(3)                                = 0
arch_prctl(ARCH_SET_FS, 0x7f00f29f84c0) = 0
mprotect(0x7f00f27e5000, 16384, PROT_READ) = 0
mprotect(0x56179b53a000, 4096, PROT_READ) = 0
mprotect(0x7f00f2a16000, 4096, PROT_READ) = 0
munmap(0x7f00f29f9000, 117640)          = 0
exit_group(0)                           = ?
+++ exited with 0 +++

Rust

execve("target/release/empty", ["target/release/empty"], 0x7ffe0b5dea60 /* 56 vars */) = 0
brk(NULL)                               = 0x55eae0502000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
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
fstat(3, {st_mode=S_IFREG|0644, st_size=117640, ...}) = 0
mmap(NULL, 117640, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f4941ed7000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\16\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=14560, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4941ed5000
mmap(NULL, 2109712, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4941ac9000
mprotect(0x7f4941acc000, 2093056, PROT_NONE) = 0
mmap(0x7f4941ccb000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f4941ccb000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\"\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=31680, ...}) = 0
mmap(NULL, 2128864, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f49418c1000
mprotect(0x7f49418c8000, 2093056, PROT_NONE) = 0
mmap(0x7f4941ac7000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x6000) = 0x7f4941ac7000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000b\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=144976, ...}) = 0
mmap(NULL, 2221184, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f49416a2000
mprotect(0x7f49416bc000, 2093056, PROT_NONE) = 0
mmap(0x7f49418bb000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0x7f49418bb000
mmap(0x7f49418bd000, 13440, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f49418bd000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libgcc_s.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\300*\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=96616, ...}) = 0
mmap(NULL, 2192432, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f494148a000
mprotect(0x7f49414a1000, 2093056, PROT_NONE) = 0
mmap(0x7f49416a0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f49416a0000
close(3)                                = 0
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
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\0\260\34\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f4941099000
mprotect(0x7f4941280000, 2097152, PROT_NONE) = 0
mmap(0x7f4941480000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7f4941480000
mmap(0x7f4941486000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f4941486000
close(3)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4941ed3000
arch_prctl(ARCH_SET_FS, 0x7f4941ed42c0) = 0
mprotect(0x7f4941480000, 16384, PROT_READ) = 0
mprotect(0x7f49416a0000, 4096, PROT_READ) = 0
mprotect(0x7f49418bb000, 4096, PROT_READ) = 0
mprotect(0x7f4941ac7000, 4096, PROT_READ) = 0
mprotect(0x7f4941ccb000, 4096, PROT_READ) = 0
mprotect(0x55eadee3b000, 8192, PROT_READ) = 0
mprotect(0x7f4941ef4000, 4096, PROT_READ) = 0
munmap(0x7f4941ed7000, 117640)          = 0
set_tid_address(0x7f4941ed4590)         = 15376
set_robust_list(0x7f4941ed45a0, 24)     = 0
rt_sigaction(SIGRTMIN, {sa_handler=0x7f49416a7cb0, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f49416b4890}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {sa_handler=0x7f49416a7d50, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7f49416b4890}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f49410d7f20}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
brk(NULL)                               = 0x55eae0502000
brk(0x55eae0523000)                     = 0x55eae0523000
openat(AT_FDCWD, "/proc/self/maps", O_RDONLY|O_CLOEXEC) = 3
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
read(3, "55eadec0b000-55eadec3b000 r-xp 0"..., 1024) = 1024
read(3, "64-linux-gnu/libgcc_s.so.1\n7f494"..., 1024) = 1024
read(3, "                 /lib/x86_64-lin"..., 1024) = 1024
read(3, "                 /lib/x86_64-lin"..., 1024) = 424
close(3)                                = 0
sched_getaffinity(15376, 32, [0, 1, 2, 3]) = 8
rt_sigaction(SIGSEGV, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, {sa_handler=0x55eadec16e20, sa_mask=[], sa_flags=SA_RESTORER|SA_ONSTACK|SA_SIGINFO, sa_restorer=0x7f49416b4890}, NULL, 8) = 0
rt_sigaction(SIGBUS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGBUS, {sa_handler=0x55eadec16e20, sa_mask=[], sa_flags=SA_RESTORER|SA_ONSTACK|SA_SIGINFO, sa_restorer=0x7f49416b4890}, NULL, 8) = 0
sigaltstack(NULL, {ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=0}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4941ef2000
sigaltstack({ss_sp=0x7f4941ef2000, ss_flags=0, ss_size=8192}, NULL) = 0
sigaltstack({ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=8192}, NULL) = 0
munmap(0x7f4941ef2000, 8192)            = 0
exit_group(0)                           = ?
+++ exited with 0 +++
# cargo build --target x86_64-unknown-linux-musl --release && 
# strace target/x86_64-unknown-linux-musl/release/empty
execve("target/x86_64-unknown-linux-musl/release/empty", ["target/x86_64-unknown-linux-musl"...], 0x7ffd39ed3070 /* 56 vars */) = 0
mmap(NULL, 432, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1de30e4000
arch_prctl(ARCH_SET_FS, 0x7f1de30e40c0) = 0
set_tid_address(0x646c80)               = 9605
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x42b3db}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RT_1 RT_2], NULL, 8) = 0
rt_sigaction(SIGSEGV, {sa_handler=0x4080a0, sa_mask=[], sa_flags=SA_RESTORER|SA_ONSTACK|SA_SIGINFO, sa_restorer=0x42b3db}, NULL, 8) = 0
rt_sigaction(SIGBUS, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGBUS, {sa_handler=0x4080a0, sa_mask=[], sa_flags=SA_RESTORER|SA_ONSTACK|SA_SIGINFO, sa_restorer=0x42b3db}, NULL, 8) = 0
sigaltstack(NULL, {ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=0}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1de30e2000
sigaltstack({ss_sp=0x7f1de30e2000, ss_flags=0, ss_size=8192}, NULL) = 0
brk(NULL)                               = 0x844000
brk(0x845000)                           = 0x845000
rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
sigaltstack({ss_sp=NULL, ss_flags=SS_DISABLE, ss_size=8192}, NULL) = 0
munmap(0x7f1de30e2000, 8192)            = 0
exit_group(0)                           = ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment