Skip to content

Instantly share code, notes, and snippets.

@azat
Last active July 17, 2023 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azat/fcbd8b6c26afd505ae5f3387fc15f0e2 to your computer and use it in GitHub Desktop.
Save azat/fcbd8b6c26afd505ae5f3387fc15f0e2 to your computer and use it in GitHub Desktop.
readlink qemu linux-user handling
$ sudo arch-chroot ./ /qemu-x86_64-static /main
==> WARNING: ./ is not a mountpoint. This may have undesirable side effects.
readlink(/proc/self/exe) => /main (len: 5)
readlink(/proc/self) => 27679 (len: 5)
readlink(/proc/1/exe) => /main (len: 5)
realpath(/proc/self/exe) => /qemu-x86_64-static
AT_EXECFN = /main
$ sudo arch-chroot ./ /qemu-x86_64-static -strace /main
==> WARNING: ./ is not a mountpoint. This may have undesirable side effects.
1 arch_prctl(12289,274886296688,4320976,2561,3,2048) = -1 errno=22 (Invalid argument)
1 brk(NULL) = 0x00000000004aa888
1 brk(0x00000000004ab588) = 0x00000000004ab588
1 arch_prctl(4098,4893760,24,2561,2,4892808) = 0
1 set_tid_address(0x4aaf10) = 1
1 set_robust_list(0x4aaf20,24) = -1 errno=38 (Function not implemented)
1 Unknown syscall 334
1 prlimit64(0,RLIMIT_STACK,NULL,0x0000004000800390) = 0 ({rlim_cur=8388608,rlim_max=-1})
1 readlinkat(-100,"/proc/self/exe",0x00000040007ff310,4096) = 5
1 getrandom(0x4a9d70,8,1) = 8
1 brk(NULL) = 0x00000000004ab588
1 brk(0x00000000004cc588) = 0x00000000004cc588
1 brk(0x00000000004cd000) = 0x00000000004cd000
1 mprotect(0x000000000049f000,16384,PROT_READ) = 0
1 readlink("/proc/self/exe",0x00000040007fd2b0,4096) = 5
1 newfstatat(1,"",0x00000040007fcf00,0x1000) = 0
1 write(1,0x4aba70,43)readlink(/proc/self/exe) => /main (len: 5)
= 43
1 readlink("/proc/self",0x00000040007fd2b0,4096) = 5
1 write(1,0x4aba70,39)readlink(/proc/self) => 27806 (len: 5)
= 39
1 getpid() = 1
1 readlink("/proc/1/exe",0x00000040007fd2b0,4096) = 5
1 write(1,0x4aba70,40)readlink(/proc/1/exe) => /main (len: 5)
= 40
1 readlink("/proc",0x00000040007fde80,1023) = -1 errno=22 (Invalid argument)
1 readlink("/proc/self",0x00000040007fde80,1023) = 5
1 readlink("/proc/27806",0x00000040007fde80,1023) = -1 errno=22 (Invalid argument)
1 readlink("/proc/27806/exe",0x00000040007fde80,1023) = 19
1 readlink("/qemu-x86_64-static",0x00000040007fde80,1023) = -1 errno=22 (Invalid argument)
1 write(1,0x4aba70,48)realpath(/proc/self/exe) => /qemu-x86_64-static
= 48
1 write(1,0x4aba70,18)AT_EXECFN = /main
= 18
1 exit_group(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment