vx32-gccã¨libvxcã¨vxrun
ã¨ãããã§ãã°ããèãã¦ã¿ããvx32-gccãã©ããªãã¤ããªãåºåããã¨ãã¨ããã¨ã
$ vx32-gcc hello.c $ file a.out a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), statically linked, not stripped
ELFå½¢å¼ã ãå½ç¶ãå®è¡ã¯ã§ããªãã
$ ./a.out -bash: ./a.out: cannot execute binary file
vx32-gccãæ®éã®gccã¨ä½ãéãã®ããã¾ã ããã£ã¦ããªãããlibcã«ã¯libvxcã¨ããç¬èªã®ãã®ã使ããã¦ããããã¼ã¹ã«ãªã£ã¦ããã®ã¯FreeBSDã®libcã¿ããã ãã©ãã·ã¹ãã ã³ã¼ã«å¼ã³åºãã¯ãã¹ã¦vx32ã®ãã©ããï¼æ£ç¢ºã«ã¯syscallå½ä»¤ãå®è¡ããï¼ã«ç½®ãæãããããä¾ãã°ãopenã¯ããããªæãã
int open(const char *path, int flags, int mode) { return syscall(VXSYSOPEN, (int)path, flags, mode, 0, 0); }
vx32ã«ã¯ãã®a.outãå®è¡ã§ãããvxrunã¨ããããã°ã©ã ãå梱ããã¦ããããããvxlinuxã¨åæ§ãªã«ã¼ãã«ãªã£ã¦ãã¦ãvxproc_runãVXTRAP_SYSCALLã§ä¸æãããããã·ã¹ãã ã³ã¼ã«å¦çããããï¼vxlinuxã¨vxrunã®éãã¯åè ãLinuxãã¹ãOSä¸ã§Linuxã®å®è¡ãã¤ããªãå¤æ´ãªãã§å®è¡ã§ããã®ã«å¯¾ãã¦ãvxrunã¯OSéä¾åãªä»çµã¿ã§ãããï¼
static void dosyscall(vxproc *proc) { : switch (NUM) { : case VXSYSOPEN: addr = ARG1; mode = ARG2; umode = mode&3; if(mode & VXC_O_CREAT) umode |= O_CREAT; if(mode & VXC_O_EXCL) umode |= O_EXCL; if(mode & VXC_O_NOCTTY) umode |= O_NOCTTY; if(mode & VXC_O_TRUNC) umode |= O_TRUNC; if(mode & VXC_O_APPEND) umode |= O_APPEND; if(mode & VXC_O_NONBLOCK) umode |= O_NONBLOCK; if(mode & VXC_O_SYNC) umode |= O_SYNC; if (!checkstring(proc->mem, m->base, addr)) goto einval; ret = open((char*)m->base+addr, umode, ARG3); if(trace) fprintf(stderr, "open %s %#x %#o => %d\n", (char*)m->base+addr, ARG2, ARG3, ret); break;
è¦ã¦ãããããã«ãvx32ã®ã·ã¹ãã ã³ã¼ã«ããã¹ãOSã¸ã®ã·ã¹ãã ã³ã¼ã«å¼åºãã«æ¸ãæãã¦ããã
9vxãä¼¼ããããªæµãã«ãªããã ããã
ãããªæãã§ã¦ã¼ã¶ã¬ãã«OSæ¸ãã¦ã¿ã¾ããï¼ï¼