|
| 1 | +# 使用qemu运行不同指令集的架构镜像(以argv为例) |
| 2 | + |
| 3 | +将镜像文件拷贝到文件夹下,执行以下命令: |
| 4 | +``` |
| 5 | +mkdir -p mnt |
| 6 | +sudo mount xxx.img mnt |
| 7 | +``` |
| 8 | +再进入mnt/musl |
| 9 | + |
| 10 | +## riscv 架构 |
| 11 | +```shell |
| 12 | +qemu-riscv64 -strace ./runtest.exe -w entry-static.exe argv ls |
| 13 | +``` |
| 14 | + |
| 15 | +```shell |
| 16 | +14092 set_tid_address(0x1d238) = 14092 |
| 17 | +14092 rt_sigprocmask(SIG_BLOCK,0x00002aaaab2aa7a0,NULL,8) = 0 |
| 18 | +14092 rt_sigprocmask(SIG_UNBLOCK,0x00002aaaab2aa5e0,NULL,8) = 0 |
| 19 | +14092 rt_sigaction(SIGCHLD,0x00002aaaab2aa5c0,0x00002aaaab2aa5e0) = 0 |
| 20 | +14092 write(1,0xab2aa530,50)========== START entry-static.exe argv ========== |
| 21 | + = 50 |
| 22 | +14092 rt_sigprocmask(SIG_BLOCK,0x000000000001d160,0x00002aaaab2aa6f0,8) = 0 |
| 23 | +14092 clone(0x11,child_stack=0x0000000000000000,parent_tidptr=0x00002aaaab2aa6f0,tls=0x0000000000000008,child_tidptr=0x0000000000000000) = 14094 |
| 24 | + = 0 |
| 25 | +14092 rt_sigprocmask(SIG_SETMASK,0x00002aaaab2aa6f0,NULL,8) = 014094 |
| 26 | +gettid() = 14094 |
| 27 | +14094 rt_sigprocmask(SIG_SETMASK,0x00002aaaab2aa6f0,NULL,8) = 0 |
| 28 | +14092 rt_sigtimedwait(46912504506272,0,46912504506256,8,0,0)14094 prlimit64(0,RLIMIT_STACK,NULL,0x00002aaaab2aa750) = 0 ({rlim_cur=8388608,rlim_max=-1}) |
| 29 | +14094 rt_sigprocmask(SIG_BLOCK,0x000000000001d168,0x00002aaaab2aa5b8,8) = 0 |
| 30 | +14094 rt_sigprocmask(SIG_BLOCK,0x000000000001d160,NULL,8) = 0 |
| 31 | +14094 prlimit64(0,RLIMIT_STACK,{rlim_cur=102400,rlim_max=102400},NULL) = 0 |
| 32 | +14094 rt_sigprocmask(SIG_SETMASK,0x00002aaaab2aa5b8,NULL,8) = 0 |
| 33 | +14094 execve("entry-static.exe",{"entry-static.exe","argv","ls",NULL}) = -1 errno=8 (Exec format error) |
| 34 | +14094 write(1,0xab2aa530,73)src/common/runtest.c:29: entry-static.exe exec failed: Exec format error |
| 35 | + = 73 |
| 36 | +14094 exit_group(1) |
| 37 | + = 17 |
| 38 | +14092 wait4(14094,0x2aaaab2aa790,0,(nil)) = 14094 |
| 39 | +14092 write(1,0xab2aa530,21)FAIL argv [status 1] |
| 40 | + = 21 |
| 41 | +14092 write(1,0xab2aa530,48)========== END entry-static.exe argv ========== |
| 42 | + = 48 |
| 43 | +14092 exit_group(1) |
| 44 | +``` |
| 45 | + |
| 46 | +## loongarch 架构 |
| 47 | +```shell |
| 48 | +qemu-loongarch64 -strace ./runtest.exe -w entry-static.exe argv ls |
| 49 | +``` |
| 50 | + |
| 51 | +```shell |
| 52 | +21399 set_tid_address(0x120014920) = 21399 |
| 53 | +21399 rt_sigprocmask(SIG_BLOCK,0x0000555555d55780,NULL,8) = 0 |
| 54 | +21399 rt_sigprocmask(SIG_UNBLOCK,0x0000555555d555d0,NULL,8) = 0 |
| 55 | +21399 rt_sigaction(SIGCHLD,0x0000555555d555b0,0x0000555555d555d0) = 0 |
| 56 | +21399 write(1,0x55d55510,50)========== START entry-static.exe argv ========== |
| 57 | + = 50 |
| 58 | +21399 rt_sigprocmask(SIG_BLOCK,0x000000012000dc98,0x0000555555d556a0,8) = 0 |
| 59 | +21399 rt_sigprocmask(SIG_BLOCK,0x000000012000dca0,0x0000555555d55610,8) = 0 |
| 60 | +21399 clone(0x11,child_stack=0x0000000000000000,parent_tidptr=0x0000555555d55610,tls=0x0000000000000000,child_tidptr=0x0000000000000008) = 21401 |
| 61 | + = 21399 rt_sigprocmask(SIG_SETMASK,00x0000555555d55610, |
| 62 | +NULL,8) = 0 |
| 63 | +21399 21401 rt_sigprocmask(set_tid_address(0x120014920)SIG_SETMASK,0x0000555555d556a0,NULL,8) = 0 |
| 64 | + = 21401 |
| 65 | +21399 rt_sigtimedwait(93825000626048,0,93825000626032,8,0,0)21401 rt_sigprocmask(SIG_SETMASK,0x0000555555d55610,NULL,8) = 0 |
| 66 | +21401 rt_sigprocmask(SIG_SETMASK,0x0000555555d556a0,NULL,8) = 0 |
| 67 | +21401 prlimit64(0,RLIMIT_STACK,NULL,0x0000555555d55730) = 0 ({rlim_cur=8388608,rlim_max=-1}) |
| 68 | +21401 prlimit64(0,RLIMIT_STACK,{rlim_cur=102400,rlim_max=102400},NULL) = 0 |
| 69 | +21401 execve("entry-static.exe",{"entry-static.exe","argv","ls",NULL}) = -1 errno=8 (Exec format error) |
| 70 | +21401 write(1,0x55d55510,73)src/common/runtest.c:29: entry-static.exe exec failed: Exec format error |
| 71 | + = 73 |
| 72 | +21401 exit_group(1) |
| 73 | + = 17 |
| 74 | +21399 wait4(21401,0x555555d55770,0,(nil)) = 21401 |
| 75 | +21399 write(1,0x55d55510,21)FAIL argv [status 1] |
| 76 | + = 21 |
| 77 | +21399 write(1,0x55d55510,48)========== END entry-static.exe argv ========== |
| 78 | + = 48 |
| 79 | +21399 exit_group(1) |
| 80 | +``` |
| 81 | + |
| 82 | +## aarch64 架构 |
| 83 | +```shell |
| 84 | +qemu-aarch64 -strace ./runtest.exe -w entry-static.exe argv ls |
| 85 | +``` |
| 86 | + |
| 87 | +```shell |
| 88 | +23575 set_tid_address(0x41d7f8) = 23575 |
| 89 | +23575 rt_sigprocmask(SIG_BLOCK,0x00004000007ff7c0,NULL,8) = 0 |
| 90 | +23575 rt_sigprocmask(SIG_UNBLOCK,0x00004000007ff5c0,NULL,8) = 0 |
| 91 | +23575 rt_sigaction(SIGCHLD,0x00004000007ff5a0,0x00004000007ff5c0) = 0 |
| 92 | +23575 write(1,0x7ff4a0,50)========== START entry-static.exe argv ========== |
| 93 | + = 50 |
| 94 | +23575 rt_sigprocmask(SIG_BLOCK,0x000000000040bc28,0x00004000007ff6e0,8) = 0 |
| 95 | +23575 rt_sigprocmask(SIG_BLOCK,0x000000000040bc20,0x00004000007ff620,8) = 0 |
| 96 | +23575 clone(0x11,child_stack=0x0000000000000000,parent_tidptr=0x0000000000000000,tls=0x0000000000000008,child_tidptr=0x0000000000000000) = 23577 |
| 97 | + = 0 |
| 98 | +23575 rt_sigprocmask(SIG_SETMASK,0x00004000007ff620,NULL,8) = 023577 |
| 99 | +gettid() = 23577 |
| 100 | +23577 rt_sigprocmask(SIG_SETMASK,0x00004000007ff620,NULL,8) = 0 |
| 101 | +23577 23575 rt_sigprocmask(rt_sigprocmask(SIG_SETMASK,SIG_SETMASK,0x00004000007ff6e0,0x00004000007ff6e0,NULL,NULL,88)) = 0 = |
| 102 | +0 |
| 103 | +23577 prlimit64(0,RLIMIT_STACK,NULL,0x00004000007ff750) = 0 ({rlim_cur=8388608,rlim_max=-1}) |
| 104 | +23575 rt_sigtimedwait(70368752564160,0,70368752564144,8,0,0)23577 prlimit64(0,RLIMIT_STACK,{rlim_cur=102400,rlim_max=102400},NULL) = 0 |
| 105 | +23577 execve("entry-static.exe",{"entry-static.exe","argv","ls",NULL}) = -1 errno=8 (Exec format error) |
| 106 | +23577 write(1,0x7ff4a0,73)src/common/runtest.c:29: entry-static.exe exec failed: Exec format error |
| 107 | + = 73 |
| 108 | +23577 exit_group(1) |
| 109 | + = 17 |
| 110 | +23575 wait4(23577,0x4000007ff7b0,0,(nil)) = 23577 |
| 111 | +23575 write(1,0x7ff4a0,21)FAIL argv [status 1] |
| 112 | + = 21 |
| 113 | +23575 write(1,0x7ff4a0,48)========== END entry-static.exe argv ========== |
| 114 | + = 48 |
| 115 | +23575 exit_group(1) |
| 116 | +``` |
0 commit comments