Commit 84778508d7403cd32fb4527550738f19aa7b1aa5
1 parent
46f42f29
Preliminary BSD user emulator support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5544 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
13 changed files
with
4708 additions
and
0 deletions
Too many changes to show.
To preserve performance only 13 of 24 files are displayed.
Makefile.target
| ... | ... | @@ -470,6 +470,111 @@ $(QEMU_PROG): $(OBJS) |
| 470 | 470 | endif #CONFIG_DARWIN_USER |
| 471 | 471 | |
| 472 | 472 | ######################################################### |
| 473 | +# BSD user emulator target | |
| 474 | + | |
| 475 | +ifdef CONFIG_BSD_USER | |
| 476 | + | |
| 477 | +VPATH+=:$(SRC_PATH)/bsd-user | |
| 478 | +CPPFLAGS+=-I$(SRC_PATH)/bsd-user -I$(SRC_PATH)/bsd-user/$(TARGET_ARCH) | |
| 479 | + | |
| 480 | +ifdef CONFIG_STATIC | |
| 481 | +LDFLAGS+=-static | |
| 482 | +endif | |
| 483 | + | |
| 484 | +ifeq ($(ARCH),i386) | |
| 485 | +ifdef TARGET_GPROF | |
| 486 | +USE_I386_LD=y | |
| 487 | +endif | |
| 488 | +ifdef CONFIG_STATIC | |
| 489 | +USE_I386_LD=y | |
| 490 | +endif | |
| 491 | +ifdef USE_I386_LD | |
| 492 | +LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld | |
| 493 | +else | |
| 494 | +# WARNING: this LDFLAGS is _very_ tricky : qemu is an ELF shared object | |
| 495 | +# that the kernel ELF loader considers as an executable. I think this | |
| 496 | +# is the simplest way to make it self virtualizable! | |
| 497 | +LDFLAGS+=-Wl,-shared | |
| 498 | +endif | |
| 499 | +endif | |
| 500 | + | |
| 501 | +ifeq ($(ARCH),x86_64) | |
| 502 | +LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld | |
| 503 | +endif | |
| 504 | + | |
| 505 | +ifeq ($(ARCH),ppc) | |
| 506 | +LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld | |
| 507 | +endif | |
| 508 | + | |
| 509 | +ifeq ($(ARCH),ppc64) | |
| 510 | +LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld | |
| 511 | +endif | |
| 512 | + | |
| 513 | +ifeq ($(ARCH),s390) | |
| 514 | +LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld | |
| 515 | +endif | |
| 516 | + | |
| 517 | +ifeq ($(ARCH),sparc) | |
| 518 | +# -static is used to avoid g1/g3 usage by the dynamic linker | |
| 519 | +LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld -static | |
| 520 | +endif | |
| 521 | + | |
| 522 | +ifeq ($(ARCH),sparc64) | |
| 523 | +LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld | |
| 524 | +endif | |
| 525 | + | |
| 526 | +ifeq ($(ARCH),alpha) | |
| 527 | +LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld | |
| 528 | +endif | |
| 529 | + | |
| 530 | +ifeq ($(ARCH),ia64) | |
| 531 | +LDFLAGS+=-Wl,-G0 -Wl,-T,$(SRC_PATH)/$(ARCH).ld | |
| 532 | +endif | |
| 533 | + | |
| 534 | +ifeq ($(ARCH),arm) | |
| 535 | +LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld | |
| 536 | +endif | |
| 537 | + | |
| 538 | +ifeq ($(ARCH),m68k) | |
| 539 | +LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld | |
| 540 | +endif | |
| 541 | + | |
| 542 | +ifeq ($(ARCH),mips) | |
| 543 | +ifeq ($(WORDS_BIGENDIAN),yes) | |
| 544 | +LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld | |
| 545 | +else | |
| 546 | +LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld | |
| 547 | +endif | |
| 548 | +endif | |
| 549 | + | |
| 550 | +ifeq ($(ARCH),mips64) | |
| 551 | +ifeq ($(WORDS_BIGENDIAN),yes) | |
| 552 | +LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH).ld | |
| 553 | +else | |
| 554 | +LDFLAGS+=-Wl,-T,$(SRC_PATH)/$(ARCH)el.ld | |
| 555 | +endif | |
| 556 | +endif | |
| 557 | + | |
| 558 | +OBJS= main.o bsdload.o elfload.o mmap.o path.o signal.o strace.o syscall.o | |
| 559 | +OBJS+= uaccess.o | |
| 560 | + | |
| 561 | +OBJS+= libqemu.a | |
| 562 | + | |
| 563 | +ifdef CONFIG_GDBSTUB | |
| 564 | +OBJS+=gdbstub.o | |
| 565 | +endif | |
| 566 | + | |
| 567 | +# Note: this is a workaround. The real fix is to avoid compiling | |
| 568 | +# cpu_signal_handler() in cpu-exec.c. | |
| 569 | +signal.o: signal.c | |
| 570 | + $(CC) $(HELPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< | |
| 571 | + | |
| 572 | +$(QEMU_PROG): $(OBJS) ../libqemu_user.a | |
| 573 | + $(CC) $(LDFLAGS) -o $@ $^ $(LIBS) | |
| 574 | + | |
| 575 | +endif #CONFIG_BSD_USER | |
| 576 | + | |
| 577 | +######################################################### | |
| 473 | 578 | # System emulator target |
| 474 | 579 | ifndef CONFIG_USER_ONLY |
| 475 | 580 | ... | ... |
bsd-user/bsdload.c
0 โ 100644
| 1 | +/* Code for loading BSD executables. Mostly linux kernel code. */ | |
| 2 | + | |
| 3 | +#include <sys/types.h> | |
| 4 | +#include <sys/stat.h> | |
| 5 | +#include <fcntl.h> | |
| 6 | +#include <errno.h> | |
| 7 | +#include <unistd.h> | |
| 8 | +#include <stdio.h> | |
| 9 | +#include <stdlib.h> | |
| 10 | + | |
| 11 | +#include "qemu.h" | |
| 12 | + | |
| 13 | +#define NGROUPS 32 | |
| 14 | + | |
| 15 | +/* ??? This should really be somewhere else. */ | |
| 16 | +abi_long memcpy_to_target(abi_ulong dest, const void *src, | |
| 17 | + unsigned long len) | |
| 18 | +{ | |
| 19 | + void *host_ptr; | |
| 20 | + | |
| 21 | + host_ptr = lock_user(VERIFY_WRITE, dest, len, 0); | |
| 22 | + if (!host_ptr) | |
| 23 | + return -TARGET_EFAULT; | |
| 24 | + memcpy(host_ptr, src, len); | |
| 25 | + unlock_user(host_ptr, dest, 1); | |
| 26 | + return 0; | |
| 27 | +} | |
| 28 | + | |
| 29 | +static int in_group_p(gid_t g) | |
| 30 | +{ | |
| 31 | + /* return TRUE if we're in the specified group, FALSE otherwise */ | |
| 32 | + int ngroup; | |
| 33 | + int i; | |
| 34 | + gid_t grouplist[NGROUPS]; | |
| 35 | + | |
| 36 | + ngroup = getgroups(NGROUPS, grouplist); | |
| 37 | + for(i = 0; i < ngroup; i++) { | |
| 38 | + if(grouplist[i] == g) { | |
| 39 | + return 1; | |
| 40 | + } | |
| 41 | + } | |
| 42 | + return 0; | |
| 43 | +} | |
| 44 | + | |
| 45 | +static int count(char ** vec) | |
| 46 | +{ | |
| 47 | + int i; | |
| 48 | + | |
| 49 | + for(i = 0; *vec; i++) { | |
| 50 | + vec++; | |
| 51 | + } | |
| 52 | + | |
| 53 | + return(i); | |
| 54 | +} | |
| 55 | + | |
| 56 | +static int prepare_binprm(struct linux_binprm *bprm) | |
| 57 | +{ | |
| 58 | + struct stat st; | |
| 59 | + int mode; | |
| 60 | + int retval, id_change; | |
| 61 | + | |
| 62 | + if(fstat(bprm->fd, &st) < 0) { | |
| 63 | + return(-errno); | |
| 64 | + } | |
| 65 | + | |
| 66 | + mode = st.st_mode; | |
| 67 | + if(!S_ISREG(mode)) { /* Must be regular file */ | |
| 68 | + return(-EACCES); | |
| 69 | + } | |
| 70 | + if(!(mode & 0111)) { /* Must have at least one execute bit set */ | |
| 71 | + return(-EACCES); | |
| 72 | + } | |
| 73 | + | |
| 74 | + bprm->e_uid = geteuid(); | |
| 75 | + bprm->e_gid = getegid(); | |
| 76 | + id_change = 0; | |
| 77 | + | |
| 78 | + /* Set-uid? */ | |
| 79 | + if(mode & S_ISUID) { | |
| 80 | + bprm->e_uid = st.st_uid; | |
| 81 | + if(bprm->e_uid != geteuid()) { | |
| 82 | + id_change = 1; | |
| 83 | + } | |
| 84 | + } | |
| 85 | + | |
| 86 | + /* Set-gid? */ | |
| 87 | + /* | |
| 88 | + * If setgid is set but no group execute bit then this | |
| 89 | + * is a candidate for mandatory locking, not a setgid | |
| 90 | + * executable. | |
| 91 | + */ | |
| 92 | + if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { | |
| 93 | + bprm->e_gid = st.st_gid; | |
| 94 | + if (!in_group_p(bprm->e_gid)) { | |
| 95 | + id_change = 1; | |
| 96 | + } | |
| 97 | + } | |
| 98 | + | |
| 99 | + memset(bprm->buf, 0, sizeof(bprm->buf)); | |
| 100 | + retval = lseek(bprm->fd, 0L, SEEK_SET); | |
| 101 | + if(retval >= 0) { | |
| 102 | + retval = read(bprm->fd, bprm->buf, 128); | |
| 103 | + } | |
| 104 | + if(retval < 0) { | |
| 105 | + perror("prepare_binprm"); | |
| 106 | + exit(-1); | |
| 107 | + /* return(-errno); */ | |
| 108 | + } | |
| 109 | + else { | |
| 110 | + return(retval); | |
| 111 | + } | |
| 112 | +} | |
| 113 | + | |
| 114 | +/* Construct the envp and argv tables on the target stack. */ | |
| 115 | +abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp, | |
| 116 | + abi_ulong stringp, int push_ptr) | |
| 117 | +{ | |
| 118 | + int n = sizeof(abi_ulong); | |
| 119 | + abi_ulong envp; | |
| 120 | + abi_ulong argv; | |
| 121 | + | |
| 122 | + sp -= (envc + 1) * n; | |
| 123 | + envp = sp; | |
| 124 | + sp -= (argc + 1) * n; | |
| 125 | + argv = sp; | |
| 126 | + if (push_ptr) { | |
| 127 | + /* FIXME - handle put_user() failures */ | |
| 128 | + sp -= n; | |
| 129 | + put_user_ual(envp, sp); | |
| 130 | + sp -= n; | |
| 131 | + put_user_ual(argv, sp); | |
| 132 | + } | |
| 133 | + sp -= n; | |
| 134 | + /* FIXME - handle put_user() failures */ | |
| 135 | + put_user_ual(argc, sp); | |
| 136 | + | |
| 137 | + while (argc-- > 0) { | |
| 138 | + /* FIXME - handle put_user() failures */ | |
| 139 | + put_user_ual(stringp, argv); | |
| 140 | + argv += n; | |
| 141 | + stringp += target_strlen(stringp) + 1; | |
| 142 | + } | |
| 143 | + /* FIXME - handle put_user() failures */ | |
| 144 | + put_user_ual(0, argv); | |
| 145 | + while (envc-- > 0) { | |
| 146 | + /* FIXME - handle put_user() failures */ | |
| 147 | + put_user_ual(stringp, envp); | |
| 148 | + envp += n; | |
| 149 | + stringp += target_strlen(stringp) + 1; | |
| 150 | + } | |
| 151 | + /* FIXME - handle put_user() failures */ | |
| 152 | + put_user_ual(0, envp); | |
| 153 | + | |
| 154 | + return sp; | |
| 155 | +} | |
| 156 | + | |
| 157 | +int loader_exec(const char * filename, char ** argv, char ** envp, | |
| 158 | + struct target_pt_regs * regs, struct image_info *infop) | |
| 159 | +{ | |
| 160 | + struct linux_binprm bprm; | |
| 161 | + int retval; | |
| 162 | + int i; | |
| 163 | + | |
| 164 | + bprm.p = TARGET_PAGE_SIZE*MAX_ARG_PAGES-sizeof(unsigned int); | |
| 165 | + for (i=0 ; i<MAX_ARG_PAGES ; i++) /* clear page-table */ | |
| 166 | + bprm.page[i] = 0; | |
| 167 | + retval = open(filename, O_RDONLY); | |
| 168 | + if (retval < 0) | |
| 169 | + return retval; | |
| 170 | + bprm.fd = retval; | |
| 171 | + bprm.filename = (char *)filename; | |
| 172 | + bprm.argc = count(argv); | |
| 173 | + bprm.argv = argv; | |
| 174 | + bprm.envc = count(envp); | |
| 175 | + bprm.envp = envp; | |
| 176 | + | |
| 177 | + retval = prepare_binprm(&bprm); | |
| 178 | + | |
| 179 | + infop->host_argv = argv; | |
| 180 | + | |
| 181 | + if(retval>=0) { | |
| 182 | + if (bprm.buf[0] == 0x7f | |
| 183 | + && bprm.buf[1] == 'E' | |
| 184 | + && bprm.buf[2] == 'L' | |
| 185 | + && bprm.buf[3] == 'F') { | |
| 186 | + retval = load_elf_binary(&bprm,regs,infop); | |
| 187 | + } else { | |
| 188 | + fprintf(stderr, "Unknown binary format\n"); | |
| 189 | + return -1; | |
| 190 | + } | |
| 191 | + } | |
| 192 | + | |
| 193 | + if(retval>=0) { | |
| 194 | + /* success. Initialize important registers */ | |
| 195 | + do_init_thread(regs, infop); | |
| 196 | + return retval; | |
| 197 | + } | |
| 198 | + | |
| 199 | + /* Something went wrong, return the inode and free the argument pages*/ | |
| 200 | + for (i=0 ; i<MAX_ARG_PAGES ; i++) { | |
| 201 | + free(bprm.page[i]); | |
| 202 | + } | |
| 203 | + return(retval); | |
| 204 | +} | ... | ... |
bsd-user/elfload.c
0 โ 100644
| 1 | +/* This is the Linux kernel elf-loading code, ported into user space */ | |
| 2 | + | |
| 3 | +#include <stdio.h> | |
| 4 | +#include <sys/types.h> | |
| 5 | +#include <fcntl.h> | |
| 6 | +#include <errno.h> | |
| 7 | +#include <unistd.h> | |
| 8 | +#include <sys/mman.h> | |
| 9 | +#include <stdlib.h> | |
| 10 | +#include <string.h> | |
| 11 | + | |
| 12 | +#include "qemu.h" | |
| 13 | +#include "disas.h" | |
| 14 | + | |
| 15 | +#ifdef __powerpc64__ | |
| 16 | +#undef ARCH_DLINFO | |
| 17 | +#undef ELF_PLATFORM | |
| 18 | +#undef ELF_HWCAP | |
| 19 | +#undef ELF_CLASS | |
| 20 | +#undef ELF_DATA | |
| 21 | +#undef ELF_ARCH | |
| 22 | +#endif | |
| 23 | + | |
| 24 | +/* from personality.h */ | |
| 25 | + | |
| 26 | +/* | |
| 27 | + * Flags for bug emulation. | |
| 28 | + * | |
| 29 | + * These occupy the top three bytes. | |
| 30 | + */ | |
| 31 | +enum { | |
| 32 | + ADDR_NO_RANDOMIZE = 0x0040000, /* disable randomization of VA space */ | |
| 33 | + FDPIC_FUNCPTRS = 0x0080000, /* userspace function ptrs point to descriptors | |
| 34 | + * (signal handling) | |
| 35 | + */ | |
| 36 | + MMAP_PAGE_ZERO = 0x0100000, | |
| 37 | + ADDR_COMPAT_LAYOUT = 0x0200000, | |
| 38 | + READ_IMPLIES_EXEC = 0x0400000, | |
| 39 | + ADDR_LIMIT_32BIT = 0x0800000, | |
| 40 | + SHORT_INODE = 0x1000000, | |
| 41 | + WHOLE_SECONDS = 0x2000000, | |
| 42 | + STICKY_TIMEOUTS = 0x4000000, | |
| 43 | + ADDR_LIMIT_3GB = 0x8000000, | |
| 44 | +}; | |
| 45 | + | |
| 46 | +/* | |
| 47 | + * Personality types. | |
| 48 | + * | |
| 49 | + * These go in the low byte. Avoid using the top bit, it will | |
| 50 | + * conflict with error returns. | |
| 51 | + */ | |
| 52 | +enum { | |
| 53 | + PER_LINUX = 0x0000, | |
| 54 | + PER_LINUX_32BIT = 0x0000 | ADDR_LIMIT_32BIT, | |
| 55 | + PER_LINUX_FDPIC = 0x0000 | FDPIC_FUNCPTRS, | |
| 56 | + PER_SVR4 = 0x0001 | STICKY_TIMEOUTS | MMAP_PAGE_ZERO, | |
| 57 | + PER_SVR3 = 0x0002 | STICKY_TIMEOUTS | SHORT_INODE, | |
| 58 | + PER_SCOSVR3 = 0x0003 | STICKY_TIMEOUTS | | |
| 59 | + WHOLE_SECONDS | SHORT_INODE, | |
| 60 | + PER_OSR5 = 0x0003 | STICKY_TIMEOUTS | WHOLE_SECONDS, | |
| 61 | + PER_WYSEV386 = 0x0004 | STICKY_TIMEOUTS | SHORT_INODE, | |
| 62 | + PER_ISCR4 = 0x0005 | STICKY_TIMEOUTS, | |
| 63 | + PER_BSD = 0x0006, | |
| 64 | + PER_SUNOS = 0x0006 | STICKY_TIMEOUTS, | |
| 65 | + PER_XENIX = 0x0007 | STICKY_TIMEOUTS | SHORT_INODE, | |
| 66 | + PER_LINUX32 = 0x0008, | |
| 67 | + PER_LINUX32_3GB = 0x0008 | ADDR_LIMIT_3GB, | |
| 68 | + PER_IRIX32 = 0x0009 | STICKY_TIMEOUTS,/* IRIX5 32-bit */ | |
| 69 | + PER_IRIXN32 = 0x000a | STICKY_TIMEOUTS,/* IRIX6 new 32-bit */ | |
| 70 | + PER_IRIX64 = 0x000b | STICKY_TIMEOUTS,/* IRIX6 64-bit */ | |
| 71 | + PER_RISCOS = 0x000c, | |
| 72 | + PER_SOLARIS = 0x000d | STICKY_TIMEOUTS, | |
| 73 | + PER_UW7 = 0x000e | STICKY_TIMEOUTS | MMAP_PAGE_ZERO, | |
| 74 | + PER_OSF4 = 0x000f, /* OSF/1 v4 */ | |
| 75 | + PER_HPUX = 0x0010, | |
| 76 | + PER_MASK = 0x00ff, | |
| 77 | +}; | |
| 78 | + | |
| 79 | +/* | |
| 80 | + * Return the base personality without flags. | |
| 81 | + */ | |
| 82 | +#define personality(pers) (pers & PER_MASK) | |
| 83 | + | |
| 84 | +/* this flag is uneffective under linux too, should be deleted */ | |
| 85 | +#ifndef MAP_DENYWRITE | |
| 86 | +#define MAP_DENYWRITE 0 | |
| 87 | +#endif | |
| 88 | + | |
| 89 | +/* should probably go in elf.h */ | |
| 90 | +#ifndef ELIBBAD | |
| 91 | +#define ELIBBAD 80 | |
| 92 | +#endif | |
| 93 | + | |
| 94 | +#ifdef TARGET_I386 | |
| 95 | + | |
| 96 | +#define ELF_PLATFORM get_elf_platform() | |
| 97 | + | |
| 98 | +static const char *get_elf_platform(void) | |
| 99 | +{ | |
| 100 | + static char elf_platform[] = "i386"; | |
| 101 | + int family = (thread_env->cpuid_version >> 8) & 0xff; | |
| 102 | + if (family > 6) | |
| 103 | + family = 6; | |
| 104 | + if (family >= 3) | |
| 105 | + elf_platform[1] = '0' + family; | |
| 106 | + return elf_platform; | |
| 107 | +} | |
| 108 | + | |
| 109 | +#define ELF_HWCAP get_elf_hwcap() | |
| 110 | + | |
| 111 | +static uint32_t get_elf_hwcap(void) | |
| 112 | +{ | |
| 113 | + return thread_env->cpuid_features; | |
| 114 | +} | |
| 115 | + | |
| 116 | +#ifdef TARGET_X86_64 | |
| 117 | +#define ELF_START_MMAP 0x2aaaaab000ULL | |
| 118 | +#define elf_check_arch(x) ( ((x) == ELF_ARCH) ) | |
| 119 | + | |
| 120 | +#define ELF_CLASS ELFCLASS64 | |
| 121 | +#define ELF_DATA ELFDATA2LSB | |
| 122 | +#define ELF_ARCH EM_X86_64 | |
| 123 | + | |
| 124 | +static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) | |
| 125 | +{ | |
| 126 | + regs->rax = 0; | |
| 127 | + regs->rsp = infop->start_stack; | |
| 128 | + regs->rip = infop->entry; | |
| 129 | +} | |
| 130 | + | |
| 131 | +#else | |
| 132 | + | |
| 133 | +#define ELF_START_MMAP 0x80000000 | |
| 134 | + | |
| 135 | +/* | |
| 136 | + * This is used to ensure we don't load something for the wrong architecture. | |
| 137 | + */ | |
| 138 | +#define elf_check_arch(x) ( ((x) == EM_386) || ((x) == EM_486) ) | |
| 139 | + | |
| 140 | +/* | |
| 141 | + * These are used to set parameters in the core dumps. | |
| 142 | + */ | |
| 143 | +#define ELF_CLASS ELFCLASS32 | |
| 144 | +#define ELF_DATA ELFDATA2LSB | |
| 145 | +#define ELF_ARCH EM_386 | |
| 146 | + | |
| 147 | +static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) | |
| 148 | +{ | |
| 149 | + regs->esp = infop->start_stack; | |
| 150 | + regs->eip = infop->entry; | |
| 151 | + | |
| 152 | + /* SVR4/i386 ABI (pages 3-31, 3-32) says that when the program | |
| 153 | + starts %edx contains a pointer to a function which might be | |
| 154 | + registered using `atexit'. This provides a mean for the | |
| 155 | + dynamic linker to call DT_FINI functions for shared libraries | |
| 156 | + that have been loaded before the code runs. | |
| 157 | + | |
| 158 | + A value of 0 tells we have no such handler. */ | |
| 159 | + regs->edx = 0; | |
| 160 | +} | |
| 161 | +#endif | |
| 162 | + | |
| 163 | +#define USE_ELF_CORE_DUMP | |
| 164 | +#define ELF_EXEC_PAGESIZE 4096 | |
| 165 | + | |
| 166 | +#endif | |
| 167 | + | |
| 168 | +#ifdef TARGET_ARM | |
| 169 | + | |
| 170 | +#define ELF_START_MMAP 0x80000000 | |
| 171 | + | |
| 172 | +#define elf_check_arch(x) ( (x) == EM_ARM ) | |
| 173 | + | |
| 174 | +#define ELF_CLASS ELFCLASS32 | |
| 175 | +#ifdef TARGET_WORDS_BIGENDIAN | |
| 176 | +#define ELF_DATA ELFDATA2MSB | |
| 177 | +#else | |
| 178 | +#define ELF_DATA ELFDATA2LSB | |
| 179 | +#endif | |
| 180 | +#define ELF_ARCH EM_ARM | |
| 181 | + | |
| 182 | +static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) | |
| 183 | +{ | |
| 184 | + abi_long stack = infop->start_stack; | |
| 185 | + memset(regs, 0, sizeof(*regs)); | |
| 186 | + regs->ARM_cpsr = 0x10; | |
| 187 | + if (infop->entry & 1) | |
| 188 | + regs->ARM_cpsr |= CPSR_T; | |
| 189 | + regs->ARM_pc = infop->entry & 0xfffffffe; | |
| 190 | + regs->ARM_sp = infop->start_stack; | |
| 191 | + /* FIXME - what to for failure of get_user()? */ | |
| 192 | + get_user_ual(regs->ARM_r2, stack + 8); /* envp */ | |
| 193 | + get_user_ual(regs->ARM_r1, stack + 4); /* envp */ | |
| 194 | + /* XXX: it seems that r0 is zeroed after ! */ | |
| 195 | + regs->ARM_r0 = 0; | |
| 196 | + /* For uClinux PIC binaries. */ | |
| 197 | + /* XXX: Linux does this only on ARM with no MMU (do we care ?) */ | |
| 198 | + regs->ARM_r10 = infop->start_data; | |
| 199 | +} | |
| 200 | + | |
| 201 | +#define USE_ELF_CORE_DUMP | |
| 202 | +#define ELF_EXEC_PAGESIZE 4096 | |
| 203 | + | |
| 204 | +enum | |
| 205 | +{ | |
| 206 | + ARM_HWCAP_ARM_SWP = 1 << 0, | |
| 207 | + ARM_HWCAP_ARM_HALF = 1 << 1, | |
| 208 | + ARM_HWCAP_ARM_THUMB = 1 << 2, | |
| 209 | + ARM_HWCAP_ARM_26BIT = 1 << 3, | |
| 210 | + ARM_HWCAP_ARM_FAST_MULT = 1 << 4, | |
| 211 | + ARM_HWCAP_ARM_FPA = 1 << 5, | |
| 212 | + ARM_HWCAP_ARM_VFP = 1 << 6, | |
| 213 | + ARM_HWCAP_ARM_EDSP = 1 << 7, | |
| 214 | +}; | |
| 215 | + | |
| 216 | +#define ELF_HWCAP (ARM_HWCAP_ARM_SWP | ARM_HWCAP_ARM_HALF \ | |
| 217 | + | ARM_HWCAP_ARM_THUMB | ARM_HWCAP_ARM_FAST_MULT \ | |
| 218 | + | ARM_HWCAP_ARM_FPA | ARM_HWCAP_ARM_VFP) | |
| 219 | + | |
| 220 | +#endif | |
| 221 | + | |
| 222 | +#ifdef TARGET_SPARC | |
| 223 | +#ifdef TARGET_SPARC64 | |
| 224 | + | |
| 225 | +#define ELF_START_MMAP 0x80000000 | |
| 226 | + | |
| 227 | +#ifndef TARGET_ABI32 | |
| 228 | +#define elf_check_arch(x) ( (x) == EM_SPARCV9 || (x) == EM_SPARC32PLUS ) | |
| 229 | +#else | |
| 230 | +#define elf_check_arch(x) ( (x) == EM_SPARC32PLUS || (x) == EM_SPARC ) | |
| 231 | +#endif | |
| 232 | + | |
| 233 | +#define ELF_CLASS ELFCLASS64 | |
| 234 | +#define ELF_DATA ELFDATA2MSB | |
| 235 | +#define ELF_ARCH EM_SPARCV9 | |
| 236 | + | |
| 237 | +#define STACK_BIAS 2047 | |
| 238 | + | |
| 239 | +static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) | |
| 240 | +{ | |
| 241 | +#ifndef TARGET_ABI32 | |
| 242 | + regs->tstate = 0; | |
| 243 | +#endif | |
| 244 | + regs->pc = infop->entry; | |
| 245 | + regs->npc = regs->pc + 4; | |
| 246 | + regs->y = 0; | |
| 247 | +#ifdef TARGET_ABI32 | |
| 248 | + regs->u_regs[14] = infop->start_stack - 16 * 4; | |
| 249 | +#else | |
| 250 | + if (personality(infop->personality) == PER_LINUX32) | |
| 251 | + regs->u_regs[14] = infop->start_stack - 16 * 4; | |
| 252 | + else | |
| 253 | + regs->u_regs[14] = infop->start_stack - 16 * 8 - STACK_BIAS; | |
| 254 | +#endif | |
| 255 | +} | |
| 256 | + | |
| 257 | +#else | |
| 258 | +#define ELF_START_MMAP 0x80000000 | |
| 259 | + | |
| 260 | +#define elf_check_arch(x) ( (x) == EM_SPARC ) | |
| 261 | + | |
| 262 | +#define ELF_CLASS ELFCLASS32 | |
| 263 | +#define ELF_DATA ELFDATA2MSB | |
| 264 | +#define ELF_ARCH EM_SPARC | |
| 265 | + | |
| 266 | +static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) | |
| 267 | +{ | |
| 268 | + regs->psr = 0; | |
| 269 | + regs->pc = infop->entry; | |
| 270 | + regs->npc = regs->pc + 4; | |
| 271 | + regs->y = 0; | |
| 272 | + regs->u_regs[14] = infop->start_stack - 16 * 4; | |
| 273 | +} | |
| 274 | + | |
| 275 | +#endif | |
| 276 | +#endif | |
| 277 | + | |
| 278 | +#ifdef TARGET_PPC | |
| 279 | + | |
| 280 | +#define ELF_START_MMAP 0x80000000 | |
| 281 | + | |
| 282 | +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32) | |
| 283 | + | |
| 284 | +#define elf_check_arch(x) ( (x) == EM_PPC64 ) | |
| 285 | + | |
| 286 | +#define ELF_CLASS ELFCLASS64 | |
| 287 | + | |
| 288 | +#else | |
| 289 | + | |
| 290 | +#define elf_check_arch(x) ( (x) == EM_PPC ) | |
| 291 | + | |
| 292 | +#define ELF_CLASS ELFCLASS32 | |
| 293 | + | |
| 294 | +#endif | |
| 295 | + | |
| 296 | +#ifdef TARGET_WORDS_BIGENDIAN | |
| 297 | +#define ELF_DATA ELFDATA2MSB | |
| 298 | +#else | |
| 299 | +#define ELF_DATA ELFDATA2LSB | |
| 300 | +#endif | |
| 301 | +#define ELF_ARCH EM_PPC | |
| 302 | + | |
| 303 | +/* | |
| 304 | + * We need to put in some extra aux table entries to tell glibc what | |
| 305 | + * the cache block size is, so it can use the dcbz instruction safely. | |
| 306 | + */ | |
| 307 | +#define AT_DCACHEBSIZE 19 | |
| 308 | +#define AT_ICACHEBSIZE 20 | |
| 309 | +#define AT_UCACHEBSIZE 21 | |
| 310 | +/* A special ignored type value for PPC, for glibc compatibility. */ | |
| 311 | +#define AT_IGNOREPPC 22 | |
| 312 | +/* | |
| 313 | + * The requirements here are: | |
| 314 | + * - keep the final alignment of sp (sp & 0xf) | |
| 315 | + * - make sure the 32-bit value at the first 16 byte aligned position of | |
| 316 | + * AUXV is greater than 16 for glibc compatibility. | |
| 317 | + * AT_IGNOREPPC is used for that. | |
| 318 | + * - for compatibility with glibc ARCH_DLINFO must always be defined on PPC, | |
| 319 | + * even if DLINFO_ARCH_ITEMS goes to zero or is undefined. | |
| 320 | + */ | |
| 321 | +#define DLINFO_ARCH_ITEMS 5 | |
| 322 | +#define ARCH_DLINFO \ | |
| 323 | +do { \ | |
| 324 | + NEW_AUX_ENT(AT_DCACHEBSIZE, 0x20); \ | |
| 325 | + NEW_AUX_ENT(AT_ICACHEBSIZE, 0x20); \ | |
| 326 | + NEW_AUX_ENT(AT_UCACHEBSIZE, 0); \ | |
| 327 | + /* \ | |
| 328 | + * Now handle glibc compatibility. \ | |
| 329 | + */ \ | |
| 330 | + NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC); \ | |
| 331 | + NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC); \ | |
| 332 | + } while (0) | |
| 333 | + | |
| 334 | +static inline void init_thread(struct target_pt_regs *_regs, struct image_info *infop) | |
| 335 | +{ | |
| 336 | + abi_ulong pos = infop->start_stack; | |
| 337 | + abi_ulong tmp; | |
| 338 | +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32) | |
| 339 | + abi_ulong entry, toc; | |
| 340 | +#endif | |
| 341 | + | |
| 342 | + _regs->gpr[1] = infop->start_stack; | |
| 343 | +#if defined(TARGET_PPC64) && !defined(TARGET_ABI32) | |
| 344 | + entry = ldq_raw(infop->entry) + infop->load_addr; | |
| 345 | + toc = ldq_raw(infop->entry + 8) + infop->load_addr; | |
| 346 | + _regs->gpr[2] = toc; | |
| 347 | + infop->entry = entry; | |
| 348 | +#endif | |
| 349 | + _regs->nip = infop->entry; | |
| 350 | + /* Note that isn't exactly what regular kernel does | |
| 351 | + * but this is what the ABI wants and is needed to allow | |
| 352 | + * execution of PPC BSD programs. | |
| 353 | + */ | |
| 354 | + /* FIXME - what to for failure of get_user()? */ | |
| 355 | + get_user_ual(_regs->gpr[3], pos); | |
| 356 | + pos += sizeof(abi_ulong); | |
| 357 | + _regs->gpr[4] = pos; | |
| 358 | + for (tmp = 1; tmp != 0; pos += sizeof(abi_ulong)) | |
| 359 | + tmp = ldl(pos); | |
| 360 | + _regs->gpr[5] = pos; | |
| 361 | +} | |
| 362 | + | |
| 363 | +#define USE_ELF_CORE_DUMP | |
| 364 | +#define ELF_EXEC_PAGESIZE 4096 | |
| 365 | + | |
| 366 | +#endif | |
| 367 | + | |
| 368 | +#ifdef TARGET_MIPS | |
| 369 | + | |
| 370 | +#define ELF_START_MMAP 0x80000000 | |
| 371 | + | |
| 372 | +#define elf_check_arch(x) ( (x) == EM_MIPS ) | |
| 373 | + | |
| 374 | +#ifdef TARGET_MIPS64 | |
| 375 | +#define ELF_CLASS ELFCLASS64 | |
| 376 | +#else | |
| 377 | +#define ELF_CLASS ELFCLASS32 | |
| 378 | +#endif | |
| 379 | +#ifdef TARGET_WORDS_BIGENDIAN | |
| 380 | +#define ELF_DATA ELFDATA2MSB | |
| 381 | +#else | |
| 382 | +#define ELF_DATA ELFDATA2LSB | |
| 383 | +#endif | |
| 384 | +#define ELF_ARCH EM_MIPS | |
| 385 | + | |
| 386 | +static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) | |
| 387 | +{ | |
| 388 | + regs->cp0_status = 2 << CP0St_KSU; | |
| 389 | + regs->cp0_epc = infop->entry; | |
| 390 | + regs->regs[29] = infop->start_stack; | |
| 391 | +} | |
| 392 | + | |
| 393 | +#define USE_ELF_CORE_DUMP | |
| 394 | +#define ELF_EXEC_PAGESIZE 4096 | |
| 395 | + | |
| 396 | +#endif /* TARGET_MIPS */ | |
| 397 | + | |
| 398 | +#ifdef TARGET_SH4 | |
| 399 | + | |
| 400 | +#define ELF_START_MMAP 0x80000000 | |
| 401 | + | |
| 402 | +#define elf_check_arch(x) ( (x) == EM_SH ) | |
| 403 | + | |
| 404 | +#define ELF_CLASS ELFCLASS32 | |
| 405 | +#define ELF_DATA ELFDATA2LSB | |
| 406 | +#define ELF_ARCH EM_SH | |
| 407 | + | |
| 408 | +static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) | |
| 409 | +{ | |
| 410 | + /* Check other registers XXXXX */ | |
| 411 | + regs->pc = infop->entry; | |
| 412 | + regs->regs[15] = infop->start_stack; | |
| 413 | +} | |
| 414 | + | |
| 415 | +#define USE_ELF_CORE_DUMP | |
| 416 | +#define ELF_EXEC_PAGESIZE 4096 | |
| 417 | + | |
| 418 | +#endif | |
| 419 | + | |
| 420 | +#ifdef TARGET_CRIS | |
| 421 | + | |
| 422 | +#define ELF_START_MMAP 0x80000000 | |
| 423 | + | |
| 424 | +#define elf_check_arch(x) ( (x) == EM_CRIS ) | |
| 425 | + | |
| 426 | +#define ELF_CLASS ELFCLASS32 | |
| 427 | +#define ELF_DATA ELFDATA2LSB | |
| 428 | +#define ELF_ARCH EM_CRIS | |
| 429 | + | |
| 430 | +static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) | |
| 431 | +{ | |
| 432 | + regs->erp = infop->entry; | |
| 433 | +} | |
| 434 | + | |
| 435 | +#define USE_ELF_CORE_DUMP | |
| 436 | +#define ELF_EXEC_PAGESIZE 8192 | |
| 437 | + | |
| 438 | +#endif | |
| 439 | + | |
| 440 | +#ifdef TARGET_M68K | |
| 441 | + | |
| 442 | +#define ELF_START_MMAP 0x80000000 | |
| 443 | + | |
| 444 | +#define elf_check_arch(x) ( (x) == EM_68K ) | |
| 445 | + | |
| 446 | +#define ELF_CLASS ELFCLASS32 | |
| 447 | +#define ELF_DATA ELFDATA2MSB | |
| 448 | +#define ELF_ARCH EM_68K | |
| 449 | + | |
| 450 | +/* ??? Does this need to do anything? | |
| 451 | +#define ELF_PLAT_INIT(_r) */ | |
| 452 | + | |
| 453 | +static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) | |
| 454 | +{ | |
| 455 | + regs->usp = infop->start_stack; | |
| 456 | + regs->sr = 0; | |
| 457 | + regs->pc = infop->entry; | |
| 458 | +} | |
| 459 | + | |
| 460 | +#define USE_ELF_CORE_DUMP | |
| 461 | +#define ELF_EXEC_PAGESIZE 8192 | |
| 462 | + | |
| 463 | +#endif | |
| 464 | + | |
| 465 | +#ifdef TARGET_ALPHA | |
| 466 | + | |
| 467 | +#define ELF_START_MMAP (0x30000000000ULL) | |
| 468 | + | |
| 469 | +#define elf_check_arch(x) ( (x) == ELF_ARCH ) | |
| 470 | + | |
| 471 | +#define ELF_CLASS ELFCLASS64 | |
| 472 | +#define ELF_DATA ELFDATA2MSB | |
| 473 | +#define ELF_ARCH EM_ALPHA | |
| 474 | + | |
| 475 | +static inline void init_thread(struct target_pt_regs *regs, struct image_info *infop) | |
| 476 | +{ | |
| 477 | + regs->pc = infop->entry; | |
| 478 | + regs->ps = 8; | |
| 479 | + regs->usp = infop->start_stack; | |
| 480 | + regs->unique = infop->start_data; /* ? */ | |
| 481 | + printf("Set unique value to " TARGET_FMT_lx " (" TARGET_FMT_lx ")\n", | |
| 482 | + regs->unique, infop->start_data); | |
| 483 | +} | |
| 484 | + | |
| 485 | +#define USE_ELF_CORE_DUMP | |
| 486 | +#define ELF_EXEC_PAGESIZE 8192 | |
| 487 | + | |
| 488 | +#endif /* TARGET_ALPHA */ | |
| 489 | + | |
| 490 | +#ifndef ELF_PLATFORM | |
| 491 | +#define ELF_PLATFORM (NULL) | |
| 492 | +#endif | |
| 493 | + | |
| 494 | +#ifndef ELF_HWCAP | |
| 495 | +#define ELF_HWCAP 0 | |
| 496 | +#endif | |
| 497 | + | |
| 498 | +#ifdef TARGET_ABI32 | |
| 499 | +#undef ELF_CLASS | |
| 500 | +#define ELF_CLASS ELFCLASS32 | |
| 501 | +#undef bswaptls | |
| 502 | +#define bswaptls(ptr) bswap32s(ptr) | |
| 503 | +#endif | |
| 504 | + | |
| 505 | +#include "elf.h" | |
| 506 | + | |
| 507 | +struct exec | |
| 508 | +{ | |
| 509 | + unsigned int a_info; /* Use macros N_MAGIC, etc for access */ | |
| 510 | + unsigned int a_text; /* length of text, in bytes */ | |
| 511 | + unsigned int a_data; /* length of data, in bytes */ | |
| 512 | + unsigned int a_bss; /* length of uninitialized data area, in bytes */ | |
| 513 | + unsigned int a_syms; /* length of symbol table data in file, in bytes */ | |
| 514 | + unsigned int a_entry; /* start address */ | |
| 515 | + unsigned int a_trsize; /* length of relocation info for text, in bytes */ | |
| 516 | + unsigned int a_drsize; /* length of relocation info for data, in bytes */ | |
| 517 | +}; | |
| 518 | + | |
| 519 | + | |
| 520 | +#define N_MAGIC(exec) ((exec).a_info & 0xffff) | |
| 521 | +#define OMAGIC 0407 | |
| 522 | +#define NMAGIC 0410 | |
| 523 | +#define ZMAGIC 0413 | |
| 524 | +#define QMAGIC 0314 | |
| 525 | + | |
| 526 | +/* max code+data+bss space allocated to elf interpreter */ | |
| 527 | +#define INTERP_MAP_SIZE (32 * 1024 * 1024) | |
| 528 | + | |
| 529 | +/* max code+data+bss+brk space allocated to ET_DYN executables */ | |
| 530 | +#define ET_DYN_MAP_SIZE (128 * 1024 * 1024) | |
| 531 | + | |
| 532 | +/* Necessary parameters */ | |
| 533 | +#define TARGET_ELF_EXEC_PAGESIZE TARGET_PAGE_SIZE | |
| 534 | +#define TARGET_ELF_PAGESTART(_v) ((_v) & ~(unsigned long)(TARGET_ELF_EXEC_PAGESIZE-1)) | |
| 535 | +#define TARGET_ELF_PAGEOFFSET(_v) ((_v) & (TARGET_ELF_EXEC_PAGESIZE-1)) | |
| 536 | + | |
| 537 | +#define INTERPRETER_NONE 0 | |
| 538 | +#define INTERPRETER_AOUT 1 | |
| 539 | +#define INTERPRETER_ELF 2 | |
| 540 | + | |
| 541 | +#define DLINFO_ITEMS 12 | |
| 542 | + | |
| 543 | +static inline void memcpy_fromfs(void * to, const void * from, unsigned long n) | |
| 544 | +{ | |
| 545 | + memcpy(to, from, n); | |
| 546 | +} | |
| 547 | + | |
| 548 | +extern unsigned long x86_stack_size; | |
| 549 | + | |
| 550 | +static int load_aout_interp(void * exptr, int interp_fd); | |
| 551 | + | |
| 552 | +#ifdef BSWAP_NEEDED | |
| 553 | +static void bswap_ehdr(struct elfhdr *ehdr) | |
| 554 | +{ | |
| 555 | + bswap16s(&ehdr->e_type); /* Object file type */ | |
| 556 | + bswap16s(&ehdr->e_machine); /* Architecture */ | |
| 557 | + bswap32s(&ehdr->e_version); /* Object file version */ | |
| 558 | + bswaptls(&ehdr->e_entry); /* Entry point virtual address */ | |
| 559 | + bswaptls(&ehdr->e_phoff); /* Program header table file offset */ | |
| 560 | + bswaptls(&ehdr->e_shoff); /* Section header table file offset */ | |
| 561 | + bswap32s(&ehdr->e_flags); /* Processor-specific flags */ | |
| 562 | + bswap16s(&ehdr->e_ehsize); /* ELF header size in bytes */ | |
| 563 | + bswap16s(&ehdr->e_phentsize); /* Program header table entry size */ | |
| 564 | + bswap16s(&ehdr->e_phnum); /* Program header table entry count */ | |
| 565 | + bswap16s(&ehdr->e_shentsize); /* Section header table entry size */ | |
| 566 | + bswap16s(&ehdr->e_shnum); /* Section header table entry count */ | |
| 567 | + bswap16s(&ehdr->e_shstrndx); /* Section header string table index */ | |
| 568 | +} | |
| 569 | + | |
| 570 | +static void bswap_phdr(struct elf_phdr *phdr) | |
| 571 | +{ | |
| 572 | + bswap32s(&phdr->p_type); /* Segment type */ | |
| 573 | + bswaptls(&phdr->p_offset); /* Segment file offset */ | |
| 574 | + bswaptls(&phdr->p_vaddr); /* Segment virtual address */ | |
| 575 | + bswaptls(&phdr->p_paddr); /* Segment physical address */ | |
| 576 | + bswaptls(&phdr->p_filesz); /* Segment size in file */ | |
| 577 | + bswaptls(&phdr->p_memsz); /* Segment size in memory */ | |
| 578 | + bswap32s(&phdr->p_flags); /* Segment flags */ | |
| 579 | + bswaptls(&phdr->p_align); /* Segment alignment */ | |
| 580 | +} | |
| 581 | + | |
| 582 | +static void bswap_shdr(struct elf_shdr *shdr) | |
| 583 | +{ | |
| 584 | + bswap32s(&shdr->sh_name); | |
| 585 | + bswap32s(&shdr->sh_type); | |
| 586 | + bswaptls(&shdr->sh_flags); | |
| 587 | + bswaptls(&shdr->sh_addr); | |
| 588 | + bswaptls(&shdr->sh_offset); | |
| 589 | + bswaptls(&shdr->sh_size); | |
| 590 | + bswap32s(&shdr->sh_link); | |
| 591 | + bswap32s(&shdr->sh_info); | |
| 592 | + bswaptls(&shdr->sh_addralign); | |
| 593 | + bswaptls(&shdr->sh_entsize); | |
| 594 | +} | |
| 595 | + | |
| 596 | +static void bswap_sym(struct elf_sym *sym) | |
| 597 | +{ | |
| 598 | + bswap32s(&sym->st_name); | |
| 599 | + bswaptls(&sym->st_value); | |
| 600 | + bswaptls(&sym->st_size); | |
| 601 | + bswap16s(&sym->st_shndx); | |
| 602 | +} | |
| 603 | +#endif | |
| 604 | + | |
| 605 | +/* | |
| 606 | + * 'copy_elf_strings()' copies argument/envelope strings from user | |
| 607 | + * memory to free pages in kernel mem. These are in a format ready | |
| 608 | + * to be put directly into the top of new user memory. | |
| 609 | + * | |
| 610 | + */ | |
| 611 | +static abi_ulong copy_elf_strings(int argc,char ** argv, void **page, | |
| 612 | + abi_ulong p) | |
| 613 | +{ | |
| 614 | + char *tmp, *tmp1, *pag = NULL; | |
| 615 | + int len, offset = 0; | |
| 616 | + | |
| 617 | + if (!p) { | |
| 618 | + return 0; /* bullet-proofing */ | |
| 619 | + } | |
| 620 | + while (argc-- > 0) { | |
| 621 | + tmp = argv[argc]; | |
| 622 | + if (!tmp) { | |
| 623 | + fprintf(stderr, "VFS: argc is wrong"); | |
| 624 | + exit(-1); | |
| 625 | + } | |
| 626 | + tmp1 = tmp; | |
| 627 | + while (*tmp++); | |
| 628 | + len = tmp - tmp1; | |
| 629 | + if (p < len) { /* this shouldn't happen - 128kB */ | |
| 630 | + return 0; | |
| 631 | + } | |
| 632 | + while (len) { | |
| 633 | + --p; --tmp; --len; | |
| 634 | + if (--offset < 0) { | |
| 635 | + offset = p % TARGET_PAGE_SIZE; | |
| 636 | + pag = (char *)page[p/TARGET_PAGE_SIZE]; | |
| 637 | + if (!pag) { | |
| 638 | + pag = (char *)malloc(TARGET_PAGE_SIZE); | |
| 639 | + memset(pag, 0, TARGET_PAGE_SIZE); | |
| 640 | + page[p/TARGET_PAGE_SIZE] = pag; | |
| 641 | + if (!pag) | |
| 642 | + return 0; | |
| 643 | + } | |
| 644 | + } | |
| 645 | + if (len == 0 || offset == 0) { | |
| 646 | + *(pag + offset) = *tmp; | |
| 647 | + } | |
| 648 | + else { | |
| 649 | + int bytes_to_copy = (len > offset) ? offset : len; | |
| 650 | + tmp -= bytes_to_copy; | |
| 651 | + p -= bytes_to_copy; | |
| 652 | + offset -= bytes_to_copy; | |
| 653 | + len -= bytes_to_copy; | |
| 654 | + memcpy_fromfs(pag + offset, tmp, bytes_to_copy + 1); | |
| 655 | + } | |
| 656 | + } | |
| 657 | + } | |
| 658 | + return p; | |
| 659 | +} | |
| 660 | + | |
| 661 | +static abi_ulong setup_arg_pages(abi_ulong p, struct linux_binprm *bprm, | |
| 662 | + struct image_info *info) | |
| 663 | +{ | |
| 664 | + abi_ulong stack_base, size, error; | |
| 665 | + int i; | |
| 666 | + | |
| 667 | + /* Create enough stack to hold everything. If we don't use | |
| 668 | + * it for args, we'll use it for something else... | |
| 669 | + */ | |
| 670 | + size = x86_stack_size; | |
| 671 | + if (size < MAX_ARG_PAGES*TARGET_PAGE_SIZE) | |
| 672 | + size = MAX_ARG_PAGES*TARGET_PAGE_SIZE; | |
| 673 | + error = target_mmap(0, | |
| 674 | + size + qemu_host_page_size, | |
| 675 | + PROT_READ | PROT_WRITE, | |
| 676 | + MAP_PRIVATE | MAP_ANON, | |
| 677 | + -1, 0); | |
| 678 | + if (error == -1) { | |
| 679 | + perror("stk mmap"); | |
| 680 | + exit(-1); | |
| 681 | + } | |
| 682 | + /* we reserve one extra page at the top of the stack as guard */ | |
| 683 | + target_mprotect(error + size, qemu_host_page_size, PROT_NONE); | |
| 684 | + | |
| 685 | + stack_base = error + size - MAX_ARG_PAGES*TARGET_PAGE_SIZE; | |
| 686 | + p += stack_base; | |
| 687 | + | |
| 688 | + for (i = 0 ; i < MAX_ARG_PAGES ; i++) { | |
| 689 | + if (bprm->page[i]) { | |
| 690 | + info->rss++; | |
| 691 | + /* FIXME - check return value of memcpy_to_target() for failure */ | |
| 692 | + memcpy_to_target(stack_base, bprm->page[i], TARGET_PAGE_SIZE); | |
| 693 | + free(bprm->page[i]); | |
| 694 | + } | |
| 695 | + stack_base += TARGET_PAGE_SIZE; | |
| 696 | + } | |
| 697 | + return p; | |
| 698 | +} | |
| 699 | + | |
| 700 | +static void set_brk(abi_ulong start, abi_ulong end) | |
| 701 | +{ | |
| 702 | + /* page-align the start and end addresses... */ | |
| 703 | + start = HOST_PAGE_ALIGN(start); | |
| 704 | + end = HOST_PAGE_ALIGN(end); | |
| 705 | + if (end <= start) | |
| 706 | + return; | |
| 707 | + if(target_mmap(start, end - start, | |
| 708 | + PROT_READ | PROT_WRITE | PROT_EXEC, | |
| 709 | + MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0) == -1) { | |
| 710 | + perror("cannot mmap brk"); | |
| 711 | + exit(-1); | |
| 712 | + } | |
| 713 | +} | |
| 714 | + | |
| 715 | + | |
| 716 | +/* We need to explicitly zero any fractional pages after the data | |
| 717 | + section (i.e. bss). This would contain the junk from the file that | |
| 718 | + should not be in memory. */ | |
| 719 | +static void padzero(abi_ulong elf_bss, abi_ulong last_bss) | |
| 720 | +{ | |
| 721 | + abi_ulong nbyte; | |
| 722 | + | |
| 723 | + if (elf_bss >= last_bss) | |
| 724 | + return; | |
| 725 | + | |
| 726 | + /* XXX: this is really a hack : if the real host page size is | |
| 727 | + smaller than the target page size, some pages after the end | |
| 728 | + of the file may not be mapped. A better fix would be to | |
| 729 | + patch target_mmap(), but it is more complicated as the file | |
| 730 | + size must be known */ | |
| 731 | + if (qemu_real_host_page_size < qemu_host_page_size) { | |
| 732 | + abi_ulong end_addr, end_addr1; | |
| 733 | + end_addr1 = (elf_bss + qemu_real_host_page_size - 1) & | |
| 734 | + ~(qemu_real_host_page_size - 1); | |
| 735 | + end_addr = HOST_PAGE_ALIGN(elf_bss); | |
| 736 | + if (end_addr1 < end_addr) { | |
| 737 | + mmap((void *)g2h(end_addr1), end_addr - end_addr1, | |
| 738 | + PROT_READ|PROT_WRITE|PROT_EXEC, | |
| 739 | + MAP_FIXED|MAP_PRIVATE|MAP_ANON, -1, 0); | |
| 740 | + } | |
| 741 | + } | |
| 742 | + | |
| 743 | + nbyte = elf_bss & (qemu_host_page_size-1); | |
| 744 | + if (nbyte) { | |
| 745 | + nbyte = qemu_host_page_size - nbyte; | |
| 746 | + do { | |
| 747 | + /* FIXME - what to do if put_user() fails? */ | |
| 748 | + put_user_u8(0, elf_bss); | |
| 749 | + elf_bss++; | |
| 750 | + } while (--nbyte); | |
| 751 | + } | |
| 752 | +} | |
| 753 | + | |
| 754 | + | |
| 755 | +static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc, | |
| 756 | + struct elfhdr * exec, | |
| 757 | + abi_ulong load_addr, | |
| 758 | + abi_ulong load_bias, | |
| 759 | + abi_ulong interp_load_addr, int ibcs, | |
| 760 | + struct image_info *info) | |
| 761 | +{ | |
| 762 | + abi_ulong sp; | |
| 763 | + int size; | |
| 764 | + abi_ulong u_platform; | |
| 765 | + const char *k_platform; | |
| 766 | + const int n = sizeof(elf_addr_t); | |
| 767 | + | |
| 768 | + sp = p; | |
| 769 | + u_platform = 0; | |
| 770 | + k_platform = ELF_PLATFORM; | |
| 771 | + if (k_platform) { | |
| 772 | + size_t len = strlen(k_platform) + 1; | |
| 773 | + sp -= (len + n - 1) & ~(n - 1); | |
| 774 | + u_platform = sp; | |
| 775 | + /* FIXME - check return value of memcpy_to_target() for failure */ | |
| 776 | + memcpy_to_target(sp, k_platform, len); | |
| 777 | + } | |
| 778 | + /* | |
| 779 | + * Force 16 byte _final_ alignment here for generality. | |
| 780 | + */ | |
| 781 | + sp = sp &~ (abi_ulong)15; | |
| 782 | + size = (DLINFO_ITEMS + 1) * 2; | |
| 783 | + if (k_platform) | |
| 784 | + size += 2; | |
| 785 | +#ifdef DLINFO_ARCH_ITEMS | |
| 786 | + size += DLINFO_ARCH_ITEMS * 2; | |
| 787 | +#endif | |
| 788 | + size += envc + argc + 2; | |
| 789 | + size += (!ibcs ? 3 : 1); /* argc itself */ | |
| 790 | + size *= n; | |
| 791 | + if (size & 15) | |
| 792 | + sp -= 16 - (size & 15); | |
| 793 | + | |
| 794 | + /* This is correct because Linux defines | |
| 795 | + * elf_addr_t as Elf32_Off / Elf64_Off | |
| 796 | + */ | |
| 797 | +#define NEW_AUX_ENT(id, val) do { \ | |
| 798 | + sp -= n; put_user_ual(val, sp); \ | |
| 799 | + sp -= n; put_user_ual(id, sp); \ | |
| 800 | + } while(0) | |
| 801 | + | |
| 802 | + NEW_AUX_ENT (AT_NULL, 0); | |
| 803 | + | |
| 804 | + /* There must be exactly DLINFO_ITEMS entries here. */ | |
| 805 | + NEW_AUX_ENT(AT_PHDR, (abi_ulong)(load_addr + exec->e_phoff)); | |
| 806 | + NEW_AUX_ENT(AT_PHENT, (abi_ulong)(sizeof (struct elf_phdr))); | |
| 807 | + NEW_AUX_ENT(AT_PHNUM, (abi_ulong)(exec->e_phnum)); | |
| 808 | + NEW_AUX_ENT(AT_PAGESZ, (abi_ulong)(TARGET_PAGE_SIZE)); | |
| 809 | + NEW_AUX_ENT(AT_BASE, (abi_ulong)(interp_load_addr)); | |
| 810 | + NEW_AUX_ENT(AT_FLAGS, (abi_ulong)0); | |
| 811 | + NEW_AUX_ENT(AT_ENTRY, load_bias + exec->e_entry); | |
| 812 | + NEW_AUX_ENT(AT_UID, (abi_ulong) getuid()); | |
| 813 | + NEW_AUX_ENT(AT_EUID, (abi_ulong) geteuid()); | |
| 814 | + NEW_AUX_ENT(AT_GID, (abi_ulong) getgid()); | |
| 815 | + NEW_AUX_ENT(AT_EGID, (abi_ulong) getegid()); | |
| 816 | + NEW_AUX_ENT(AT_HWCAP, (abi_ulong) ELF_HWCAP); | |
| 817 | + NEW_AUX_ENT(AT_CLKTCK, (abi_ulong) sysconf(_SC_CLK_TCK)); | |
| 818 | + if (k_platform) | |
| 819 | + NEW_AUX_ENT(AT_PLATFORM, u_platform); | |
| 820 | +#ifdef ARCH_DLINFO | |
| 821 | + /* | |
| 822 | + * ARCH_DLINFO must come last so platform specific code can enforce | |
| 823 | + * special alignment requirements on the AUXV if necessary (eg. PPC). | |
| 824 | + */ | |
| 825 | + ARCH_DLINFO; | |
| 826 | +#endif | |
| 827 | +#undef NEW_AUX_ENT | |
| 828 | + | |
| 829 | + sp = loader_build_argptr(envc, argc, sp, p, !ibcs); | |
| 830 | + return sp; | |
| 831 | +} | |
| 832 | + | |
| 833 | + | |
| 834 | +static abi_ulong load_elf_interp(struct elfhdr * interp_elf_ex, | |
| 835 | + int interpreter_fd, | |
| 836 | + abi_ulong *interp_load_addr) | |
| 837 | +{ | |
| 838 | + struct elf_phdr *elf_phdata = NULL; | |
| 839 | + struct elf_phdr *eppnt; | |
| 840 | + abi_ulong load_addr = 0; | |
| 841 | + int load_addr_set = 0; | |
| 842 | + int retval; | |
| 843 | + abi_ulong last_bss, elf_bss; | |
| 844 | + abi_ulong error; | |
| 845 | + int i; | |
| 846 | + | |
| 847 | + elf_bss = 0; | |
| 848 | + last_bss = 0; | |
| 849 | + error = 0; | |
| 850 | + | |
| 851 | +#ifdef BSWAP_NEEDED | |
| 852 | + bswap_ehdr(interp_elf_ex); | |
| 853 | +#endif | |
| 854 | + /* First of all, some simple consistency checks */ | |
| 855 | + if ((interp_elf_ex->e_type != ET_EXEC && | |
| 856 | + interp_elf_ex->e_type != ET_DYN) || | |
| 857 | + !elf_check_arch(interp_elf_ex->e_machine)) { | |
| 858 | + return ~((abi_ulong)0UL); | |
| 859 | + } | |
| 860 | + | |
| 861 | + | |
| 862 | + /* Now read in all of the header information */ | |
| 863 | + | |
| 864 | + if (sizeof(struct elf_phdr) * interp_elf_ex->e_phnum > TARGET_PAGE_SIZE) | |
| 865 | + return ~(abi_ulong)0UL; | |
| 866 | + | |
| 867 | + elf_phdata = (struct elf_phdr *) | |
| 868 | + malloc(sizeof(struct elf_phdr) * interp_elf_ex->e_phnum); | |
| 869 | + | |
| 870 | + if (!elf_phdata) | |
| 871 | + return ~((abi_ulong)0UL); | |
| 872 | + | |
| 873 | + /* | |
| 874 | + * If the size of this structure has changed, then punt, since | |
| 875 | + * we will be doing the wrong thing. | |
| 876 | + */ | |
| 877 | + if (interp_elf_ex->e_phentsize != sizeof(struct elf_phdr)) { | |
| 878 | + free(elf_phdata); | |
| 879 | + return ~((abi_ulong)0UL); | |
| 880 | + } | |
| 881 | + | |
| 882 | + retval = lseek(interpreter_fd, interp_elf_ex->e_phoff, SEEK_SET); | |
| 883 | + if(retval >= 0) { | |
| 884 | + retval = read(interpreter_fd, | |
| 885 | + (char *) elf_phdata, | |
| 886 | + sizeof(struct elf_phdr) * interp_elf_ex->e_phnum); | |
| 887 | + } | |
| 888 | + if (retval < 0) { | |
| 889 | + perror("load_elf_interp"); | |
| 890 | + exit(-1); | |
| 891 | + free (elf_phdata); | |
| 892 | + return retval; | |
| 893 | + } | |
| 894 | +#ifdef BSWAP_NEEDED | |
| 895 | + eppnt = elf_phdata; | |
| 896 | + for (i=0; i<interp_elf_ex->e_phnum; i++, eppnt++) { | |
| 897 | + bswap_phdr(eppnt); | |
| 898 | + } | |
| 899 | +#endif | |
| 900 | + | |
| 901 | + if (interp_elf_ex->e_type == ET_DYN) { | |
| 902 | + /* in order to avoid hardcoding the interpreter load | |
| 903 | + address in qemu, we allocate a big enough memory zone */ | |
| 904 | + error = target_mmap(0, INTERP_MAP_SIZE, | |
| 905 | + PROT_NONE, MAP_PRIVATE | MAP_ANON, | |
| 906 | + -1, 0); | |
| 907 | + if (error == -1) { | |
| 908 | + perror("mmap"); | |
| 909 | + exit(-1); | |
| 910 | + } | |
| 911 | + load_addr = error; | |
| 912 | + load_addr_set = 1; | |
| 913 | + } | |
| 914 | + | |
| 915 | + eppnt = elf_phdata; | |
| 916 | + for(i=0; i<interp_elf_ex->e_phnum; i++, eppnt++) | |
| 917 | + if (eppnt->p_type == PT_LOAD) { | |
| 918 | + int elf_type = MAP_PRIVATE | MAP_DENYWRITE; | |
| 919 | + int elf_prot = 0; | |
| 920 | + abi_ulong vaddr = 0; | |
| 921 | + abi_ulong k; | |
| 922 | + | |
| 923 | + if (eppnt->p_flags & PF_R) elf_prot = PROT_READ; | |
| 924 | + if (eppnt->p_flags & PF_W) elf_prot |= PROT_WRITE; | |
| 925 | + if (eppnt->p_flags & PF_X) elf_prot |= PROT_EXEC; | |
| 926 | + if (interp_elf_ex->e_type == ET_EXEC || load_addr_set) { | |
| 927 | + elf_type |= MAP_FIXED; | |
| 928 | + vaddr = eppnt->p_vaddr; | |
| 929 | + } | |
| 930 | + error = target_mmap(load_addr+TARGET_ELF_PAGESTART(vaddr), | |
| 931 | + eppnt->p_filesz + TARGET_ELF_PAGEOFFSET(eppnt->p_vaddr), | |
| 932 | + elf_prot, | |
| 933 | + elf_type, | |
| 934 | + interpreter_fd, | |
| 935 | + eppnt->p_offset - TARGET_ELF_PAGEOFFSET(eppnt->p_vaddr)); | |
| 936 | + | |
| 937 | + if (error == -1) { | |
| 938 | + /* Real error */ | |
| 939 | + close(interpreter_fd); | |
| 940 | + free(elf_phdata); | |
| 941 | + return ~((abi_ulong)0UL); | |
| 942 | + } | |
| 943 | + | |
| 944 | + if (!load_addr_set && interp_elf_ex->e_type == ET_DYN) { | |
| 945 | + load_addr = error; | |
| 946 | + load_addr_set = 1; | |
| 947 | + } | |
| 948 | + | |
| 949 | + /* | |
| 950 | + * Find the end of the file mapping for this phdr, and keep | |
| 951 | + * track of the largest address we see for this. | |
| 952 | + */ | |
| 953 | + k = load_addr + eppnt->p_vaddr + eppnt->p_filesz; | |
| 954 | + if (k > elf_bss) elf_bss = k; | |
| 955 | + | |
| 956 | + /* | |
| 957 | + * Do the same thing for the memory mapping - between | |
| 958 | + * elf_bss and last_bss is the bss section. | |
| 959 | + */ | |
| 960 | + k = load_addr + eppnt->p_memsz + eppnt->p_vaddr; | |
| 961 | + if (k > last_bss) last_bss = k; | |
| 962 | + } | |
| 963 | + | |
| 964 | + /* Now use mmap to map the library into memory. */ | |
| 965 | + | |
| 966 | + close(interpreter_fd); | |
| 967 | + | |
| 968 | + /* | |
| 969 | + * Now fill out the bss section. First pad the last page up | |
| 970 | + * to the page boundary, and then perform a mmap to make sure | |
| 971 | + * that there are zeromapped pages up to and including the last | |
| 972 | + * bss page. | |
| 973 | + */ | |
| 974 | + padzero(elf_bss, last_bss); | |
| 975 | + elf_bss = TARGET_ELF_PAGESTART(elf_bss + qemu_host_page_size - 1); /* What we have mapped so far */ | |
| 976 | + | |
| 977 | + /* Map the last of the bss segment */ | |
| 978 | + if (last_bss > elf_bss) { | |
| 979 | + target_mmap(elf_bss, last_bss-elf_bss, | |
| 980 | + PROT_READ|PROT_WRITE|PROT_EXEC, | |
| 981 | + MAP_FIXED|MAP_PRIVATE|MAP_ANON, -1, 0); | |
| 982 | + } | |
| 983 | + free(elf_phdata); | |
| 984 | + | |
| 985 | + *interp_load_addr = load_addr; | |
| 986 | + return ((abi_ulong) interp_elf_ex->e_entry) + load_addr; | |
| 987 | +} | |
| 988 | + | |
| 989 | +static int symfind(const void *s0, const void *s1) | |
| 990 | +{ | |
| 991 | + struct elf_sym *key = (struct elf_sym *)s0; | |
| 992 | + struct elf_sym *sym = (struct elf_sym *)s1; | |
| 993 | + int result = 0; | |
| 994 | + if (key->st_value < sym->st_value) { | |
| 995 | + result = -1; | |
| 996 | + } else if (key->st_value > sym->st_value + sym->st_size) { | |
| 997 | + result = 1; | |
| 998 | + } | |
| 999 | + return result; | |
| 1000 | +} | |
| 1001 | + | |
| 1002 | +static const char *lookup_symbolxx(struct syminfo *s, target_ulong orig_addr) | |
| 1003 | +{ | |
| 1004 | +#if ELF_CLASS == ELFCLASS32 | |
| 1005 | + struct elf_sym *syms = s->disas_symtab.elf32; | |
| 1006 | +#else | |
| 1007 | + struct elf_sym *syms = s->disas_symtab.elf64; | |
| 1008 | +#endif | |
| 1009 | + | |
| 1010 | + // binary search | |
| 1011 | + struct elf_sym key; | |
| 1012 | + struct elf_sym *sym; | |
| 1013 | + | |
| 1014 | + key.st_value = orig_addr; | |
| 1015 | + | |
| 1016 | + sym = bsearch(&key, syms, s->disas_num_syms, sizeof(*syms), symfind); | |
| 1017 | + if (sym != 0) { | |
| 1018 | + return s->disas_strtab + sym->st_name; | |
| 1019 | + } | |
| 1020 | + | |
| 1021 | + return ""; | |
| 1022 | +} | |
| 1023 | + | |
| 1024 | +/* FIXME: This should use elf_ops.h */ | |
| 1025 | +static int symcmp(const void *s0, const void *s1) | |
| 1026 | +{ | |
| 1027 | + struct elf_sym *sym0 = (struct elf_sym *)s0; | |
| 1028 | + struct elf_sym *sym1 = (struct elf_sym *)s1; | |
| 1029 | + return (sym0->st_value < sym1->st_value) | |
| 1030 | + ? -1 | |
| 1031 | + : ((sym0->st_value > sym1->st_value) ? 1 : 0); | |
| 1032 | +} | |
| 1033 | + | |
| 1034 | +/* Best attempt to load symbols from this ELF object. */ | |
| 1035 | +static void load_symbols(struct elfhdr *hdr, int fd) | |
| 1036 | +{ | |
| 1037 | + unsigned int i, nsyms; | |
| 1038 | + struct elf_shdr sechdr, symtab, strtab; | |
| 1039 | + char *strings; | |
| 1040 | + struct syminfo *s; | |
| 1041 | + struct elf_sym *syms; | |
| 1042 | + | |
| 1043 | + lseek(fd, hdr->e_shoff, SEEK_SET); | |
| 1044 | + for (i = 0; i < hdr->e_shnum; i++) { | |
| 1045 | + if (read(fd, &sechdr, sizeof(sechdr)) != sizeof(sechdr)) | |
| 1046 | + return; | |
| 1047 | +#ifdef BSWAP_NEEDED | |
| 1048 | + bswap_shdr(&sechdr); | |
| 1049 | +#endif | |
| 1050 | + if (sechdr.sh_type == SHT_SYMTAB) { | |
| 1051 | + symtab = sechdr; | |
| 1052 | + lseek(fd, hdr->e_shoff | |
| 1053 | + + sizeof(sechdr) * sechdr.sh_link, SEEK_SET); | |
| 1054 | + if (read(fd, &strtab, sizeof(strtab)) | |
| 1055 | + != sizeof(strtab)) | |
| 1056 | + return; | |
| 1057 | +#ifdef BSWAP_NEEDED | |
| 1058 | + bswap_shdr(&strtab); | |
| 1059 | +#endif | |
| 1060 | + goto found; | |
| 1061 | + } | |
| 1062 | + } | |
| 1063 | + return; /* Shouldn't happen... */ | |
| 1064 | + | |
| 1065 | + found: | |
| 1066 | + /* Now know where the strtab and symtab are. Snarf them. */ | |
| 1067 | + s = malloc(sizeof(*s)); | |
| 1068 | + syms = malloc(symtab.sh_size); | |
| 1069 | + if (!syms) | |
| 1070 | + return; | |
| 1071 | + s->disas_strtab = strings = malloc(strtab.sh_size); | |
| 1072 | + if (!s->disas_strtab) | |
| 1073 | + return; | |
| 1074 | + | |
| 1075 | + lseek(fd, symtab.sh_offset, SEEK_SET); | |
| 1076 | + if (read(fd, syms, symtab.sh_size) != symtab.sh_size) | |
| 1077 | + return; | |
| 1078 | + | |
| 1079 | + nsyms = symtab.sh_size / sizeof(struct elf_sym); | |
| 1080 | + | |
| 1081 | + i = 0; | |
| 1082 | + while (i < nsyms) { | |
| 1083 | +#ifdef BSWAP_NEEDED | |
| 1084 | + bswap_sym(syms + i); | |
| 1085 | +#endif | |
| 1086 | + // Throw away entries which we do not need. | |
| 1087 | + if (syms[i].st_shndx == SHN_UNDEF || | |
| 1088 | + syms[i].st_shndx >= SHN_LORESERVE || | |
| 1089 | + ELF_ST_TYPE(syms[i].st_info) != STT_FUNC) { | |
| 1090 | + nsyms--; | |
| 1091 | + if (i < nsyms) { | |
| 1092 | + syms[i] = syms[nsyms]; | |
| 1093 | + } | |
| 1094 | + continue; | |
| 1095 | + } | |
| 1096 | +#if defined(TARGET_ARM) || defined (TARGET_MIPS) | |
| 1097 | + /* The bottom address bit marks a Thumb or MIPS16 symbol. */ | |
| 1098 | + syms[i].st_value &= ~(target_ulong)1; | |
| 1099 | +#endif | |
| 1100 | + i++; | |
| 1101 | + } | |
| 1102 | + syms = realloc(syms, nsyms * sizeof(*syms)); | |
| 1103 | + | |
| 1104 | + qsort(syms, nsyms, sizeof(*syms), symcmp); | |
| 1105 | + | |
| 1106 | + lseek(fd, strtab.sh_offset, SEEK_SET); | |
| 1107 | + if (read(fd, strings, strtab.sh_size) != strtab.sh_size) | |
| 1108 | + return; | |
| 1109 | + s->disas_num_syms = nsyms; | |
| 1110 | +#if ELF_CLASS == ELFCLASS32 | |
| 1111 | + s->disas_symtab.elf32 = syms; | |
| 1112 | + s->lookup_symbol = lookup_symbolxx; | |
| 1113 | +#else | |
| 1114 | + s->disas_symtab.elf64 = syms; | |
| 1115 | + s->lookup_symbol = lookup_symbolxx; | |
| 1116 | +#endif | |
| 1117 | + s->next = syminfos; | |
| 1118 | + syminfos = s; | |
| 1119 | +} | |
| 1120 | + | |
| 1121 | +int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, | |
| 1122 | + struct image_info * info) | |
| 1123 | +{ | |
| 1124 | + struct elfhdr elf_ex; | |
| 1125 | + struct elfhdr interp_elf_ex; | |
| 1126 | + struct exec interp_ex; | |
| 1127 | + int interpreter_fd = -1; /* avoid warning */ | |
| 1128 | + abi_ulong load_addr, load_bias; | |
| 1129 | + int load_addr_set = 0; | |
| 1130 | + unsigned int interpreter_type = INTERPRETER_NONE; | |
| 1131 | + unsigned char ibcs2_interpreter; | |
| 1132 | + int i; | |
| 1133 | + abi_ulong mapped_addr; | |
| 1134 | + struct elf_phdr * elf_ppnt; | |
| 1135 | + struct elf_phdr *elf_phdata; | |
| 1136 | + abi_ulong elf_bss, k, elf_brk; | |
| 1137 | + int retval; | |
| 1138 | + char * elf_interpreter; | |
| 1139 | + abi_ulong elf_entry, interp_load_addr = 0; | |
| 1140 | + int status; | |
| 1141 | + abi_ulong start_code, end_code, start_data, end_data; | |
| 1142 | + abi_ulong reloc_func_desc = 0; | |
| 1143 | + abi_ulong elf_stack; | |
| 1144 | + char passed_fileno[6]; | |
| 1145 | + | |
| 1146 | + ibcs2_interpreter = 0; | |
| 1147 | + status = 0; | |
| 1148 | + load_addr = 0; | |
| 1149 | + load_bias = 0; | |
| 1150 | + elf_ex = *((struct elfhdr *) bprm->buf); /* exec-header */ | |
| 1151 | +#ifdef BSWAP_NEEDED | |
| 1152 | + bswap_ehdr(&elf_ex); | |
| 1153 | +#endif | |
| 1154 | + | |
| 1155 | + /* First of all, some simple consistency checks */ | |
| 1156 | + if ((elf_ex.e_type != ET_EXEC && elf_ex.e_type != ET_DYN) || | |
| 1157 | + (! elf_check_arch(elf_ex.e_machine))) { | |
| 1158 | + return -ENOEXEC; | |
| 1159 | + } | |
| 1160 | + | |
| 1161 | + bprm->p = copy_elf_strings(1, &bprm->filename, bprm->page, bprm->p); | |
| 1162 | + bprm->p = copy_elf_strings(bprm->envc,bprm->envp,bprm->page,bprm->p); | |
| 1163 | + bprm->p = copy_elf_strings(bprm->argc,bprm->argv,bprm->page,bprm->p); | |
| 1164 | + if (!bprm->p) { | |
| 1165 | + retval = -E2BIG; | |
| 1166 | + } | |
| 1167 | + | |
| 1168 | + /* Now read in all of the header information */ | |
| 1169 | + elf_phdata = (struct elf_phdr *)malloc(elf_ex.e_phentsize*elf_ex.e_phnum); | |
| 1170 | + if (elf_phdata == NULL) { | |
| 1171 | + return -ENOMEM; | |
| 1172 | + } | |
| 1173 | + | |
| 1174 | + retval = lseek(bprm->fd, elf_ex.e_phoff, SEEK_SET); | |
| 1175 | + if(retval > 0) { | |
| 1176 | + retval = read(bprm->fd, (char *) elf_phdata, | |
| 1177 | + elf_ex.e_phentsize * elf_ex.e_phnum); | |
| 1178 | + } | |
| 1179 | + | |
| 1180 | + if (retval < 0) { | |
| 1181 | + perror("load_elf_binary"); | |
| 1182 | + exit(-1); | |
| 1183 | + free (elf_phdata); | |
| 1184 | + return -errno; | |
| 1185 | + } | |
| 1186 | + | |
| 1187 | +#ifdef BSWAP_NEEDED | |
| 1188 | + elf_ppnt = elf_phdata; | |
| 1189 | + for (i=0; i<elf_ex.e_phnum; i++, elf_ppnt++) { | |
| 1190 | + bswap_phdr(elf_ppnt); | |
| 1191 | + } | |
| 1192 | +#endif | |
| 1193 | + elf_ppnt = elf_phdata; | |
| 1194 | + | |
| 1195 | + elf_bss = 0; | |
| 1196 | + elf_brk = 0; | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + elf_stack = ~((abi_ulong)0UL); | |
| 1200 | + elf_interpreter = NULL; | |
| 1201 | + start_code = ~((abi_ulong)0UL); | |
| 1202 | + end_code = 0; | |
| 1203 | + start_data = 0; | |
| 1204 | + end_data = 0; | |
| 1205 | + interp_ex.a_info = 0; | |
| 1206 | + | |
| 1207 | + for(i=0;i < elf_ex.e_phnum; i++) { | |
| 1208 | + if (elf_ppnt->p_type == PT_INTERP) { | |
| 1209 | + if ( elf_interpreter != NULL ) | |
| 1210 | + { | |
| 1211 | + free (elf_phdata); | |
| 1212 | + free(elf_interpreter); | |
| 1213 | + close(bprm->fd); | |
| 1214 | + return -EINVAL; | |
| 1215 | + } | |
| 1216 | + | |
| 1217 | + /* This is the program interpreter used for | |
| 1218 | + * shared libraries - for now assume that this | |
| 1219 | + * is an a.out format binary | |
| 1220 | + */ | |
| 1221 | + | |
| 1222 | + elf_interpreter = (char *)malloc(elf_ppnt->p_filesz); | |
| 1223 | + | |
| 1224 | + if (elf_interpreter == NULL) { | |
| 1225 | + free (elf_phdata); | |
| 1226 | + close(bprm->fd); | |
| 1227 | + return -ENOMEM; | |
| 1228 | + } | |
| 1229 | + | |
| 1230 | + retval = lseek(bprm->fd, elf_ppnt->p_offset, SEEK_SET); | |
| 1231 | + if(retval >= 0) { | |
| 1232 | + retval = read(bprm->fd, elf_interpreter, elf_ppnt->p_filesz); | |
| 1233 | + } | |
| 1234 | + if(retval < 0) { | |
| 1235 | + perror("load_elf_binary2"); | |
| 1236 | + exit(-1); | |
| 1237 | + } | |
| 1238 | + | |
| 1239 | + /* If the program interpreter is one of these two, | |
| 1240 | + then assume an iBCS2 image. Otherwise assume | |
| 1241 | + a native linux image. */ | |
| 1242 | + | |
| 1243 | + /* JRP - Need to add X86 lib dir stuff here... */ | |
| 1244 | + | |
| 1245 | + if (strcmp(elf_interpreter,"/usr/lib/libc.so.1") == 0 || | |
| 1246 | + strcmp(elf_interpreter,"/usr/lib/ld.so.1") == 0) { | |
| 1247 | + ibcs2_interpreter = 1; | |
| 1248 | + } | |
| 1249 | + | |
| 1250 | +#if 0 | |
| 1251 | + printf("Using ELF interpreter %s\n", elf_interpreter); | |
| 1252 | +#endif | |
| 1253 | + if (retval >= 0) { | |
| 1254 | + retval = open(path(elf_interpreter), O_RDONLY); | |
| 1255 | + if(retval >= 0) { | |
| 1256 | + interpreter_fd = retval; | |
| 1257 | + } | |
| 1258 | + else { | |
| 1259 | + perror(elf_interpreter); | |
| 1260 | + exit(-1); | |
| 1261 | + /* retval = -errno; */ | |
| 1262 | + } | |
| 1263 | + } | |
| 1264 | + | |
| 1265 | + if (retval >= 0) { | |
| 1266 | + retval = lseek(interpreter_fd, 0, SEEK_SET); | |
| 1267 | + if(retval >= 0) { | |
| 1268 | + retval = read(interpreter_fd,bprm->buf,128); | |
| 1269 | + } | |
| 1270 | + } | |
| 1271 | + if (retval >= 0) { | |
| 1272 | + interp_ex = *((struct exec *) bprm->buf); /* aout exec-header */ | |
| 1273 | + interp_elf_ex=*((struct elfhdr *) bprm->buf); /* elf exec-header */ | |
| 1274 | + } | |
| 1275 | + if (retval < 0) { | |
| 1276 | + perror("load_elf_binary3"); | |
| 1277 | + exit(-1); | |
| 1278 | + free (elf_phdata); | |
| 1279 | + free(elf_interpreter); | |
| 1280 | + close(bprm->fd); | |
| 1281 | + return retval; | |
| 1282 | + } | |
| 1283 | + } | |
| 1284 | + elf_ppnt++; | |
| 1285 | + } | |
| 1286 | + | |
| 1287 | + /* Some simple consistency checks for the interpreter */ | |
| 1288 | + if (elf_interpreter){ | |
| 1289 | + interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT; | |
| 1290 | + | |
| 1291 | + /* Now figure out which format our binary is */ | |
| 1292 | + if ((N_MAGIC(interp_ex) != OMAGIC) && (N_MAGIC(interp_ex) != ZMAGIC) && | |
| 1293 | + (N_MAGIC(interp_ex) != QMAGIC)) { | |
| 1294 | + interpreter_type = INTERPRETER_ELF; | |
| 1295 | + } | |
| 1296 | + | |
| 1297 | + if (interp_elf_ex.e_ident[0] != 0x7f || | |
| 1298 | + strncmp(&interp_elf_ex.e_ident[1], "ELF",3) != 0) { | |
| 1299 | + interpreter_type &= ~INTERPRETER_ELF; | |
| 1300 | + } | |
| 1301 | + | |
| 1302 | + if (!interpreter_type) { | |
| 1303 | + free(elf_interpreter); | |
| 1304 | + free(elf_phdata); | |
| 1305 | + close(bprm->fd); | |
| 1306 | + return -ELIBBAD; | |
| 1307 | + } | |
| 1308 | + } | |
| 1309 | + | |
| 1310 | + /* OK, we are done with that, now set up the arg stuff, | |
| 1311 | + and then start this sucker up */ | |
| 1312 | + | |
| 1313 | + { | |
| 1314 | + char * passed_p; | |
| 1315 | + | |
| 1316 | + if (interpreter_type == INTERPRETER_AOUT) { | |
| 1317 | + snprintf(passed_fileno, sizeof(passed_fileno), "%d", bprm->fd); | |
| 1318 | + passed_p = passed_fileno; | |
| 1319 | + | |
| 1320 | + if (elf_interpreter) { | |
| 1321 | + bprm->p = copy_elf_strings(1,&passed_p,bprm->page,bprm->p); | |
| 1322 | + bprm->argc++; | |
| 1323 | + } | |
| 1324 | + } | |
| 1325 | + if (!bprm->p) { | |
| 1326 | + if (elf_interpreter) { | |
| 1327 | + free(elf_interpreter); | |
| 1328 | + } | |
| 1329 | + free (elf_phdata); | |
| 1330 | + close(bprm->fd); | |
| 1331 | + return -E2BIG; | |
| 1332 | + } | |
| 1333 | + } | |
| 1334 | + | |
| 1335 | + /* OK, This is the point of no return */ | |
| 1336 | + info->end_data = 0; | |
| 1337 | + info->end_code = 0; | |
| 1338 | + info->start_mmap = (abi_ulong)ELF_START_MMAP; | |
| 1339 | + info->mmap = 0; | |
| 1340 | + elf_entry = (abi_ulong) elf_ex.e_entry; | |
| 1341 | + | |
| 1342 | + /* Do this so that we can load the interpreter, if need be. We will | |
| 1343 | + change some of these later */ | |
| 1344 | + info->rss = 0; | |
| 1345 | + bprm->p = setup_arg_pages(bprm->p, bprm, info); | |
| 1346 | + info->start_stack = bprm->p; | |
| 1347 | + | |
| 1348 | + /* Now we do a little grungy work by mmaping the ELF image into | |
| 1349 | + * the correct location in memory. At this point, we assume that | |
| 1350 | + * the image should be loaded at fixed address, not at a variable | |
| 1351 | + * address. | |
| 1352 | + */ | |
| 1353 | + | |
| 1354 | + for(i = 0, elf_ppnt = elf_phdata; i < elf_ex.e_phnum; i++, elf_ppnt++) { | |
| 1355 | + int elf_prot = 0; | |
| 1356 | + int elf_flags = 0; | |
| 1357 | + abi_ulong error; | |
| 1358 | + | |
| 1359 | + if (elf_ppnt->p_type != PT_LOAD) | |
| 1360 | + continue; | |
| 1361 | + | |
| 1362 | + if (elf_ppnt->p_flags & PF_R) elf_prot |= PROT_READ; | |
| 1363 | + if (elf_ppnt->p_flags & PF_W) elf_prot |= PROT_WRITE; | |
| 1364 | + if (elf_ppnt->p_flags & PF_X) elf_prot |= PROT_EXEC; | |
| 1365 | + elf_flags = MAP_PRIVATE | MAP_DENYWRITE; | |
| 1366 | + if (elf_ex.e_type == ET_EXEC || load_addr_set) { | |
| 1367 | + elf_flags |= MAP_FIXED; | |
| 1368 | + } else if (elf_ex.e_type == ET_DYN) { | |
| 1369 | + /* Try and get dynamic programs out of the way of the default mmap | |
| 1370 | + base, as well as whatever program they might try to exec. This | |
| 1371 | + is because the brk will follow the loader, and is not movable. */ | |
| 1372 | + /* NOTE: for qemu, we do a big mmap to get enough space | |
| 1373 | + without hardcoding any address */ | |
| 1374 | + error = target_mmap(0, ET_DYN_MAP_SIZE, | |
| 1375 | + PROT_NONE, MAP_PRIVATE | MAP_ANON, | |
| 1376 | + -1, 0); | |
| 1377 | + if (error == -1) { | |
| 1378 | + perror("mmap"); | |
| 1379 | + exit(-1); | |
| 1380 | + } | |
| 1381 | + load_bias = TARGET_ELF_PAGESTART(error - elf_ppnt->p_vaddr); | |
| 1382 | + } | |
| 1383 | + | |
| 1384 | + error = target_mmap(TARGET_ELF_PAGESTART(load_bias + elf_ppnt->p_vaddr), | |
| 1385 | + (elf_ppnt->p_filesz + | |
| 1386 | + TARGET_ELF_PAGEOFFSET(elf_ppnt->p_vaddr)), | |
| 1387 | + elf_prot, | |
| 1388 | + (MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE), | |
| 1389 | + bprm->fd, | |
| 1390 | + (elf_ppnt->p_offset - | |
| 1391 | + TARGET_ELF_PAGEOFFSET(elf_ppnt->p_vaddr))); | |
| 1392 | + if (error == -1) { | |
| 1393 | + perror("mmap"); | |
| 1394 | + exit(-1); | |
| 1395 | + } | |
| 1396 | + | |
| 1397 | +#ifdef LOW_ELF_STACK | |
| 1398 | + if (TARGET_ELF_PAGESTART(elf_ppnt->p_vaddr) < elf_stack) | |
| 1399 | + elf_stack = TARGET_ELF_PAGESTART(elf_ppnt->p_vaddr); | |
| 1400 | +#endif | |
| 1401 | + | |
| 1402 | + if (!load_addr_set) { | |
| 1403 | + load_addr_set = 1; | |
| 1404 | + load_addr = elf_ppnt->p_vaddr - elf_ppnt->p_offset; | |
| 1405 | + if (elf_ex.e_type == ET_DYN) { | |
| 1406 | + load_bias += error - | |
| 1407 | + TARGET_ELF_PAGESTART(load_bias + elf_ppnt->p_vaddr); | |
| 1408 | + load_addr += load_bias; | |
| 1409 | + reloc_func_desc = load_bias; | |
| 1410 | + } | |
| 1411 | + } | |
| 1412 | + k = elf_ppnt->p_vaddr; | |
| 1413 | + if (k < start_code) | |
| 1414 | + start_code = k; | |
| 1415 | + if (start_data < k) | |
| 1416 | + start_data = k; | |
| 1417 | + k = elf_ppnt->p_vaddr + elf_ppnt->p_filesz; | |
| 1418 | + if (k > elf_bss) | |
| 1419 | + elf_bss = k; | |
| 1420 | + if ((elf_ppnt->p_flags & PF_X) && end_code < k) | |
| 1421 | + end_code = k; | |
| 1422 | + if (end_data < k) | |
| 1423 | + end_data = k; | |
| 1424 | + k = elf_ppnt->p_vaddr + elf_ppnt->p_memsz; | |
| 1425 | + if (k > elf_brk) elf_brk = k; | |
| 1426 | + } | |
| 1427 | + | |
| 1428 | + elf_entry += load_bias; | |
| 1429 | + elf_bss += load_bias; | |
| 1430 | + elf_brk += load_bias; | |
| 1431 | + start_code += load_bias; | |
| 1432 | + end_code += load_bias; | |
| 1433 | + start_data += load_bias; | |
| 1434 | + end_data += load_bias; | |
| 1435 | + | |
| 1436 | + if (elf_interpreter) { | |
| 1437 | + if (interpreter_type & 1) { | |
| 1438 | + elf_entry = load_aout_interp(&interp_ex, interpreter_fd); | |
| 1439 | + } | |
| 1440 | + else if (interpreter_type & 2) { | |
| 1441 | + elf_entry = load_elf_interp(&interp_elf_ex, interpreter_fd, | |
| 1442 | + &interp_load_addr); | |
| 1443 | + } | |
| 1444 | + reloc_func_desc = interp_load_addr; | |
| 1445 | + | |
| 1446 | + close(interpreter_fd); | |
| 1447 | + free(elf_interpreter); | |
| 1448 | + | |
| 1449 | + if (elf_entry == ~((abi_ulong)0UL)) { | |
| 1450 | + printf("Unable to load interpreter\n"); | |
| 1451 | + free(elf_phdata); | |
| 1452 | + exit(-1); | |
| 1453 | + return 0; | |
| 1454 | + } | |
| 1455 | + } | |
| 1456 | + | |
| 1457 | + free(elf_phdata); | |
| 1458 | + | |
| 1459 | + if (loglevel) | |
| 1460 | + load_symbols(&elf_ex, bprm->fd); | |
| 1461 | + | |
| 1462 | + if (interpreter_type != INTERPRETER_AOUT) close(bprm->fd); | |
| 1463 | + info->personality = (ibcs2_interpreter ? PER_SVR4 : PER_LINUX); | |
| 1464 | + | |
| 1465 | +#ifdef LOW_ELF_STACK | |
| 1466 | + info->start_stack = bprm->p = elf_stack - 4; | |
| 1467 | +#endif | |
| 1468 | + bprm->p = create_elf_tables(bprm->p, | |
| 1469 | + bprm->argc, | |
| 1470 | + bprm->envc, | |
| 1471 | + &elf_ex, | |
| 1472 | + load_addr, load_bias, | |
| 1473 | + interp_load_addr, | |
| 1474 | + (interpreter_type == INTERPRETER_AOUT ? 0 : 1), | |
| 1475 | + info); | |
| 1476 | + info->load_addr = reloc_func_desc; | |
| 1477 | + info->start_brk = info->brk = elf_brk; | |
| 1478 | + info->end_code = end_code; | |
| 1479 | + info->start_code = start_code; | |
| 1480 | + info->start_data = start_data; | |
| 1481 | + info->end_data = end_data; | |
| 1482 | + info->start_stack = bprm->p; | |
| 1483 | + | |
| 1484 | + /* Calling set_brk effectively mmaps the pages that we need for the bss and break | |
| 1485 | + sections */ | |
| 1486 | + set_brk(elf_bss, elf_brk); | |
| 1487 | + | |
| 1488 | + padzero(elf_bss, elf_brk); | |
| 1489 | + | |
| 1490 | +#if 0 | |
| 1491 | + printf("(start_brk) %x\n" , info->start_brk); | |
| 1492 | + printf("(end_code) %x\n" , info->end_code); | |
| 1493 | + printf("(start_code) %x\n" , info->start_code); | |
| 1494 | + printf("(end_data) %x\n" , info->end_data); | |
| 1495 | + printf("(start_stack) %x\n" , info->start_stack); | |
| 1496 | + printf("(brk) %x\n" , info->brk); | |
| 1497 | +#endif | |
| 1498 | + | |
| 1499 | + if ( info->personality == PER_SVR4 ) | |
| 1500 | + { | |
| 1501 | + /* Why this, you ask??? Well SVr4 maps page 0 as read-only, | |
| 1502 | + and some applications "depend" upon this behavior. | |
| 1503 | + Since we do not have the power to recompile these, we | |
| 1504 | + emulate the SVr4 behavior. Sigh. */ | |
| 1505 | + mapped_addr = target_mmap(0, qemu_host_page_size, PROT_READ | PROT_EXEC, | |
| 1506 | + MAP_FIXED | MAP_PRIVATE, -1, 0); | |
| 1507 | + } | |
| 1508 | + | |
| 1509 | + info->entry = elf_entry; | |
| 1510 | + | |
| 1511 | + return 0; | |
| 1512 | +} | |
| 1513 | + | |
| 1514 | +static int load_aout_interp(void * exptr, int interp_fd) | |
| 1515 | +{ | |
| 1516 | + printf("a.out interpreter not yet supported\n"); | |
| 1517 | + return(0); | |
| 1518 | +} | |
| 1519 | + | |
| 1520 | +void do_init_thread(struct target_pt_regs *regs, struct image_info *infop) | |
| 1521 | +{ | |
| 1522 | + init_thread(regs, infop); | |
| 1523 | +} | ... | ... |
bsd-user/errno_defs.h
0 โ 100644
| 1 | +/* $OpenBSD: errno.h,v 1.20 2007/09/03 14:37:52 millert Exp $ */ | |
| 2 | +/* $NetBSD: errno.h,v 1.10 1996/01/20 01:33:53 jtc Exp $ */ | |
| 3 | + | |
| 4 | +/* | |
| 5 | + * Copyright (c) 1982, 1986, 1989, 1993 | |
| 6 | + * The Regents of the University of California. All rights reserved. | |
| 7 | + * (c) UNIX System Laboratories, Inc. | |
| 8 | + * All or some portions of this file are derived from material licensed | |
| 9 | + * to the University of California by American Telephone and Telegraph | |
| 10 | + * Co. or Unix System Laboratories, Inc. and are reproduced herein with | |
| 11 | + * the permission of UNIX System Laboratories, Inc. | |
| 12 | + * | |
| 13 | + * Redistribution and use in source and binary forms, with or without | |
| 14 | + * modification, are permitted provided that the following conditions | |
| 15 | + * are met: | |
| 16 | + * 1. Redistributions of source code must retain the above copyright | |
| 17 | + * notice, this list of conditions and the following disclaimer. | |
| 18 | + * 2. Redistributions in binary form must reproduce the above copyright | |
| 19 | + * notice, this list of conditions and the following disclaimer in the | |
| 20 | + * documentation and/or other materials provided with the distribution. | |
| 21 | + * 3. Neither the name of the University nor the names of its contributors | |
| 22 | + * may be used to endorse or promote products derived from this software | |
| 23 | + * without specific prior written permission. | |
| 24 | + * | |
| 25 | + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
| 26 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 27 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 28 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
| 29 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| 30 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
| 31 | + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
| 32 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 33 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
| 34 | + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
| 35 | + * SUCH DAMAGE. | |
| 36 | + * | |
| 37 | + * @(#)errno.h 8.5 (Berkeley) 1/21/94 | |
| 38 | + */ | |
| 39 | + | |
| 40 | +#define TARGET_EPERM 1 /* Operation not permitted */ | |
| 41 | +#define TARGET_ENOENT 2 /* No such file or directory */ | |
| 42 | +#define TARGET_ESRCH 3 /* No such process */ | |
| 43 | +#define TARGET_EINTR 4 /* Interrupted system call */ | |
| 44 | +#define TARGET_EIO 5 /* Input/output error */ | |
| 45 | +#define TARGET_ENXIO 6 /* Device not configured */ | |
| 46 | +#define TARGET_E2BIG 7 /* Argument list too long */ | |
| 47 | +#define TARGET_ENOEXEC 8 /* Exec format error */ | |
| 48 | +#define TARGET_EBADF 9 /* Bad file descriptor */ | |
| 49 | +#define TARGET_ECHILD 10 /* No child processes */ | |
| 50 | +#define TARGET_EDEADLK 11 /* Resource deadlock avoided */ | |
| 51 | + /* 11 was EAGAIN */ | |
| 52 | +#define TARGET_ENOMEM 12 /* Cannot allocate memory */ | |
| 53 | +#define TARGET_EACCES 13 /* Permission denied */ | |
| 54 | +#define TARGET_EFAULT 14 /* Bad address */ | |
| 55 | +#define TARGET_ENOTBLK 15 /* Block device required */ | |
| 56 | +#define TARGET_EBUSY 16 /* Device busy */ | |
| 57 | +#define TARGET_EEXIST 17 /* File exists */ | |
| 58 | +#define TARGET_EXDEV 18 /* Cross-device link */ | |
| 59 | +#define TARGET_ENODEV 19 /* Operation not supported by device */ | |
| 60 | +#define TARGET_ENOTDIR 20 /* Not a directory */ | |
| 61 | +#define TARGET_EISDIR 21 /* Is a directory */ | |
| 62 | +#define TARGET_EINVAL 22 /* Invalid argument */ | |
| 63 | +#define TARGET_ENFILE 23 /* Too many open files in system */ | |
| 64 | +#define TARGET_EMFILE 24 /* Too many open files */ | |
| 65 | +#define TARGET_ENOTTY 25 /* Inappropriate ioctl for device */ | |
| 66 | +#define TARGET_ETXTBSY 26 /* Text file busy */ | |
| 67 | +#define TARGET_EFBIG 27 /* File too large */ | |
| 68 | +#define TARGET_ENOSPC 28 /* No space left on device */ | |
| 69 | +#define TARGET_ESPIPE 29 /* Illegal seek */ | |
| 70 | +#define TARGET_EROFS 30 /* Read-only file system */ | |
| 71 | +#define TARGET_EMLINK 31 /* Too many links */ | |
| 72 | +#define TARGET_EPIPE 32 /* Broken pipe */ | |
| 73 | + | |
| 74 | +/* math software */ | |
| 75 | +#define TARGET_EDOM 33 /* Numerical argument out of domain */ | |
| 76 | +#define TARGET_ERANGE 34 /* Result too large */ | |
| 77 | + | |
| 78 | +/* non-blocking and interrupt i/o */ | |
| 79 | +#define TARGET_EAGAIN 35 /* Resource temporarily unavailable */ | |
| 80 | +#define TARGET_EWOULDBLOCK EAGAIN /* Operation would block */ | |
| 81 | +#define TARGET_EINPROGRESS 36 /* Operation now in progress */ | |
| 82 | +#define TARGET_EALREADY 37 /* Operation already in progress */ | |
| 83 | + | |
| 84 | +/* ipc/network software -- argument errors */ | |
| 85 | +#define TARGET_ENOTSOCK 38 /* Socket operation on non-socket */ | |
| 86 | +#define TARGET_EDESTADDRREQ 39 /* Destination address required */ | |
| 87 | +#define TARGET_EMSGSIZE 40 /* Message too long */ | |
| 88 | +#define TARGET_EPROTOTYPE 41 /* Protocol wrong type for socket */ | |
| 89 | +#define TARGET_ENOPROTOOPT 42 /* Protocol not available */ | |
| 90 | +#define TARGET_EPROTONOSUPPORT 43 /* Protocol not supported */ | |
| 91 | +#define TARGET_ESOCKTNOSUPPORT 44 /* Socket type not supported */ | |
| 92 | +#define TARGET_EOPNOTSUPP 45 /* Operation not supported */ | |
| 93 | +#define TARGET_EPFNOSUPPORT 46 /* Protocol family not supported */ | |
| 94 | +#define TARGET_EAFNOSUPPORT 47 /* Address family not supported by protocol family */ | |
| 95 | +#define TARGET_EADDRINUSE 48 /* Address already in use */ | |
| 96 | +#define TARGET_EADDRNOTAVAIL 49 /* Can't assign requested address */ | |
| 97 | + | |
| 98 | +/* ipc/network software -- operational errors */ | |
| 99 | +#define TARGET_ENETDOWN 50 /* Network is down */ | |
| 100 | +#define TARGET_ENETUNREACH 51 /* Network is unreachable */ | |
| 101 | +#define TARGET_ENETRESET 52 /* Network dropped connection on reset */ | |
| 102 | +#define TARGET_ECONNABORTED 53 /* Software caused connection abort */ | |
| 103 | +#define TARGET_ECONNRESET 54 /* Connection reset by peer */ | |
| 104 | +#define TARGET_ENOBUFS 55 /* No buffer space available */ | |
| 105 | +#define TARGET_EISCONN 56 /* Socket is already connected */ | |
| 106 | +#define TARGET_ENOTCONN 57 /* Socket is not connected */ | |
| 107 | +#define TARGET_ESHUTDOWN 58 /* Can't send after socket shutdown */ | |
| 108 | +#define TARGET_ETOOMANYREFS 59 /* Too many references: can't splice */ | |
| 109 | +#define TARGET_ETIMEDOUT 60 /* Operation timed out */ | |
| 110 | +#define TARGET_ECONNREFUSED 61 /* Connection refused */ | |
| 111 | + | |
| 112 | +#define TARGET_ELOOP 62 /* Too many levels of symbolic links */ | |
| 113 | +#define TARGET_ENAMETOOLONG 63 /* File name too long */ | |
| 114 | + | |
| 115 | +/* should be rearranged */ | |
| 116 | +#define TARGET_EHOSTDOWN 64 /* Host is down */ | |
| 117 | +#define TARGET_EHOSTUNREACH 65 /* No route to host */ | |
| 118 | +#define TARGET_ENOTEMPTY 66 /* Directory not empty */ | |
| 119 | + | |
| 120 | +/* quotas & mush */ | |
| 121 | +#define TARGET_EPROCLIM 67 /* Too many processes */ | |
| 122 | +#define TARGET_EUSERS 68 /* Too many users */ | |
| 123 | +#define TARGET_EDQUOT 69 /* Disk quota exceeded */ | |
| 124 | + | |
| 125 | +/* Network File System */ | |
| 126 | +#define TARGET_ESTALE 70 /* Stale NFS file handle */ | |
| 127 | +#define TARGET_EREMOTE 71 /* Too many levels of remote in path */ | |
| 128 | +#define TARGET_EBADRPC 72 /* RPC struct is bad */ | |
| 129 | +#define TARGET_ERPCMISMATCH 73 /* RPC version wrong */ | |
| 130 | +#define TARGET_EPROGUNAVAIL 74 /* RPC prog. not avail */ | |
| 131 | +#define TARGET_EPROGMISMATCH 75 /* Program version wrong */ | |
| 132 | +#define TARGET_EPROCUNAVAIL 76 /* Bad procedure for program */ | |
| 133 | + | |
| 134 | +#define TARGET_ENOLCK 77 /* No locks available */ | |
| 135 | +#define TARGET_ENOSYS 78 /* Function not implemented */ | |
| 136 | + | |
| 137 | +#define TARGET_EFTYPE 79 /* Inappropriate file type or format */ | |
| 138 | +#define TARGET_EAUTH 80 /* Authentication error */ | |
| 139 | +#define TARGET_ENEEDAUTH 81 /* Need authenticator */ | |
| 140 | +#define TARGET_EIPSEC 82 /* IPsec processing failure */ | |
| 141 | +#define TARGET_ENOATTR 83 /* Attribute not found */ | |
| 142 | +#define TARGET_EILSEQ 84 /* Illegal byte sequence */ | |
| 143 | +#define TARGET_ENOMEDIUM 85 /* No medium found */ | |
| 144 | +#define TARGET_EMEDIUMTYPE 86 /* Wrong Medium Type */ | |
| 145 | +#define TARGET_EOVERFLOW 87 /* Conversion overflow */ | |
| 146 | +#define TARGET_ECANCELED 88 /* Operation canceled */ | |
| 147 | +#define TARGET_EIDRM 89 /* Identifier removed */ | |
| 148 | +#define TARGET_ENOMSG 90 /* No message of desired type */ | |
| 149 | +#define TARGET_ELAST 90 /* Must be equal largest errno */ | ... | ... |
bsd-user/freebsd/strace.list
0 โ 100644
| 1 | +{ TARGET_FREEBSD_NR___getcwd, "__getcwd", NULL, NULL, NULL }, | |
| 2 | +{ TARGET_FREEBSD_NR___semctl, "__semctl", NULL, NULL, NULL }, | |
| 3 | +{ TARGET_FREEBSD_NR___syscall, "__syscall", NULL, NULL, NULL }, | |
| 4 | +{ TARGET_FREEBSD_NR___sysctl, "__sysctl", NULL, NULL, NULL }, | |
| 5 | +{ TARGET_FREEBSD_NR_accept, "accept", "%s(%d,%#x,%#x)", NULL, NULL }, | |
| 6 | +{ TARGET_FREEBSD_NR_access, "access", "%s(\"%s\",%#o)", NULL, NULL }, | |
| 7 | +{ TARGET_FREEBSD_NR_acct, "acct", NULL, NULL, NULL }, | |
| 8 | +{ TARGET_FREEBSD_NR_adjtime, "adjtime", NULL, NULL, NULL }, | |
| 9 | +{ TARGET_FREEBSD_NR_bind, "bind", NULL, NULL, NULL }, | |
| 10 | +{ TARGET_FREEBSD_NR_break, "break", NULL, NULL, NULL }, | |
| 11 | +{ TARGET_FREEBSD_NR_chdir, "chdir", "%s(\"%s\")", NULL, NULL }, | |
| 12 | +{ TARGET_FREEBSD_NR_chflags, "chflags", NULL, NULL, NULL }, | |
| 13 | +{ TARGET_FREEBSD_NR_chmod, "chmod", "%s(\"%s\",%#o)", NULL, NULL }, | |
| 14 | +{ TARGET_FREEBSD_NR_chown, "chown", NULL, NULL, NULL }, | |
| 15 | +{ TARGET_FREEBSD_NR_chroot, "chroot", NULL, NULL, NULL }, | |
| 16 | +{ TARGET_FREEBSD_NR_clock_getres, "clock_getres", NULL, NULL, NULL }, | |
| 17 | +{ TARGET_FREEBSD_NR_clock_gettime, "clock_gettime", NULL, NULL, NULL }, | |
| 18 | +{ TARGET_FREEBSD_NR_clock_settime, "clock_settime", NULL, NULL, NULL }, | |
| 19 | +{ TARGET_FREEBSD_NR_close, "close", "%s(%d)", NULL, NULL }, | |
| 20 | +{ TARGET_FREEBSD_NR_connect, "connect", "%s(%d,%#x,%d)", NULL, NULL }, | |
| 21 | +{ TARGET_FREEBSD_NR_dup, "dup", NULL, NULL, NULL }, | |
| 22 | +{ TARGET_FREEBSD_NR_dup2, "dup2", NULL, NULL, NULL }, | |
| 23 | +{ TARGET_FREEBSD_NR_execve, "execve", NULL, print_execve, NULL }, | |
| 24 | +{ TARGET_FREEBSD_NR_exit, "exit", "%s(%d)\n", NULL, NULL }, | |
| 25 | +{ TARGET_FREEBSD_NR_fchdir, "fchdir", NULL, NULL, NULL }, | |
| 26 | +{ TARGET_FREEBSD_NR_fchflags, "fchflags", NULL, NULL, NULL }, | |
| 27 | +{ TARGET_FREEBSD_NR_fchmod, "fchmod", "%s(%d,%#o)", NULL, NULL }, | |
| 28 | +{ TARGET_FREEBSD_NR_fchown, "fchown", "%s(\"%s\",%d,%d)", NULL, NULL }, | |
| 29 | +{ TARGET_FREEBSD_NR_fcntl, "fcntl", NULL, NULL, NULL }, | |
| 30 | +{ TARGET_FREEBSD_NR_fhopen, "fhopen", NULL, NULL, NULL }, | |
| 31 | +{ TARGET_FREEBSD_NR_fhstat, "fhstat", NULL, NULL, NULL }, | |
| 32 | +{ TARGET_FREEBSD_NR_fhstatfs, "fhstatfs", NULL, NULL, NULL }, | |
| 33 | +{ TARGET_FREEBSD_NR_flock, "flock", NULL, NULL, NULL }, | |
| 34 | +{ TARGET_FREEBSD_NR_fork, "fork", "%s()", NULL, NULL }, | |
| 35 | +{ TARGET_FREEBSD_NR_fpathconf, "fpathconf", NULL, NULL, NULL }, | |
| 36 | +{ TARGET_FREEBSD_NR_fstat, "fstat", "%s(%d,%p)", NULL, NULL }, | |
| 37 | +{ TARGET_FREEBSD_NR_fstatfs, "fstatfs", "%s(%d,%p)", NULL, NULL }, | |
| 38 | +{ TARGET_FREEBSD_NR_fsync, "fsync", NULL, NULL, NULL }, | |
| 39 | +{ TARGET_FREEBSD_NR_ftruncate, "ftruncate", NULL, NULL, NULL }, | |
| 40 | +{ TARGET_FREEBSD_NR_futimes, "futimes", NULL, NULL, NULL }, | |
| 41 | +{ TARGET_FREEBSD_NR_getdirentries, "getdirentries", NULL, NULL, NULL }, | |
| 42 | +{ TARGET_FREEBSD_NR_getegid, "getegid", "%s()", NULL, NULL }, | |
| 43 | +{ TARGET_FREEBSD_NR_geteuid, "geteuid", "%s()", NULL, NULL }, | |
| 44 | +{ TARGET_FREEBSD_NR_getfh, "getfh", NULL, NULL, NULL }, | |
| 45 | +{ TARGET_FREEBSD_NR_getfsstat, "getfsstat", NULL, NULL, NULL }, | |
| 46 | +{ TARGET_FREEBSD_NR_getgid, "getgid", "%s()", NULL, NULL }, | |
| 47 | +{ TARGET_FREEBSD_NR_getgroups, "getgroups", NULL, NULL, NULL }, | |
| 48 | +{ TARGET_FREEBSD_NR_getitimer, "getitimer", NULL, NULL, NULL }, | |
| 49 | +{ TARGET_FREEBSD_NR_getlogin, "getlogin", NULL, NULL, NULL }, | |
| 50 | +{ TARGET_FREEBSD_NR_getpeername, "getpeername", NULL, NULL, NULL }, | |
| 51 | +{ TARGET_FREEBSD_NR_getpgid, "getpgid", NULL, NULL, NULL }, | |
| 52 | +{ TARGET_FREEBSD_NR_getpgrp, "getpgrp", "%s()", NULL, NULL }, | |
| 53 | +{ TARGET_FREEBSD_NR_getpid, "getpid", "%s()", NULL, NULL }, | |
| 54 | +{ TARGET_FREEBSD_NR_getppid, "getppid", "%s()", NULL, NULL }, | |
| 55 | +{ TARGET_FREEBSD_NR_getpriority, "getpriority", "%s(%#x,%#x)", NULL, NULL }, | |
| 56 | +{ TARGET_FREEBSD_NR_getresgid, "getresgid", NULL, NULL, NULL }, | |
| 57 | +{ TARGET_FREEBSD_NR_getresuid, "getresuid", NULL, NULL, NULL }, | |
| 58 | +{ TARGET_FREEBSD_NR_getrlimit, "getrlimit", NULL, NULL, NULL }, | |
| 59 | +{ TARGET_FREEBSD_NR_getrusage, "getrusage", NULL, NULL, NULL }, | |
| 60 | +{ TARGET_FREEBSD_NR_getsid, "getsid", NULL, NULL, NULL }, | |
| 61 | +{ TARGET_FREEBSD_NR_getsockname, "getsockname", NULL, NULL, NULL }, | |
| 62 | +{ TARGET_FREEBSD_NR_getsockopt, "getsockopt", NULL, NULL, NULL }, | |
| 63 | +{ TARGET_FREEBSD_NR_gettimeofday, "gettimeofday", NULL, NULL, NULL }, | |
| 64 | +{ TARGET_FREEBSD_NR_getuid, "getuid", "%s()", NULL, NULL }, | |
| 65 | +{ TARGET_FREEBSD_NR_ioctl, "ioctl", NULL, NULL, NULL }, | |
| 66 | +{ TARGET_FREEBSD_NR_issetugid, "issetugid", "%s()", NULL, NULL }, | |
| 67 | +{ TARGET_FREEBSD_NR_kevent, "kevent", NULL, NULL, NULL }, | |
| 68 | +{ TARGET_FREEBSD_NR_kill, "kill", NULL, NULL, NULL }, | |
| 69 | +{ TARGET_FREEBSD_NR_kqueue, "kqueue", NULL, NULL, NULL }, | |
| 70 | +{ TARGET_FREEBSD_NR_ktrace, "ktrace", NULL, NULL, NULL }, | |
| 71 | +{ TARGET_FREEBSD_NR_lchown, "lchown", NULL, NULL, NULL }, | |
| 72 | +{ TARGET_FREEBSD_NR_link, "link", "%s(\"%s\",\"%s\")", NULL, NULL }, | |
| 73 | +{ TARGET_FREEBSD_NR_listen, "listen", NULL, NULL, NULL }, | |
| 74 | +{ TARGET_FREEBSD_NR_lseek, "lseek", NULL, NULL, NULL }, | |
| 75 | +{ TARGET_FREEBSD_NR_lstat, "lstat", "%s(\"%s\",%p)", NULL, NULL }, | |
| 76 | +{ TARGET_FREEBSD_NR_madvise, "madvise", NULL, NULL, NULL }, | |
| 77 | +{ TARGET_FREEBSD_NR_mincore, "mincore", NULL, NULL, NULL }, | |
| 78 | +{ TARGET_FREEBSD_NR_minherit, "minherit", NULL, NULL, NULL }, | |
| 79 | +{ TARGET_FREEBSD_NR_mkdir, "mkdir", "%s(\"%s\",%#o)", NULL, NULL }, | |
| 80 | +{ TARGET_FREEBSD_NR_mkfifo, "mkfifo", NULL, NULL, NULL }, | |
| 81 | +{ TARGET_FREEBSD_NR_mknod, "mknod", "%s(\"%s\",%#o,%#x)", NULL, NULL }, | |
| 82 | +{ TARGET_FREEBSD_NR_mlock, "mlock", NULL, NULL, NULL }, | |
| 83 | +{ TARGET_FREEBSD_NR_mlockall, "mlockall", NULL, NULL, NULL }, | |
| 84 | +{ TARGET_FREEBSD_NR_mmap, "mmap", NULL, NULL, print_syscall_ret_addr }, | |
| 85 | +{ TARGET_FREEBSD_NR_mount, "mount", NULL, NULL, NULL }, | |
| 86 | +{ TARGET_FREEBSD_NR_mprotect, "mprotect", "%s(%#x,%#x,%d)", NULL, NULL }, | |
| 87 | +{ TARGET_FREEBSD_NR_msgctl, "msgctl", NULL, NULL, NULL }, | |
| 88 | +{ TARGET_FREEBSD_NR_msgget, "msgget", NULL, NULL, NULL }, | |
| 89 | +{ TARGET_FREEBSD_NR_msgrcv, "msgrcv", NULL, NULL, NULL }, | |
| 90 | +{ TARGET_FREEBSD_NR_msgsnd, "msgsnd", NULL, NULL, NULL }, | |
| 91 | +{ TARGET_FREEBSD_NR_msync, "msync", NULL, NULL, NULL }, | |
| 92 | +{ TARGET_FREEBSD_NR_munlock, "munlock", NULL, NULL, NULL }, | |
| 93 | +{ TARGET_FREEBSD_NR_munlockall, "munlockall", NULL, NULL, NULL }, | |
| 94 | +{ TARGET_FREEBSD_NR_munmap, "munmap", "%s(%p,%d)", NULL, NULL }, | |
| 95 | +{ TARGET_FREEBSD_NR_nanosleep, "nanosleep", NULL, NULL, NULL }, | |
| 96 | +{ TARGET_FREEBSD_NR_nfssvc, "nfssvc", NULL, NULL, NULL }, | |
| 97 | +{ TARGET_FREEBSD_NR_open, "open", "%s(\"%s\",%#x,%#o)", NULL, NULL }, | |
| 98 | +{ TARGET_FREEBSD_NR_pathconf, "pathconf", NULL, NULL, NULL }, | |
| 99 | +{ TARGET_FREEBSD_NR_pipe, "pipe", NULL, NULL, NULL }, | |
| 100 | +{ TARGET_FREEBSD_NR_poll, "poll", NULL, NULL, NULL }, | |
| 101 | +{ TARGET_FREEBSD_NR_pread, "pread", NULL, NULL, NULL }, | |
| 102 | +{ TARGET_FREEBSD_NR_preadv, "preadv", NULL, NULL, NULL }, | |
| 103 | +{ TARGET_FREEBSD_NR_profil, "profil", NULL, NULL, NULL }, | |
| 104 | +{ TARGET_FREEBSD_NR_ptrace, "ptrace", NULL, NULL, NULL }, | |
| 105 | +{ TARGET_FREEBSD_NR_pwrite, "pwrite", NULL, NULL, NULL }, | |
| 106 | +{ TARGET_FREEBSD_NR_pwritev, "pwritev", NULL, NULL, NULL }, | |
| 107 | +{ TARGET_FREEBSD_NR_quotactl, "quotactl", NULL, NULL, NULL }, | |
| 108 | +{ TARGET_FREEBSD_NR_read, "read", "%s(%d,%#x,%d)", NULL, NULL }, | |
| 109 | +{ TARGET_FREEBSD_NR_readlink, "readlink", "%s(\"%s\",%p,%d)", NULL, NULL }, | |
| 110 | +{ TARGET_FREEBSD_NR_readv, "readv", NULL, NULL, NULL }, | |
| 111 | +{ TARGET_FREEBSD_NR_reboot, "reboot", NULL, NULL, NULL }, | |
| 112 | +{ TARGET_FREEBSD_NR_recvfrom, "recvfrom", NULL, NULL, NULL }, | |
| 113 | +{ TARGET_FREEBSD_NR_recvmsg, "recvmsg", NULL, NULL, NULL }, | |
| 114 | +{ TARGET_FREEBSD_NR_rename, "rename", "%s(\"%s\",\"%s\")", NULL, NULL }, | |
| 115 | +{ TARGET_FREEBSD_NR_revoke, "revoke", NULL, NULL, NULL }, | |
| 116 | +{ TARGET_FREEBSD_NR_rfork, "rfork", NULL, NULL, NULL }, | |
| 117 | +{ TARGET_FREEBSD_NR_rmdir, "rmdir", NULL, NULL, NULL }, | |
| 118 | +{ TARGET_FREEBSD_NR_sbrk, "sbrk", NULL, NULL, NULL }, | |
| 119 | +{ TARGET_FREEBSD_NR_sched_yield, "sched_yield", NULL, NULL, NULL }, | |
| 120 | +{ TARGET_FREEBSD_NR_select, "select", NULL, NULL, NULL }, | |
| 121 | +{ TARGET_FREEBSD_NR_semget, "semget", NULL, NULL, NULL }, | |
| 122 | +{ TARGET_FREEBSD_NR_semop, "semop", NULL, NULL, NULL }, | |
| 123 | +{ TARGET_FREEBSD_NR_sendmsg, "sendmsg", NULL, NULL, NULL }, | |
| 124 | +{ TARGET_FREEBSD_NR_sendto, "sendto", NULL, NULL, NULL }, | |
| 125 | +{ TARGET_FREEBSD_NR_setegid, "setegid", NULL, NULL, NULL }, | |
| 126 | +{ TARGET_FREEBSD_NR_seteuid, "seteuid", NULL, NULL, NULL }, | |
| 127 | +{ TARGET_FREEBSD_NR_setgid, "setgid", NULL, NULL, NULL }, | |
| 128 | +{ TARGET_FREEBSD_NR_setgroups, "setgroups", NULL, NULL, NULL }, | |
| 129 | +{ TARGET_FREEBSD_NR_setitimer, "setitimer", NULL, NULL, NULL }, | |
| 130 | +{ TARGET_FREEBSD_NR_setlogin, "setlogin", NULL, NULL, NULL }, | |
| 131 | +{ TARGET_FREEBSD_NR_setpgid, "setpgid", NULL, NULL, NULL }, | |
| 132 | +{ TARGET_FREEBSD_NR_setpriority, "setpriority", NULL, NULL, NULL }, | |
| 133 | +{ TARGET_FREEBSD_NR_setregid, "setregid", NULL, NULL, NULL }, | |
| 134 | +{ TARGET_FREEBSD_NR_setresgid, "setresgid", NULL, NULL, NULL }, | |
| 135 | +{ TARGET_FREEBSD_NR_setresuid, "setresuid", NULL, NULL, NULL }, | |
| 136 | +{ TARGET_FREEBSD_NR_setreuid, "setreuid", NULL, NULL, NULL }, | |
| 137 | +{ TARGET_FREEBSD_NR_setrlimit, "setrlimit", NULL, NULL, NULL }, | |
| 138 | +{ TARGET_FREEBSD_NR_setsid, "setsid", NULL, NULL, NULL }, | |
| 139 | +{ TARGET_FREEBSD_NR_setsockopt, "setsockopt", NULL, NULL, NULL }, | |
| 140 | +{ TARGET_FREEBSD_NR_settimeofday, "settimeofday", NULL, NULL, NULL }, | |
| 141 | +{ TARGET_FREEBSD_NR_setuid, "setuid", NULL, NULL, NULL }, | |
| 142 | +{ TARGET_FREEBSD_NR_shmat, "shmat", NULL, NULL, NULL }, | |
| 143 | +{ TARGET_FREEBSD_NR_shmctl, "shmctl", NULL, NULL, NULL }, | |
| 144 | +{ TARGET_FREEBSD_NR_shmdt, "shmdt", NULL, NULL, NULL }, | |
| 145 | +{ TARGET_FREEBSD_NR_shmget, "shmget", NULL, NULL, NULL }, | |
| 146 | +{ TARGET_FREEBSD_NR_shutdown, "shutdown", NULL, NULL, NULL }, | |
| 147 | +{ TARGET_FREEBSD_NR_sigaction, "sigaction", NULL, NULL, NULL }, | |
| 148 | +{ TARGET_FREEBSD_NR_sigaltstack, "sigaltstack", "%s(%p,%p)", NULL, NULL }, | |
| 149 | +{ TARGET_FREEBSD_NR_sigpending, "sigpending", NULL, NULL, NULL }, | |
| 150 | +{ TARGET_FREEBSD_NR_sigprocmask, "sigprocmask", NULL, NULL, NULL }, | |
| 151 | +{ TARGET_FREEBSD_NR_sigreturn, "sigreturn", NULL, NULL, NULL }, | |
| 152 | +{ TARGET_FREEBSD_NR_sigsuspend, "sigsuspend", NULL, NULL, NULL }, | |
| 153 | +{ TARGET_FREEBSD_NR_socket, "socket", NULL, NULL, NULL }, | |
| 154 | +{ TARGET_FREEBSD_NR_socketpair, "socketpair", NULL, NULL, NULL }, | |
| 155 | +{ TARGET_FREEBSD_NR_sstk, "sstk", NULL, NULL, NULL }, | |
| 156 | +{ TARGET_FREEBSD_NR_stat, "stat", "%s(\"%s\",%p)", NULL, NULL }, | |
| 157 | +{ TARGET_FREEBSD_NR_statfs, "statfs", "%s(\"%s\",%p)", NULL, NULL }, | |
| 158 | +{ TARGET_FREEBSD_NR_symlink, "symlink", "%s(\"%s\",\"%s\")", NULL, NULL }, | |
| 159 | +{ TARGET_FREEBSD_NR_sync, "sync", NULL, NULL, NULL }, | |
| 160 | +{ TARGET_FREEBSD_NR_sysarch, "sysarch", NULL, NULL, NULL }, | |
| 161 | +{ TARGET_FREEBSD_NR_syscall, "syscall", NULL, NULL, NULL }, | |
| 162 | +{ TARGET_FREEBSD_NR_truncate, "truncate", NULL, NULL, NULL }, | |
| 163 | +{ TARGET_FREEBSD_NR_umask, "umask", "%s(%#o)", NULL, NULL }, | |
| 164 | +{ TARGET_FREEBSD_NR_unlink, "unlink", "%s(\"%s\")", NULL, NULL }, | |
| 165 | +{ TARGET_FREEBSD_NR_unmount, "unmount", NULL, NULL, NULL }, | |
| 166 | +{ TARGET_FREEBSD_NR_utimes, "utimes", NULL, NULL, NULL }, | |
| 167 | +{ TARGET_FREEBSD_NR_vfork, "vfork", NULL, NULL, NULL }, | |
| 168 | +{ TARGET_FREEBSD_NR_wait4, "wait4", NULL, NULL, NULL }, | |
| 169 | +{ TARGET_FREEBSD_NR_write, "write", "%s(%d,%#x,%d)", NULL, NULL }, | |
| 170 | +{ TARGET_FREEBSD_NR_writev, "writev", "%s(%d,%p,%#x)", NULL, NULL }, | ... | ... |
bsd-user/freebsd/syscall_nr.h
0 โ 100644
| 1 | +/* | |
| 2 | + * System call numbers. | |
| 3 | + * | |
| 4 | + * $FreeBSD: src/sys/sys/syscall.h,v 1.224 2008/08/24 21:23:08 rwatson Exp $ | |
| 5 | + * created from FreeBSD: head/sys/kern/syscalls.master 182123 2008-08-24 21:20:35Z rwatson | |
| 6 | + */ | |
| 7 | + | |
| 8 | +#define TARGET_FREEBSD_NR_syscall 0 | |
| 9 | +#define TARGET_FREEBSD_NR_exit 1 | |
| 10 | +#define TARGET_FREEBSD_NR_fork 2 | |
| 11 | +#define TARGET_FREEBSD_NR_read 3 | |
| 12 | +#define TARGET_FREEBSD_NR_write 4 | |
| 13 | +#define TARGET_FREEBSD_NR_open 5 | |
| 14 | +#define TARGET_FREEBSD_NR_close 6 | |
| 15 | +#define TARGET_FREEBSD_NR_wait4 7 | |
| 16 | +#define TARGET_FREEBSD_NR_link 9 | |
| 17 | +#define TARGET_FREEBSD_NR_unlink 10 | |
| 18 | +#define TARGET_FREEBSD_NR_chdir 12 | |
| 19 | +#define TARGET_FREEBSD_NR_fchdir 13 | |
| 20 | +#define TARGET_FREEBSD_NR_mknod 14 | |
| 21 | +#define TARGET_FREEBSD_NR_chmod 15 | |
| 22 | +#define TARGET_FREEBSD_NR_chown 16 | |
| 23 | +#define TARGET_FREEBSD_NR_break 17 | |
| 24 | +#define TARGET_FREEBSD_NR_freebsd4_getfsstat 18 | |
| 25 | +#define TARGET_FREEBSD_NR_getpid 20 | |
| 26 | +#define TARGET_FREEBSD_NR_mount 21 | |
| 27 | +#define TARGET_FREEBSD_NR_unmount 22 | |
| 28 | +#define TARGET_FREEBSD_NR_setuid 23 | |
| 29 | +#define TARGET_FREEBSD_NR_getuid 24 | |
| 30 | +#define TARGET_FREEBSD_NR_geteuid 25 | |
| 31 | +#define TARGET_FREEBSD_NR_ptrace 26 | |
| 32 | +#define TARGET_FREEBSD_NR_recvmsg 27 | |
| 33 | +#define TARGET_FREEBSD_NR_sendmsg 28 | |
| 34 | +#define TARGET_FREEBSD_NR_recvfrom 29 | |
| 35 | +#define TARGET_FREEBSD_NR_accept 30 | |
| 36 | +#define TARGET_FREEBSD_NR_getpeername 31 | |
| 37 | +#define TARGET_FREEBSD_NR_getsockname 32 | |
| 38 | +#define TARGET_FREEBSD_NR_access 33 | |
| 39 | +#define TARGET_FREEBSD_NR_chflags 34 | |
| 40 | +#define TARGET_FREEBSD_NR_fchflags 35 | |
| 41 | +#define TARGET_FREEBSD_NR_sync 36 | |
| 42 | +#define TARGET_FREEBSD_NR_kill 37 | |
| 43 | +#define TARGET_FREEBSD_NR_getppid 39 | |
| 44 | +#define TARGET_FREEBSD_NR_dup 41 | |
| 45 | +#define TARGET_FREEBSD_NR_pipe 42 | |
| 46 | +#define TARGET_FREEBSD_NR_getegid 43 | |
| 47 | +#define TARGET_FREEBSD_NR_profil 44 | |
| 48 | +#define TARGET_FREEBSD_NR_ktrace 45 | |
| 49 | +#define TARGET_FREEBSD_NR_getgid 47 | |
| 50 | +#define TARGET_FREEBSD_NR_getlogin 49 | |
| 51 | +#define TARGET_FREEBSD_NR_setlogin 50 | |
| 52 | +#define TARGET_FREEBSD_NR_acct 51 | |
| 53 | +#define TARGET_FREEBSD_NR_sigaltstack 53 | |
| 54 | +#define TARGET_FREEBSD_NR_ioctl 54 | |
| 55 | +#define TARGET_FREEBSD_NR_reboot 55 | |
| 56 | +#define TARGET_FREEBSD_NR_revoke 56 | |
| 57 | +#define TARGET_FREEBSD_NR_symlink 57 | |
| 58 | +#define TARGET_FREEBSD_NR_readlink 58 | |
| 59 | +#define TARGET_FREEBSD_NR_execve 59 | |
| 60 | +#define TARGET_FREEBSD_NR_umask 60 | |
| 61 | +#define TARGET_FREEBSD_NR_chroot 61 | |
| 62 | +#define TARGET_FREEBSD_NR_msync 65 | |
| 63 | +#define TARGET_FREEBSD_NR_vfork 66 | |
| 64 | +#define TARGET_FREEBSD_NR_sbrk 69 | |
| 65 | +#define TARGET_FREEBSD_NR_sstk 70 | |
| 66 | +#define TARGET_FREEBSD_NR_vadvise 72 | |
| 67 | +#define TARGET_FREEBSD_NR_munmap 73 | |
| 68 | +#define TARGET_FREEBSD_NR_mprotect 74 | |
| 69 | +#define TARGET_FREEBSD_NR_madvise 75 | |
| 70 | +#define TARGET_FREEBSD_NR_mincore 78 | |
| 71 | +#define TARGET_FREEBSD_NR_getgroups 79 | |
| 72 | +#define TARGET_FREEBSD_NR_setgroups 80 | |
| 73 | +#define TARGET_FREEBSD_NR_getpgrp 81 | |
| 74 | +#define TARGET_FREEBSD_NR_setpgid 82 | |
| 75 | +#define TARGET_FREEBSD_NR_setitimer 83 | |
| 76 | +#define TARGET_FREEBSD_NR_swapon 85 | |
| 77 | +#define TARGET_FREEBSD_NR_getitimer 86 | |
| 78 | +#define TARGET_FREEBSD_NR_getdtablesize 89 | |
| 79 | +#define TARGET_FREEBSD_NR_dup2 90 | |
| 80 | +#define TARGET_FREEBSD_NR_fcntl 92 | |
| 81 | +#define TARGET_FREEBSD_NR_select 93 | |
| 82 | +#define TARGET_FREEBSD_NR_fsync 95 | |
| 83 | +#define TARGET_FREEBSD_NR_setpriority 96 | |
| 84 | +#define TARGET_FREEBSD_NR_socket 97 | |
| 85 | +#define TARGET_FREEBSD_NR_connect 98 | |
| 86 | +#define TARGET_FREEBSD_NR_getpriority 100 | |
| 87 | +#define TARGET_FREEBSD_NR_bind 104 | |
| 88 | +#define TARGET_FREEBSD_NR_setsockopt 105 | |
| 89 | +#define TARGET_FREEBSD_NR_listen 106 | |
| 90 | +#define TARGET_FREEBSD_NR_gettimeofday 116 | |
| 91 | +#define TARGET_FREEBSD_NR_getrusage 117 | |
| 92 | +#define TARGET_FREEBSD_NR_getsockopt 118 | |
| 93 | +#define TARGET_FREEBSD_NR_readv 120 | |
| 94 | +#define TARGET_FREEBSD_NR_writev 121 | |
| 95 | +#define TARGET_FREEBSD_NR_settimeofday 122 | |
| 96 | +#define TARGET_FREEBSD_NR_fchown 123 | |
| 97 | +#define TARGET_FREEBSD_NR_fchmod 124 | |
| 98 | +#define TARGET_FREEBSD_NR_setreuid 126 | |
| 99 | +#define TARGET_FREEBSD_NR_setregid 127 | |
| 100 | +#define TARGET_FREEBSD_NR_rename 128 | |
| 101 | +#define TARGET_FREEBSD_NR_flock 131 | |
| 102 | +#define TARGET_FREEBSD_NR_mkfifo 132 | |
| 103 | +#define TARGET_FREEBSD_NR_sendto 133 | |
| 104 | +#define TARGET_FREEBSD_NR_shutdown 134 | |
| 105 | +#define TARGET_FREEBSD_NR_socketpair 135 | |
| 106 | +#define TARGET_FREEBSD_NR_mkdir 136 | |
| 107 | +#define TARGET_FREEBSD_NR_rmdir 137 | |
| 108 | +#define TARGET_FREEBSD_NR_utimes 138 | |
| 109 | +#define TARGET_FREEBSD_NR_adjtime 140 | |
| 110 | +#define TARGET_FREEBSD_NR_setsid 147 | |
| 111 | +#define TARGET_FREEBSD_NR_quotactl 148 | |
| 112 | +#define TARGET_FREEBSD_NR_nlm_syscall 154 | |
| 113 | +#define TARGET_FREEBSD_NR_nfssvc 155 | |
| 114 | +#define TARGET_FREEBSD_NR_freebsd4_statfs 157 | |
| 115 | +#define TARGET_FREEBSD_NR_freebsd4_fstatfs 158 | |
| 116 | +#define TARGET_FREEBSD_NR_lgetfh 160 | |
| 117 | +#define TARGET_FREEBSD_NR_getfh 161 | |
| 118 | +#define TARGET_FREEBSD_NR_getdomainname 162 | |
| 119 | +#define TARGET_FREEBSD_NR_setdomainname 163 | |
| 120 | +#define TARGET_FREEBSD_NR_uname 164 | |
| 121 | +#define TARGET_FREEBSD_NR_sysarch 165 | |
| 122 | +#define TARGET_FREEBSD_NR_rtprio 166 | |
| 123 | +#define TARGET_FREEBSD_NR_semsys 169 | |
| 124 | +#define TARGET_FREEBSD_NR_msgsys 170 | |
| 125 | +#define TARGET_FREEBSD_NR_shmsys 171 | |
| 126 | +#define TARGET_FREEBSD_NR_freebsd6_pread 173 | |
| 127 | +#define TARGET_FREEBSD_NR_freebsd6_pwrite 174 | |
| 128 | +#define TARGET_FREEBSD_NR_setfib 175 | |
| 129 | +#define TARGET_FREEBSD_NR_ntp_adjtime 176 | |
| 130 | +#define TARGET_FREEBSD_NR_setgid 181 | |
| 131 | +#define TARGET_FREEBSD_NR_setegid 182 | |
| 132 | +#define TARGET_FREEBSD_NR_seteuid 183 | |
| 133 | +#define TARGET_FREEBSD_NR_stat 188 | |
| 134 | +#define TARGET_FREEBSD_NR_fstat 189 | |
| 135 | +#define TARGET_FREEBSD_NR_lstat 190 | |
| 136 | +#define TARGET_FREEBSD_NR_pathconf 191 | |
| 137 | +#define TARGET_FREEBSD_NR_fpathconf 192 | |
| 138 | +#define TARGET_FREEBSD_NR_getrlimit 194 | |
| 139 | +#define TARGET_FREEBSD_NR_setrlimit 195 | |
| 140 | +#define TARGET_FREEBSD_NR_getdirentries 196 | |
| 141 | +#define TARGET_FREEBSD_NR_freebsd6_mmap 197 | |
| 142 | +#define TARGET_FREEBSD_NR___syscall 198 | |
| 143 | +#define TARGET_FREEBSD_NR_freebsd6_lseek 199 | |
| 144 | +#define TARGET_FREEBSD_NR_freebsd6_truncate 200 | |
| 145 | +#define TARGET_FREEBSD_NR_freebsd6_ftruncate 201 | |
| 146 | +#define TARGET_FREEBSD_NR___sysctl 202 | |
| 147 | +#define TARGET_FREEBSD_NR_mlock 203 | |
| 148 | +#define TARGET_FREEBSD_NR_munlock 204 | |
| 149 | +#define TARGET_FREEBSD_NR_undelete 205 | |
| 150 | +#define TARGET_FREEBSD_NR_futimes 206 | |
| 151 | +#define TARGET_FREEBSD_NR_getpgid 207 | |
| 152 | +#define TARGET_FREEBSD_NR_poll 209 | |
| 153 | +#define TARGET_FREEBSD_NR___semctl 220 | |
| 154 | +#define TARGET_FREEBSD_NR_semget 221 | |
| 155 | +#define TARGET_FREEBSD_NR_semop 222 | |
| 156 | +#define TARGET_FREEBSD_NR_msgctl 224 | |
| 157 | +#define TARGET_FREEBSD_NR_msgget 225 | |
| 158 | +#define TARGET_FREEBSD_NR_msgsnd 226 | |
| 159 | +#define TARGET_FREEBSD_NR_msgrcv 227 | |
| 160 | +#define TARGET_FREEBSD_NR_shmat 228 | |
| 161 | +#define TARGET_FREEBSD_NR_shmctl 229 | |
| 162 | +#define TARGET_FREEBSD_NR_shmdt 230 | |
| 163 | +#define TARGET_FREEBSD_NR_shmget 231 | |
| 164 | +#define TARGET_FREEBSD_NR_clock_gettime 232 | |
| 165 | +#define TARGET_FREEBSD_NR_clock_settime 233 | |
| 166 | +#define TARGET_FREEBSD_NR_clock_getres 234 | |
| 167 | +#define TARGET_FREEBSD_NR_ktimer_create 235 | |
| 168 | +#define TARGET_FREEBSD_NR_ktimer_delete 236 | |
| 169 | +#define TARGET_FREEBSD_NR_ktimer_settime 237 | |
| 170 | +#define TARGET_FREEBSD_NR_ktimer_gettime 238 | |
| 171 | +#define TARGET_FREEBSD_NR_ktimer_getoverrun 239 | |
| 172 | +#define TARGET_FREEBSD_NR_nanosleep 240 | |
| 173 | +#define TARGET_FREEBSD_NR_ntp_gettime 248 | |
| 174 | +#define TARGET_FREEBSD_NR_minherit 250 | |
| 175 | +#define TARGET_FREEBSD_NR_rfork 251 | |
| 176 | +#define TARGET_FREEBSD_NR_openbsd_poll 252 | |
| 177 | +#define TARGET_FREEBSD_NR_issetugid 253 | |
| 178 | +#define TARGET_FREEBSD_NR_lchown 254 | |
| 179 | +#define TARGET_FREEBSD_NR_aio_read 255 | |
| 180 | +#define TARGET_FREEBSD_NR_aio_write 256 | |
| 181 | +#define TARGET_FREEBSD_NR_lio_listio 257 | |
| 182 | +#define TARGET_FREEBSD_NR_getdents 272 | |
| 183 | +#define TARGET_FREEBSD_NR_lchmod 274 | |
| 184 | +#define TARGET_FREEBSD_NR_netbsd_lchown 275 | |
| 185 | +#define TARGET_FREEBSD_NR_lutimes 276 | |
| 186 | +#define TARGET_FREEBSD_NR_netbsd_msync 277 | |
| 187 | +#define TARGET_FREEBSD_NR_nstat 278 | |
| 188 | +#define TARGET_FREEBSD_NR_nfstat 279 | |
| 189 | +#define TARGET_FREEBSD_NR_nlstat 280 | |
| 190 | +#define TARGET_FREEBSD_NR_preadv 289 | |
| 191 | +#define TARGET_FREEBSD_NR_pwritev 290 | |
| 192 | +#define TARGET_FREEBSD_NR_freebsd4_fhstatfs 297 | |
| 193 | +#define TARGET_FREEBSD_NR_fhopen 298 | |
| 194 | +#define TARGET_FREEBSD_NR_fhstat 299 | |
| 195 | +#define TARGET_FREEBSD_NR_modnext 300 | |
| 196 | +#define TARGET_FREEBSD_NR_modstat 301 | |
| 197 | +#define TARGET_FREEBSD_NR_modfnext 302 | |
| 198 | +#define TARGET_FREEBSD_NR_modfind 303 | |
| 199 | +#define TARGET_FREEBSD_NR_kldload 304 | |
| 200 | +#define TARGET_FREEBSD_NR_kldunload 305 | |
| 201 | +#define TARGET_FREEBSD_NR_kldfind 306 | |
| 202 | +#define TARGET_FREEBSD_NR_kldnext 307 | |
| 203 | +#define TARGET_FREEBSD_NR_kldstat 308 | |
| 204 | +#define TARGET_FREEBSD_NR_kldfirstmod 309 | |
| 205 | +#define TARGET_FREEBSD_NR_getsid 310 | |
| 206 | +#define TARGET_FREEBSD_NR_setresuid 311 | |
| 207 | +#define TARGET_FREEBSD_NR_setresgid 312 | |
| 208 | +#define TARGET_FREEBSD_NR_aio_return 314 | |
| 209 | +#define TARGET_FREEBSD_NR_aio_suspend 315 | |
| 210 | +#define TARGET_FREEBSD_NR_aio_cancel 316 | |
| 211 | +#define TARGET_FREEBSD_NR_aio_error 317 | |
| 212 | +#define TARGET_FREEBSD_NR_oaio_read 318 | |
| 213 | +#define TARGET_FREEBSD_NR_oaio_write 319 | |
| 214 | +#define TARGET_FREEBSD_NR_olio_listio 320 | |
| 215 | +#define TARGET_FREEBSD_NR_yield 321 | |
| 216 | +#define TARGET_FREEBSD_NR_mlockall 324 | |
| 217 | +#define TARGET_FREEBSD_NR_munlockall 325 | |
| 218 | +#define TARGET_FREEBSD_NR___getcwd 326 | |
| 219 | +#define TARGET_FREEBSD_NR_sched_setparam 327 | |
| 220 | +#define TARGET_FREEBSD_NR_sched_getparam 328 | |
| 221 | +#define TARGET_FREEBSD_NR_sched_setscheduler 329 | |
| 222 | +#define TARGET_FREEBSD_NR_sched_getscheduler 330 | |
| 223 | +#define TARGET_FREEBSD_NR_sched_yield 331 | |
| 224 | +#define TARGET_FREEBSD_NR_sched_get_priority_max 332 | |
| 225 | +#define TARGET_FREEBSD_NR_sched_get_priority_min 333 | |
| 226 | +#define TARGET_FREEBSD_NR_sched_rr_get_interval 334 | |
| 227 | +#define TARGET_FREEBSD_NR_utrace 335 | |
| 228 | +#define TARGET_FREEBSD_NR_freebsd4_sendfile 336 | |
| 229 | +#define TARGET_FREEBSD_NR_kldsym 337 | |
| 230 | +#define TARGET_FREEBSD_NR_jail 338 | |
| 231 | +#define TARGET_FREEBSD_NR_sigprocmask 340 | |
| 232 | +#define TARGET_FREEBSD_NR_sigsuspend 341 | |
| 233 | +#define TARGET_FREEBSD_NR_freebsd4_sigaction 342 | |
| 234 | +#define TARGET_FREEBSD_NR_sigpending 343 | |
| 235 | +#define TARGET_FREEBSD_NR_freebsd4_sigreturn 344 | |
| 236 | +#define TARGET_FREEBSD_NR_sigtimedwait 345 | |
| 237 | +#define TARGET_FREEBSD_NR_sigwaitinfo 346 | |
| 238 | +#define TARGET_FREEBSD_NR___acl_get_file 347 | |
| 239 | +#define TARGET_FREEBSD_NR___acl_set_file 348 | |
| 240 | +#define TARGET_FREEBSD_NR___acl_get_fd 349 | |
| 241 | +#define TARGET_FREEBSD_NR___acl_set_fd 350 | |
| 242 | +#define TARGET_FREEBSD_NR___acl_delete_file 351 | |
| 243 | +#define TARGET_FREEBSD_NR___acl_delete_fd 352 | |
| 244 | +#define TARGET_FREEBSD_NR___acl_aclcheck_file 353 | |
| 245 | +#define TARGET_FREEBSD_NR___acl_aclcheck_fd 354 | |
| 246 | +#define TARGET_FREEBSD_NR_extattrctl 355 | |
| 247 | +#define TARGET_FREEBSD_NR_extattr_set_file 356 | |
| 248 | +#define TARGET_FREEBSD_NR_extattr_get_file 357 | |
| 249 | +#define TARGET_FREEBSD_NR_extattr_delete_file 358 | |
| 250 | +#define TARGET_FREEBSD_NR_aio_waitcomplete 359 | |
| 251 | +#define TARGET_FREEBSD_NR_getresuid 360 | |
| 252 | +#define TARGET_FREEBSD_NR_getresgid 361 | |
| 253 | +#define TARGET_FREEBSD_NR_kqueue 362 | |
| 254 | +#define TARGET_FREEBSD_NR_kevent 363 | |
| 255 | +#define TARGET_FREEBSD_NR_extattr_set_fd 371 | |
| 256 | +#define TARGET_FREEBSD_NR_extattr_get_fd 372 | |
| 257 | +#define TARGET_FREEBSD_NR_extattr_delete_fd 373 | |
| 258 | +#define TARGET_FREEBSD_NR___setugid 374 | |
| 259 | +#define TARGET_FREEBSD_NR_nfsclnt 375 | |
| 260 | +#define TARGET_FREEBSD_NR_eaccess 376 | |
| 261 | +#define TARGET_FREEBSD_NR_nmount 378 | |
| 262 | +#define TARGET_FREEBSD_NR___mac_get_proc 384 | |
| 263 | +#define TARGET_FREEBSD_NR___mac_set_proc 385 | |
| 264 | +#define TARGET_FREEBSD_NR___mac_get_fd 386 | |
| 265 | +#define TARGET_FREEBSD_NR___mac_get_file 387 | |
| 266 | +#define TARGET_FREEBSD_NR___mac_set_fd 388 | |
| 267 | +#define TARGET_FREEBSD_NR___mac_set_file 389 | |
| 268 | +#define TARGET_FREEBSD_NR_kenv 390 | |
| 269 | +#define TARGET_FREEBSD_NR_lchflags 391 | |
| 270 | +#define TARGET_FREEBSD_NR_uuidgen 392 | |
| 271 | +#define TARGET_FREEBSD_NR_sendfile 393 | |
| 272 | +#define TARGET_FREEBSD_NR_mac_syscall 394 | |
| 273 | +#define TARGET_FREEBSD_NR_getfsstat 395 | |
| 274 | +#define TARGET_FREEBSD_NR_statfs 396 | |
| 275 | +#define TARGET_FREEBSD_NR_fstatfs 397 | |
| 276 | +#define TARGET_FREEBSD_NR_fhstatfs 398 | |
| 277 | +#define TARGET_FREEBSD_NR_ksem_close 400 | |
| 278 | +#define TARGET_FREEBSD_NR_ksem_post 401 | |
| 279 | +#define TARGET_FREEBSD_NR_ksem_wait 402 | |
| 280 | +#define TARGET_FREEBSD_NR_ksem_trywait 403 | |
| 281 | +#define TARGET_FREEBSD_NR_ksem_init 404 | |
| 282 | +#define TARGET_FREEBSD_NR_ksem_open 405 | |
| 283 | +#define TARGET_FREEBSD_NR_ksem_unlink 406 | |
| 284 | +#define TARGET_FREEBSD_NR_ksem_getvalue 407 | |
| 285 | +#define TARGET_FREEBSD_NR_ksem_destroy 408 | |
| 286 | +#define TARGET_FREEBSD_NR___mac_get_pid 409 | |
| 287 | +#define TARGET_FREEBSD_NR___mac_get_link 410 | |
| 288 | +#define TARGET_FREEBSD_NR___mac_set_link 411 | |
| 289 | +#define TARGET_FREEBSD_NR_extattr_set_link 412 | |
| 290 | +#define TARGET_FREEBSD_NR_extattr_get_link 413 | |
| 291 | +#define TARGET_FREEBSD_NR_extattr_delete_link 414 | |
| 292 | +#define TARGET_FREEBSD_NR___mac_execve 415 | |
| 293 | +#define TARGET_FREEBSD_NR_sigaction 416 | |
| 294 | +#define TARGET_FREEBSD_NR_sigreturn 417 | |
| 295 | +#define TARGET_FREEBSD_NR_getcontext 421 | |
| 296 | +#define TARGET_FREEBSD_NR_setcontext 422 | |
| 297 | +#define TARGET_FREEBSD_NR_swapcontext 423 | |
| 298 | +#define TARGET_FREEBSD_NR_swapoff 424 | |
| 299 | +#define TARGET_FREEBSD_NR___acl_get_link 425 | |
| 300 | +#define TARGET_FREEBSD_NR___acl_set_link 426 | |
| 301 | +#define TARGET_FREEBSD_NR___acl_delete_link 427 | |
| 302 | +#define TARGET_FREEBSD_NR___acl_aclcheck_link 428 | |
| 303 | +#define TARGET_FREEBSD_NR_sigwait 429 | |
| 304 | +#define TARGET_FREEBSD_NR_thr_create 430 | |
| 305 | +#define TARGET_FREEBSD_NR_thr_exit 431 | |
| 306 | +#define TARGET_FREEBSD_NR_thr_self 432 | |
| 307 | +#define TARGET_FREEBSD_NR_thr_kill 433 | |
| 308 | +#define TARGET_FREEBSD_NR__umtx_lock 434 | |
| 309 | +#define TARGET_FREEBSD_NR__umtx_unlock 435 | |
| 310 | +#define TARGET_FREEBSD_NR_jail_attach 436 | |
| 311 | +#define TARGET_FREEBSD_NR_extattr_list_fd 437 | |
| 312 | +#define TARGET_FREEBSD_NR_extattr_list_file 438 | |
| 313 | +#define TARGET_FREEBSD_NR_extattr_list_link 439 | |
| 314 | +#define TARGET_FREEBSD_NR_ksem_timedwait 441 | |
| 315 | +#define TARGET_FREEBSD_NR_thr_suspend 442 | |
| 316 | +#define TARGET_FREEBSD_NR_thr_wake 443 | |
| 317 | +#define TARGET_FREEBSD_NR_kldunloadf 444 | |
| 318 | +#define TARGET_FREEBSD_NR_audit 445 | |
| 319 | +#define TARGET_FREEBSD_NR_auditon 446 | |
| 320 | +#define TARGET_FREEBSD_NR_getauid 447 | |
| 321 | +#define TARGET_FREEBSD_NR_setauid 448 | |
| 322 | +#define TARGET_FREEBSD_NR_getaudit 449 | |
| 323 | +#define TARGET_FREEBSD_NR_setaudit 450 | |
| 324 | +#define TARGET_FREEBSD_NR_getaudit_addr 451 | |
| 325 | +#define TARGET_FREEBSD_NR_setaudit_addr 452 | |
| 326 | +#define TARGET_FREEBSD_NR_auditctl 453 | |
| 327 | +#define TARGET_FREEBSD_NR__umtx_op 454 | |
| 328 | +#define TARGET_FREEBSD_NR_thr_new 455 | |
| 329 | +#define TARGET_FREEBSD_NR_sigqueue 456 | |
| 330 | +#define TARGET_FREEBSD_NR_kmq_open 457 | |
| 331 | +#define TARGET_FREEBSD_NR_kmq_setattr 458 | |
| 332 | +#define TARGET_FREEBSD_NR_kmq_timedreceive 459 | |
| 333 | +#define TARGET_FREEBSD_NR_kmq_timedsend 460 | |
| 334 | +#define TARGET_FREEBSD_NR_kmq_notify 461 | |
| 335 | +#define TARGET_FREEBSD_NR_kmq_unlink 462 | |
| 336 | +#define TARGET_FREEBSD_NR_abort2 463 | |
| 337 | +#define TARGET_FREEBSD_NR_thr_set_name 464 | |
| 338 | +#define TARGET_FREEBSD_NR_aio_fsync 465 | |
| 339 | +#define TARGET_FREEBSD_NR_rtprio_thread 466 | |
| 340 | +#define TARGET_FREEBSD_NR_sctp_peeloff 471 | |
| 341 | +#define TARGET_FREEBSD_NR_sctp_generic_sendmsg 472 | |
| 342 | +#define TARGET_FREEBSD_NR_sctp_generic_sendmsg_iov 473 | |
| 343 | +#define TARGET_FREEBSD_NR_sctp_generic_recvmsg 474 | |
| 344 | +#define TARGET_FREEBSD_NR_pread 475 | |
| 345 | +#define TARGET_FREEBSD_NR_pwrite 476 | |
| 346 | +#define TARGET_FREEBSD_NR_mmap 477 | |
| 347 | +#define TARGET_FREEBSD_NR_lseek 478 | |
| 348 | +#define TARGET_FREEBSD_NR_truncate 479 | |
| 349 | +#define TARGET_FREEBSD_NR_ftruncate 480 | |
| 350 | +#define TARGET_FREEBSD_NR_thr_kill2 481 | |
| 351 | +#define TARGET_FREEBSD_NR_shm_open 482 | |
| 352 | +#define TARGET_FREEBSD_NR_shm_unlink 483 | |
| 353 | +#define TARGET_FREEBSD_NR_cpuset 484 | |
| 354 | +#define TARGET_FREEBSD_NR_cpuset_setid 485 | |
| 355 | +#define TARGET_FREEBSD_NR_cpuset_getid 486 | |
| 356 | +#define TARGET_FREEBSD_NR_cpuset_getaffinity 487 | |
| 357 | +#define TARGET_FREEBSD_NR_cpuset_setaffinity 488 | |
| 358 | +#define TARGET_FREEBSD_NR_faccessat 489 | |
| 359 | +#define TARGET_FREEBSD_NR_fchmodat 490 | |
| 360 | +#define TARGET_FREEBSD_NR_fchownat 491 | |
| 361 | +#define TARGET_FREEBSD_NR_fexecve 492 | |
| 362 | +#define TARGET_FREEBSD_NR_fstatat 493 | |
| 363 | +#define TARGET_FREEBSD_NR_futimesat 494 | |
| 364 | +#define TARGET_FREEBSD_NR_linkat 495 | |
| 365 | +#define TARGET_FREEBSD_NR_mkdirat 496 | |
| 366 | +#define TARGET_FREEBSD_NR_mkfifoat 497 | |
| 367 | +#define TARGET_FREEBSD_NR_mknodat 498 | |
| 368 | +#define TARGET_FREEBSD_NR_openat 499 | |
| 369 | +#define TARGET_FREEBSD_NR_readlinkat 500 | |
| 370 | +#define TARGET_FREEBSD_NR_renameat 501 | |
| 371 | +#define TARGET_FREEBSD_NR_symlinkat 502 | |
| 372 | +#define TARGET_FREEBSD_NR_unlinkat 503 | |
| 373 | +#define TARGET_FREEBSD_NR_posix_openpt 504 | ... | ... |
bsd-user/main.c
0 โ 100644
| 1 | +/* | |
| 2 | + * qemu user main | |
| 3 | + * | |
| 4 | + * Copyright (c) 2003-2008 Fabrice Bellard | |
| 5 | + * | |
| 6 | + * This program is free software; you can redistribute it and/or modify | |
| 7 | + * it under the terms of the GNU General Public License as published by | |
| 8 | + * the Free Software Foundation; either version 2 of the License, or | |
| 9 | + * (at your option) any later version. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU General Public License | |
| 17 | + * along with this program; if not, write to the Free Software | |
| 18 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 19 | + */ | |
| 20 | +#include <stdlib.h> | |
| 21 | +#include <stdio.h> | |
| 22 | +#include <stdarg.h> | |
| 23 | +#include <string.h> | |
| 24 | +#include <errno.h> | |
| 25 | +#include <unistd.h> | |
| 26 | +#include <machine/trap.h> | |
| 27 | + | |
| 28 | +#include "qemu.h" | |
| 29 | +#include "qemu-common.h" | |
| 30 | +/* For tb_lock */ | |
| 31 | +#include "exec-all.h" | |
| 32 | + | |
| 33 | +#define DEBUG_LOGFILE "/tmp/qemu.log" | |
| 34 | + | |
| 35 | +static const char *interp_prefix = CONFIG_QEMU_PREFIX; | |
| 36 | +const char *qemu_uname_release = CONFIG_UNAME_RELEASE; | |
| 37 | +extern char **environ; | |
| 38 | + | |
| 39 | +/* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so | |
| 40 | + we allocate a bigger stack. Need a better solution, for example | |
| 41 | + by remapping the process stack directly at the right place */ | |
| 42 | +unsigned long x86_stack_size = 512 * 1024; | |
| 43 | + | |
| 44 | +void gemu_log(const char *fmt, ...) | |
| 45 | +{ | |
| 46 | + va_list ap; | |
| 47 | + | |
| 48 | + va_start(ap, fmt); | |
| 49 | + vfprintf(stderr, fmt, ap); | |
| 50 | + va_end(ap); | |
| 51 | +} | |
| 52 | +#ifdef TARGET_SPARC | |
| 53 | +#define SPARC64_STACK_BIAS 2047 | |
| 54 | + | |
| 55 | +//#define DEBUG_WIN | |
| 56 | +/* WARNING: dealing with register windows _is_ complicated. More info | |
| 57 | + can be found at http://www.sics.se/~psm/sparcstack.html */ | |
| 58 | +static inline int get_reg_index(CPUSPARCState *env, int cwp, int index) | |
| 59 | +{ | |
| 60 | + index = (index + cwp * 16) % (16 * env->nwindows); | |
| 61 | + /* wrap handling : if cwp is on the last window, then we use the | |
| 62 | + registers 'after' the end */ | |
| 63 | + if (index < 8 && env->cwp == env->nwindows - 1) | |
| 64 | + index += 16 * env->nwindows; | |
| 65 | + return index; | |
| 66 | +} | |
| 67 | + | |
| 68 | +/* save the register window 'cwp1' */ | |
| 69 | +static inline void save_window_offset(CPUSPARCState *env, int cwp1) | |
| 70 | +{ | |
| 71 | + unsigned int i; | |
| 72 | + abi_ulong sp_ptr; | |
| 73 | + | |
| 74 | + sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)]; | |
| 75 | +#ifdef TARGET_SPARC64 | |
| 76 | + if (sp_ptr & 3) | |
| 77 | + sp_ptr += SPARC64_STACK_BIAS; | |
| 78 | +#endif | |
| 79 | +#if defined(DEBUG_WIN) | |
| 80 | + printf("win_overflow: sp_ptr=0x" TARGET_ABI_FMT_lx " save_cwp=%d\n", | |
| 81 | + sp_ptr, cwp1); | |
| 82 | +#endif | |
| 83 | + for(i = 0; i < 16; i++) { | |
| 84 | + /* FIXME - what to do if put_user() fails? */ | |
| 85 | + put_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr); | |
| 86 | + sp_ptr += sizeof(abi_ulong); | |
| 87 | + } | |
| 88 | +} | |
| 89 | + | |
| 90 | +static void save_window(CPUSPARCState *env) | |
| 91 | +{ | |
| 92 | +#ifndef TARGET_SPARC64 | |
| 93 | + unsigned int new_wim; | |
| 94 | + new_wim = ((env->wim >> 1) | (env->wim << (env->nwindows - 1))) & | |
| 95 | + ((1LL << env->nwindows) - 1); | |
| 96 | + save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2)); | |
| 97 | + env->wim = new_wim; | |
| 98 | +#else | |
| 99 | + save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2)); | |
| 100 | + env->cansave++; | |
| 101 | + env->canrestore--; | |
| 102 | +#endif | |
| 103 | +} | |
| 104 | + | |
| 105 | +static void restore_window(CPUSPARCState *env) | |
| 106 | +{ | |
| 107 | +#ifndef TARGET_SPARC64 | |
| 108 | + unsigned int new_wim; | |
| 109 | +#endif | |
| 110 | + unsigned int i, cwp1; | |
| 111 | + abi_ulong sp_ptr; | |
| 112 | + | |
| 113 | +#ifndef TARGET_SPARC64 | |
| 114 | + new_wim = ((env->wim << 1) | (env->wim >> (env->nwindows - 1))) & | |
| 115 | + ((1LL << env->nwindows) - 1); | |
| 116 | +#endif | |
| 117 | + | |
| 118 | + /* restore the invalid window */ | |
| 119 | + cwp1 = cpu_cwp_inc(env, env->cwp + 1); | |
| 120 | + sp_ptr = env->regbase[get_reg_index(env, cwp1, 6)]; | |
| 121 | +#ifdef TARGET_SPARC64 | |
| 122 | + if (sp_ptr & 3) | |
| 123 | + sp_ptr += SPARC64_STACK_BIAS; | |
| 124 | +#endif | |
| 125 | +#if defined(DEBUG_WIN) | |
| 126 | + printf("win_underflow: sp_ptr=0x" TARGET_ABI_FMT_lx " load_cwp=%d\n", | |
| 127 | + sp_ptr, cwp1); | |
| 128 | +#endif | |
| 129 | + for(i = 0; i < 16; i++) { | |
| 130 | + /* FIXME - what to do if get_user() fails? */ | |
| 131 | + get_user_ual(env->regbase[get_reg_index(env, cwp1, 8 + i)], sp_ptr); | |
| 132 | + sp_ptr += sizeof(abi_ulong); | |
| 133 | + } | |
| 134 | +#ifdef TARGET_SPARC64 | |
| 135 | + env->canrestore++; | |
| 136 | + if (env->cleanwin < env->nwindows - 1) | |
| 137 | + env->cleanwin++; | |
| 138 | + env->cansave--; | |
| 139 | +#else | |
| 140 | + env->wim = new_wim; | |
| 141 | +#endif | |
| 142 | +} | |
| 143 | + | |
| 144 | +static void flush_windows(CPUSPARCState *env) | |
| 145 | +{ | |
| 146 | + int offset, cwp1; | |
| 147 | + | |
| 148 | + offset = 1; | |
| 149 | + for(;;) { | |
| 150 | + /* if restore would invoke restore_window(), then we can stop */ | |
| 151 | + cwp1 = cpu_cwp_inc(env, env->cwp + offset); | |
| 152 | +#ifndef TARGET_SPARC64 | |
| 153 | + if (env->wim & (1 << cwp1)) | |
| 154 | + break; | |
| 155 | +#else | |
| 156 | + if (env->canrestore == 0) | |
| 157 | + break; | |
| 158 | + env->cansave++; | |
| 159 | + env->canrestore--; | |
| 160 | +#endif | |
| 161 | + save_window_offset(env, cwp1); | |
| 162 | + offset++; | |
| 163 | + } | |
| 164 | + cwp1 = cpu_cwp_inc(env, env->cwp + 1); | |
| 165 | +#ifndef TARGET_SPARC64 | |
| 166 | + /* set wim so that restore will reload the registers */ | |
| 167 | + env->wim = 1 << cwp1; | |
| 168 | +#endif | |
| 169 | +#if defined(DEBUG_WIN) | |
| 170 | + printf("flush_windows: nb=%d\n", offset - 1); | |
| 171 | +#endif | |
| 172 | +} | |
| 173 | + | |
| 174 | +void cpu_loop(CPUSPARCState *env, enum BSDType bsd_type) | |
| 175 | +{ | |
| 176 | + int trapnr, ret, syscall_nr; | |
| 177 | + //target_siginfo_t info; | |
| 178 | + | |
| 179 | + while (1) { | |
| 180 | + trapnr = cpu_sparc_exec (env); | |
| 181 | + | |
| 182 | + switch (trapnr) { | |
| 183 | + case 0x100: | |
| 184 | + syscall_nr = env->gregs[1]; | |
| 185 | +#if defined(TARGET_SPARC) | |
| 186 | + syscall_nr &= ~(SYSCALL_G7RFLAG | SYSCALL_G2RFLAG); | |
| 187 | +#endif | |
| 188 | + if (bsd_type == target_freebsd) | |
| 189 | + ret = do_freebsd_syscall(env, syscall_nr, | |
| 190 | + env->regwptr[0], env->regwptr[1], | |
| 191 | + env->regwptr[2], env->regwptr[3], | |
| 192 | + env->regwptr[4], env->regwptr[5]); | |
| 193 | + else if (bsd_type == target_netbsd) | |
| 194 | + ret = do_netbsd_syscall(env, syscall_nr, | |
| 195 | + env->regwptr[0], env->regwptr[1], | |
| 196 | + env->regwptr[2], env->regwptr[3], | |
| 197 | + env->regwptr[4], env->regwptr[5]); | |
| 198 | + else //if (bsd_type == target_openbsd) | |
| 199 | + ret = do_openbsd_syscall(env, syscall_nr, | |
| 200 | + env->regwptr[0], env->regwptr[1], | |
| 201 | + env->regwptr[2], env->regwptr[3], | |
| 202 | + env->regwptr[4], env->regwptr[5]); | |
| 203 | + if ((unsigned int)ret >= (unsigned int)(-515)) { | |
| 204 | +#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) | |
| 205 | + env->xcc |= PSR_CARRY; | |
| 206 | +#else | |
| 207 | + env->psr |= PSR_CARRY; | |
| 208 | +#endif | |
| 209 | + } else { | |
| 210 | +#if defined(TARGET_SPARC64) && !defined(TARGET_ABI32) | |
| 211 | + env->xcc &= ~PSR_CARRY; | |
| 212 | +#else | |
| 213 | + env->psr &= ~PSR_CARRY; | |
| 214 | +#endif | |
| 215 | + } | |
| 216 | + env->regwptr[0] = ret; | |
| 217 | + /* next instruction */ | |
| 218 | +#if defined(TARGET_SPARC) | |
| 219 | + if (env->gregs[1] & SYSCALL_G2RFLAG) { | |
| 220 | + env->pc = env->gregs[2]; | |
| 221 | + env->npc = env->pc + 4; | |
| 222 | + } else if (env->gregs[1] & SYSCALL_G7RFLAG) { | |
| 223 | + env->pc = env->gregs[7]; | |
| 224 | + env->npc = env->pc + 4; | |
| 225 | + } else { | |
| 226 | + env->pc = env->npc; | |
| 227 | + env->npc = env->npc + 4; | |
| 228 | + } | |
| 229 | +#else | |
| 230 | + env->pc = env->npc; | |
| 231 | + env->npc = env->npc + 4; | |
| 232 | +#endif | |
| 233 | + break; | |
| 234 | + case 0x83: /* flush windows */ | |
| 235 | +#ifdef TARGET_ABI32 | |
| 236 | + case 0x103: | |
| 237 | +#endif | |
| 238 | + flush_windows(env); | |
| 239 | + /* next instruction */ | |
| 240 | + env->pc = env->npc; | |
| 241 | + env->npc = env->npc + 4; | |
| 242 | + break; | |
| 243 | +#ifndef TARGET_SPARC64 | |
| 244 | + case TT_WIN_OVF: /* window overflow */ | |
| 245 | + save_window(env); | |
| 246 | + break; | |
| 247 | + case TT_WIN_UNF: /* window underflow */ | |
| 248 | + restore_window(env); | |
| 249 | + break; | |
| 250 | + case TT_TFAULT: | |
| 251 | + case TT_DFAULT: | |
| 252 | +#if 0 | |
| 253 | + { | |
| 254 | + info.si_signo = SIGSEGV; | |
| 255 | + info.si_errno = 0; | |
| 256 | + /* XXX: check env->error_code */ | |
| 257 | + info.si_code = TARGET_SEGV_MAPERR; | |
| 258 | + info._sifields._sigfault._addr = env->mmuregs[4]; | |
| 259 | + queue_signal(env, info.si_signo, &info); | |
| 260 | + } | |
| 261 | +#endif | |
| 262 | + break; | |
| 263 | +#else | |
| 264 | + case TT_SPILL: /* window overflow */ | |
| 265 | + save_window(env); | |
| 266 | + break; | |
| 267 | + case TT_FILL: /* window underflow */ | |
| 268 | + restore_window(env); | |
| 269 | + break; | |
| 270 | + case TT_TFAULT: | |
| 271 | + case TT_DFAULT: | |
| 272 | +#if 0 | |
| 273 | + { | |
| 274 | + info.si_signo = SIGSEGV; | |
| 275 | + info.si_errno = 0; | |
| 276 | + /* XXX: check env->error_code */ | |
| 277 | + info.si_code = TARGET_SEGV_MAPERR; | |
| 278 | + if (trapnr == TT_DFAULT) | |
| 279 | + info._sifields._sigfault._addr = env->dmmuregs[4]; | |
| 280 | + else | |
| 281 | + info._sifields._sigfault._addr = env->tsptr->tpc; | |
| 282 | + //queue_signal(env, info.si_signo, &info); | |
| 283 | + } | |
| 284 | +#endif | |
| 285 | + break; | |
| 286 | +#endif | |
| 287 | + case EXCP_INTERRUPT: | |
| 288 | + /* just indicate that signals should be handled asap */ | |
| 289 | + break; | |
| 290 | + case EXCP_DEBUG: | |
| 291 | + { | |
| 292 | + int sig; | |
| 293 | + | |
| 294 | + sig = gdb_handlesig (env, TARGET_SIGTRAP); | |
| 295 | +#if 0 | |
| 296 | + if (sig) | |
| 297 | + { | |
| 298 | + info.si_signo = sig; | |
| 299 | + info.si_errno = 0; | |
| 300 | + info.si_code = TARGET_TRAP_BRKPT; | |
| 301 | + //queue_signal(env, info.si_signo, &info); | |
| 302 | + } | |
| 303 | +#endif | |
| 304 | + } | |
| 305 | + break; | |
| 306 | + default: | |
| 307 | + printf ("Unhandled trap: 0x%x\n", trapnr); | |
| 308 | + cpu_dump_state(env, stderr, fprintf, 0); | |
| 309 | + exit (1); | |
| 310 | + } | |
| 311 | + process_pending_signals (env); | |
| 312 | + } | |
| 313 | +} | |
| 314 | + | |
| 315 | +#endif | |
| 316 | + | |
| 317 | +static void usage(void) | |
| 318 | +{ | |
| 319 | + printf("qemu-" TARGET_ARCH " version " QEMU_VERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n" | |
| 320 | + "usage: qemu-" TARGET_ARCH " [options] program [arguments...]\n" | |
| 321 | + "BSD CPU emulator (compiled for %s emulation)\n" | |
| 322 | + "\n" | |
| 323 | + "Standard options:\n" | |
| 324 | + "-h print this help\n" | |
| 325 | + "-g port wait gdb connection to port\n" | |
| 326 | + "-L path set the elf interpreter prefix (default=%s)\n" | |
| 327 | + "-s size set the stack size in bytes (default=%ld)\n" | |
| 328 | + "-cpu model select CPU (-cpu ? for list)\n" | |
| 329 | + "-drop-ld-preload drop LD_PRELOAD for target process\n" | |
| 330 | + "-bsd type select emulated BSD type FreeBSD/NetBSD/OpenBSD (default)\n" | |
| 331 | + "\n" | |
| 332 | + "Debug options:\n" | |
| 333 | + "-d options activate log (logfile=%s)\n" | |
| 334 | + "-p pagesize set the host page size to 'pagesize'\n" | |
| 335 | + "-strace log system calls\n" | |
| 336 | + "\n" | |
| 337 | + "Environment variables:\n" | |
| 338 | + "QEMU_STRACE Print system calls and arguments similar to the\n" | |
| 339 | + " 'strace' program. Enable by setting to any value.\n" | |
| 340 | + , | |
| 341 | + TARGET_ARCH, | |
| 342 | + interp_prefix, | |
| 343 | + x86_stack_size, | |
| 344 | + DEBUG_LOGFILE); | |
| 345 | + _exit(1); | |
| 346 | +} | |
| 347 | + | |
| 348 | +THREAD CPUState *thread_env; | |
| 349 | + | |
| 350 | +/* Assumes contents are already zeroed. */ | |
| 351 | +void init_task_state(TaskState *ts) | |
| 352 | +{ | |
| 353 | + int i; | |
| 354 | + | |
| 355 | + ts->used = 1; | |
| 356 | + ts->first_free = ts->sigqueue_table; | |
| 357 | + for (i = 0; i < MAX_SIGQUEUE_SIZE - 1; i++) { | |
| 358 | + ts->sigqueue_table[i].next = &ts->sigqueue_table[i + 1]; | |
| 359 | + } | |
| 360 | + ts->sigqueue_table[i].next = NULL; | |
| 361 | +} | |
| 362 | + | |
| 363 | +int main(int argc, char **argv) | |
| 364 | +{ | |
| 365 | + const char *filename; | |
| 366 | + const char *cpu_model; | |
| 367 | + struct target_pt_regs regs1, *regs = ®s1; | |
| 368 | + struct image_info info1, *info = &info1; | |
| 369 | + TaskState ts1, *ts = &ts1; | |
| 370 | + CPUState *env; | |
| 371 | + int optind; | |
| 372 | + const char *r; | |
| 373 | + int gdbstub_port = 0; | |
| 374 | + int drop_ld_preload = 0, environ_count = 0; | |
| 375 | + char **target_environ, **wrk, **dst; | |
| 376 | + enum BSDType bsd_type = target_openbsd; | |
| 377 | + | |
| 378 | + if (argc <= 1) | |
| 379 | + usage(); | |
| 380 | + | |
| 381 | + /* init debug */ | |
| 382 | + cpu_set_log_filename(DEBUG_LOGFILE); | |
| 383 | + | |
| 384 | + cpu_model = NULL; | |
| 385 | + optind = 1; | |
| 386 | + for(;;) { | |
| 387 | + if (optind >= argc) | |
| 388 | + break; | |
| 389 | + r = argv[optind]; | |
| 390 | + if (r[0] != '-') | |
| 391 | + break; | |
| 392 | + optind++; | |
| 393 | + r++; | |
| 394 | + if (!strcmp(r, "-")) { | |
| 395 | + break; | |
| 396 | + } else if (!strcmp(r, "d")) { | |
| 397 | + int mask; | |
| 398 | + const CPULogItem *item; | |
| 399 | + | |
| 400 | + if (optind >= argc) | |
| 401 | + break; | |
| 402 | + | |
| 403 | + r = argv[optind++]; | |
| 404 | + mask = cpu_str_to_log_mask(r); | |
| 405 | + if (!mask) { | |
| 406 | + printf("Log items (comma separated):\n"); | |
| 407 | + for(item = cpu_log_items; item->mask != 0; item++) { | |
| 408 | + printf("%-10s %s\n", item->name, item->help); | |
| 409 | + } | |
| 410 | + exit(1); | |
| 411 | + } | |
| 412 | + cpu_set_log(mask); | |
| 413 | + } else if (!strcmp(r, "s")) { | |
| 414 | + r = argv[optind++]; | |
| 415 | + x86_stack_size = strtol(r, (char **)&r, 0); | |
| 416 | + if (x86_stack_size <= 0) | |
| 417 | + usage(); | |
| 418 | + if (*r == 'M') | |
| 419 | + x86_stack_size *= 1024 * 1024; | |
| 420 | + else if (*r == 'k' || *r == 'K') | |
| 421 | + x86_stack_size *= 1024; | |
| 422 | + } else if (!strcmp(r, "L")) { | |
| 423 | + interp_prefix = argv[optind++]; | |
| 424 | + } else if (!strcmp(r, "p")) { | |
| 425 | + qemu_host_page_size = atoi(argv[optind++]); | |
| 426 | + if (qemu_host_page_size == 0 || | |
| 427 | + (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) { | |
| 428 | + fprintf(stderr, "page size must be a power of two\n"); | |
| 429 | + exit(1); | |
| 430 | + } | |
| 431 | + } else if (!strcmp(r, "g")) { | |
| 432 | + gdbstub_port = atoi(argv[optind++]); | |
| 433 | + } else if (!strcmp(r, "r")) { | |
| 434 | + qemu_uname_release = argv[optind++]; | |
| 435 | + } else if (!strcmp(r, "cpu")) { | |
| 436 | + cpu_model = argv[optind++]; | |
| 437 | + if (strcmp(cpu_model, "?") == 0) { | |
| 438 | +/* XXX: implement xxx_cpu_list for targets that still miss it */ | |
| 439 | +#if defined(cpu_list) | |
| 440 | + cpu_list(stdout, &fprintf); | |
| 441 | +#endif | |
| 442 | + _exit(1); | |
| 443 | + } | |
| 444 | + } else if (!strcmp(r, "drop-ld-preload")) { | |
| 445 | + drop_ld_preload = 1; | |
| 446 | + } else if (!strcmp(r, "bsd")) { | |
| 447 | + if (!strcasecmp(argv[optind], "freebsd")) { | |
| 448 | + bsd_type = target_freebsd; | |
| 449 | + } else if (!strcasecmp(argv[optind], "netbsd")) { | |
| 450 | + bsd_type = target_netbsd; | |
| 451 | + } else if (!strcasecmp(argv[optind], "openbsd")) { | |
| 452 | + bsd_type = target_openbsd; | |
| 453 | + } else { | |
| 454 | + usage(); | |
| 455 | + } | |
| 456 | + optind++; | |
| 457 | + } else if (!strcmp(r, "strace")) { | |
| 458 | + do_strace = 1; | |
| 459 | + } else | |
| 460 | + { | |
| 461 | + usage(); | |
| 462 | + } | |
| 463 | + } | |
| 464 | + if (optind >= argc) | |
| 465 | + usage(); | |
| 466 | + filename = argv[optind]; | |
| 467 | + | |
| 468 | + /* Zero out regs */ | |
| 469 | + memset(regs, 0, sizeof(struct target_pt_regs)); | |
| 470 | + | |
| 471 | + /* Zero out image_info */ | |
| 472 | + memset(info, 0, sizeof(struct image_info)); | |
| 473 | + | |
| 474 | + /* Scan interp_prefix dir for replacement files. */ | |
| 475 | + init_paths(interp_prefix); | |
| 476 | + | |
| 477 | + if (cpu_model == NULL) { | |
| 478 | +#if defined(TARGET_SPARC) | |
| 479 | +#ifdef TARGET_SPARC64 | |
| 480 | + cpu_model = "TI UltraSparc II"; | |
| 481 | +#else | |
| 482 | + cpu_model = "Fujitsu MB86904"; | |
| 483 | +#endif | |
| 484 | +#else | |
| 485 | + cpu_model = "any"; | |
| 486 | +#endif | |
| 487 | + } | |
| 488 | + cpu_exec_init_all(0); | |
| 489 | + /* NOTE: we need to init the CPU at this stage to get | |
| 490 | + qemu_host_page_size */ | |
| 491 | + env = cpu_init(cpu_model); | |
| 492 | + if (!env) { | |
| 493 | + fprintf(stderr, "Unable to find CPU definition\n"); | |
| 494 | + exit(1); | |
| 495 | + } | |
| 496 | + thread_env = env; | |
| 497 | + | |
| 498 | + if (getenv("QEMU_STRACE")) { | |
| 499 | + do_strace = 1; | |
| 500 | + } | |
| 501 | + | |
| 502 | + wrk = environ; | |
| 503 | + while (*(wrk++)) | |
| 504 | + environ_count++; | |
| 505 | + | |
| 506 | + target_environ = malloc((environ_count + 1) * sizeof(char *)); | |
| 507 | + if (!target_environ) | |
| 508 | + abort(); | |
| 509 | + for (wrk = environ, dst = target_environ; *wrk; wrk++) { | |
| 510 | + if (drop_ld_preload && !strncmp(*wrk, "LD_PRELOAD=", 11)) | |
| 511 | + continue; | |
| 512 | + *(dst++) = strdup(*wrk); | |
| 513 | + } | |
| 514 | + *dst = NULL; /* NULL terminate target_environ */ | |
| 515 | + | |
| 516 | + if (loader_exec(filename, argv+optind, target_environ, regs, info) != 0) { | |
| 517 | + printf("Error loading %s\n", filename); | |
| 518 | + _exit(1); | |
| 519 | + } | |
| 520 | + | |
| 521 | + for (wrk = target_environ; *wrk; wrk++) { | |
| 522 | + free(*wrk); | |
| 523 | + } | |
| 524 | + | |
| 525 | + free(target_environ); | |
| 526 | + | |
| 527 | + if (loglevel) { | |
| 528 | + page_dump(logfile); | |
| 529 | + | |
| 530 | + fprintf(logfile, "start_brk 0x" TARGET_ABI_FMT_lx "\n", info->start_brk); | |
| 531 | + fprintf(logfile, "end_code 0x" TARGET_ABI_FMT_lx "\n", info->end_code); | |
| 532 | + fprintf(logfile, "start_code 0x" TARGET_ABI_FMT_lx "\n", | |
| 533 | + info->start_code); | |
| 534 | + fprintf(logfile, "start_data 0x" TARGET_ABI_FMT_lx "\n", | |
| 535 | + info->start_data); | |
| 536 | + fprintf(logfile, "end_data 0x" TARGET_ABI_FMT_lx "\n", info->end_data); | |
| 537 | + fprintf(logfile, "start_stack 0x" TARGET_ABI_FMT_lx "\n", | |
| 538 | + info->start_stack); | |
| 539 | + fprintf(logfile, "brk 0x" TARGET_ABI_FMT_lx "\n", info->brk); | |
| 540 | + fprintf(logfile, "entry 0x" TARGET_ABI_FMT_lx "\n", info->entry); | |
| 541 | + } | |
| 542 | + | |
| 543 | + target_set_brk(info->brk); | |
| 544 | + syscall_init(); | |
| 545 | + signal_init(); | |
| 546 | + | |
| 547 | + /* build Task State */ | |
| 548 | + memset(ts, 0, sizeof(TaskState)); | |
| 549 | + init_task_state(ts); | |
| 550 | + ts->info = info; | |
| 551 | + env->opaque = ts; | |
| 552 | + env->user_mode_only = 1; | |
| 553 | + | |
| 554 | +#if defined(TARGET_SPARC) | |
| 555 | + { | |
| 556 | + int i; | |
| 557 | + env->pc = regs->pc; | |
| 558 | + env->npc = regs->npc; | |
| 559 | + env->y = regs->y; | |
| 560 | + for(i = 0; i < 8; i++) | |
| 561 | + env->gregs[i] = regs->u_regs[i]; | |
| 562 | + for(i = 0; i < 8; i++) | |
| 563 | + env->regwptr[i] = regs->u_regs[i + 8]; | |
| 564 | + } | |
| 565 | +#else | |
| 566 | +#error unsupported target CPU | |
| 567 | +#endif | |
| 568 | + | |
| 569 | + if (gdbstub_port) { | |
| 570 | + gdbserver_start (gdbstub_port); | |
| 571 | + gdb_handlesig(env, 0); | |
| 572 | + } | |
| 573 | + cpu_loop(env, bsd_type); | |
| 574 | + /* never exits */ | |
| 575 | + return 0; | |
| 576 | +} | ... | ... |
bsd-user/mmap.c
0 โ 100644
| 1 | +/* | |
| 2 | + * mmap support for qemu | |
| 3 | + * | |
| 4 | + * Copyright (c) 2003 - 2008 Fabrice Bellard | |
| 5 | + * | |
| 6 | + * This program is free software; you can redistribute it and/or modify | |
| 7 | + * it under the terms of the GNU General Public License as published by | |
| 8 | + * the Free Software Foundation; either version 2 of the License, or | |
| 9 | + * (at your option) any later version. | |
| 10 | + * | |
| 11 | + * This program is distributed in the hope that it will be useful, | |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | + * GNU General Public License for more details. | |
| 15 | + * | |
| 16 | + * You should have received a copy of the GNU General Public License | |
| 17 | + * along with this program; if not, write to the Free Software | |
| 18 | + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 19 | + */ | |
| 20 | +#include <stdlib.h> | |
| 21 | +#include <stdio.h> | |
| 22 | +#include <stdarg.h> | |
| 23 | +#include <string.h> | |
| 24 | +#include <unistd.h> | |
| 25 | +#include <errno.h> | |
| 26 | +#include <sys/mman.h> | |
| 27 | + | |
| 28 | +#include "qemu.h" | |
| 29 | +#include "qemu-common.h" | |
| 30 | + | |
| 31 | +//#define DEBUG_MMAP | |
| 32 | + | |
| 33 | +#if defined(USE_NPTL) | |
| 34 | +pthread_mutex_t mmap_mutex; | |
| 35 | +static int __thread mmap_lock_count; | |
| 36 | + | |
| 37 | +void mmap_lock(void) | |
| 38 | +{ | |
| 39 | + if (mmap_lock_count++ == 0) { | |
| 40 | + pthread_mutex_lock(&mmap_mutex); | |
| 41 | + } | |
| 42 | +} | |
| 43 | + | |
| 44 | +void mmap_unlock(void) | |
| 45 | +{ | |
| 46 | + if (--mmap_lock_count == 0) { | |
| 47 | + pthread_mutex_unlock(&mmap_mutex); | |
| 48 | + } | |
| 49 | +} | |
| 50 | + | |
| 51 | +/* Grab lock to make sure things are in a consistent state after fork(). */ | |
| 52 | +void mmap_fork_start(void) | |
| 53 | +{ | |
| 54 | + if (mmap_lock_count) | |
| 55 | + abort(); | |
| 56 | + pthread_mutex_lock(&mmap_mutex); | |
| 57 | +} | |
| 58 | + | |
| 59 | +void mmap_fork_end(int child) | |
| 60 | +{ | |
| 61 | + if (child) | |
| 62 | + pthread_mutex_init(&mmap_mutex, NULL); | |
| 63 | + else | |
| 64 | + pthread_mutex_unlock(&mmap_mutex); | |
| 65 | +} | |
| 66 | +#else | |
| 67 | +/* We aren't threadsafe to start with, so no need to worry about locking. */ | |
| 68 | +void mmap_lock(void) | |
| 69 | +{ | |
| 70 | +} | |
| 71 | + | |
| 72 | +void mmap_unlock(void) | |
| 73 | +{ | |
| 74 | +} | |
| 75 | +#endif | |
| 76 | + | |
| 77 | +void *qemu_vmalloc(size_t size) | |
| 78 | +{ | |
| 79 | + void *p; | |
| 80 | + unsigned long addr; | |
| 81 | + mmap_lock(); | |
| 82 | + /* Use map and mark the pages as used. */ | |
| 83 | + p = mmap(NULL, size, PROT_READ | PROT_WRITE, | |
| 84 | + MAP_PRIVATE | MAP_ANON, -1, 0); | |
| 85 | + | |
| 86 | + addr = (unsigned long)p; | |
| 87 | + if (addr == (target_ulong) addr) { | |
| 88 | + /* Allocated region overlaps guest address space. | |
| 89 | + This may recurse. */ | |
| 90 | + page_set_flags(addr & TARGET_PAGE_MASK, TARGET_PAGE_ALIGN(addr + size), | |
| 91 | + PAGE_RESERVED); | |
| 92 | + } | |
| 93 | + | |
| 94 | + mmap_unlock(); | |
| 95 | + return p; | |
| 96 | +} | |
| 97 | + | |
| 98 | +void *qemu_malloc(size_t size) | |
| 99 | +{ | |
| 100 | + char * p; | |
| 101 | + size += 16; | |
| 102 | + p = qemu_vmalloc(size); | |
| 103 | + *(size_t *)p = size; | |
| 104 | + return p + 16; | |
| 105 | +} | |
| 106 | + | |
| 107 | +/* We use map, which is always zero initialized. */ | |
| 108 | +void * qemu_mallocz(size_t size) | |
| 109 | +{ | |
| 110 | + return qemu_malloc(size); | |
| 111 | +} | |
| 112 | + | |
| 113 | +void qemu_free(void *ptr) | |
| 114 | +{ | |
| 115 | + /* FIXME: We should unmark the reserved pages here. However this gets | |
| 116 | + complicated when one target page spans multiple host pages, so we | |
| 117 | + don't bother. */ | |
| 118 | + size_t *p; | |
| 119 | + p = (size_t *)((char *)ptr - 16); | |
| 120 | + munmap(p, *p); | |
| 121 | +} | |
| 122 | + | |
| 123 | +/* NOTE: all the constants are the HOST ones, but addresses are target. */ | |
| 124 | +int target_mprotect(abi_ulong start, abi_ulong len, int prot) | |
| 125 | +{ | |
| 126 | + abi_ulong end, host_start, host_end, addr; | |
| 127 | + int prot1, ret; | |
| 128 | + | |
| 129 | +#ifdef DEBUG_MMAP | |
| 130 | + printf("mprotect: start=0x" TARGET_FMT_lx | |
| 131 | + " len=0x" TARGET_FMT_lx " prot=%c%c%c\n", start, len, | |
| 132 | + prot & PROT_READ ? 'r' : '-', | |
| 133 | + prot & PROT_WRITE ? 'w' : '-', | |
| 134 | + prot & PROT_EXEC ? 'x' : '-'); | |
| 135 | +#endif | |
| 136 | + | |
| 137 | + if ((start & ~TARGET_PAGE_MASK) != 0) | |
| 138 | + return -EINVAL; | |
| 139 | + len = TARGET_PAGE_ALIGN(len); | |
| 140 | + end = start + len; | |
| 141 | + if (end < start) | |
| 142 | + return -EINVAL; | |
| 143 | + prot &= PROT_READ | PROT_WRITE | PROT_EXEC; | |
| 144 | + if (len == 0) | |
| 145 | + return 0; | |
| 146 | + | |
| 147 | + mmap_lock(); | |
| 148 | + host_start = start & qemu_host_page_mask; | |
| 149 | + host_end = HOST_PAGE_ALIGN(end); | |
| 150 | + if (start > host_start) { | |
| 151 | + /* handle host page containing start */ | |
| 152 | + prot1 = prot; | |
| 153 | + for(addr = host_start; addr < start; addr += TARGET_PAGE_SIZE) { | |
| 154 | + prot1 |= page_get_flags(addr); | |
| 155 | + } | |
| 156 | + if (host_end == host_start + qemu_host_page_size) { | |
| 157 | + for(addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) { | |
| 158 | + prot1 |= page_get_flags(addr); | |
| 159 | + } | |
| 160 | + end = host_end; | |
| 161 | + } | |
| 162 | + ret = mprotect(g2h(host_start), qemu_host_page_size, prot1 & PAGE_BITS); | |
| 163 | + if (ret != 0) | |
| 164 | + goto error; | |
| 165 | + host_start += qemu_host_page_size; | |
| 166 | + } | |
| 167 | + if (end < host_end) { | |
| 168 | + prot1 = prot; | |
| 169 | + for(addr = end; addr < host_end; addr += TARGET_PAGE_SIZE) { | |
| 170 | + prot1 |= page_get_flags(addr); | |
| 171 | + } | |
| 172 | + ret = mprotect(g2h(host_end - qemu_host_page_size), qemu_host_page_size, | |
| 173 | + prot1 & PAGE_BITS); | |
| 174 | + if (ret != 0) | |
| 175 | + goto error; | |
| 176 | + host_end -= qemu_host_page_size; | |
| 177 | + } | |
| 178 | + | |
| 179 | + /* handle the pages in the middle */ | |
| 180 | + if (host_start < host_end) { | |
| 181 | + ret = mprotect(g2h(host_start), host_end - host_start, prot); | |
| 182 | + if (ret != 0) | |
| 183 | + goto error; | |
| 184 | + } | |
| 185 | + page_set_flags(start, start + len, prot | PAGE_VALID); | |
| 186 | + mmap_unlock(); | |
| 187 | + return 0; | |
| 188 | +error: | |
| 189 | + mmap_unlock(); | |
| 190 | + return ret; | |
| 191 | +} | |
| 192 | + | |
| 193 | +/* map an incomplete host page */ | |
| 194 | +static int mmap_frag(abi_ulong real_start, | |
| 195 | + abi_ulong start, abi_ulong end, | |
| 196 | + int prot, int flags, int fd, abi_ulong offset) | |
| 197 | +{ | |
| 198 | + abi_ulong real_end, addr; | |
| 199 | + void *host_start; | |
| 200 | + int prot1, prot_new; | |
| 201 | + | |
| 202 | + real_end = real_start + qemu_host_page_size; | |
| 203 | + host_start = g2h(real_start); | |
| 204 | + | |
| 205 | + /* get the protection of the target pages outside the mapping */ | |
| 206 | + prot1 = 0; | |
| 207 | + for(addr = real_start; addr < real_end; addr++) { | |
| 208 | + if (addr < start || addr >= end) | |
| 209 | + prot1 |= page_get_flags(addr); | |
| 210 | + } | |
| 211 | + | |
| 212 | + if (prot1 == 0) { | |
| 213 | + /* no page was there, so we allocate one */ | |
| 214 | + void *p = mmap(host_start, qemu_host_page_size, prot, | |
| 215 | + flags | MAP_ANON, -1, 0); | |
| 216 | + if (p == MAP_FAILED) | |
| 217 | + return -1; | |
| 218 | + prot1 = prot; | |
| 219 | + } | |
| 220 | + prot1 &= PAGE_BITS; | |
| 221 | + | |
| 222 | + prot_new = prot | prot1; | |
| 223 | + if (!(flags & MAP_ANON)) { | |
| 224 | + /* msync() won't work here, so we return an error if write is | |
| 225 | + possible while it is a shared mapping */ | |
| 226 | + if ((flags & MAP_FLAGMASK) == MAP_SHARED && | |
| 227 | + (prot & PROT_WRITE)) | |
| 228 | + return -EINVAL; | |
| 229 | + | |
| 230 | + /* adjust protection to be able to read */ | |
| 231 | + if (!(prot1 & PROT_WRITE)) | |
| 232 | + mprotect(host_start, qemu_host_page_size, prot1 | PROT_WRITE); | |
| 233 | + | |
| 234 | + /* read the corresponding file data */ | |
| 235 | + pread(fd, g2h(start), end - start, offset); | |
| 236 | + | |
| 237 | + /* put final protection */ | |
| 238 | + if (prot_new != (prot1 | PROT_WRITE)) | |
| 239 | + mprotect(host_start, qemu_host_page_size, prot_new); | |
| 240 | + } else { | |
| 241 | + /* just update the protection */ | |
| 242 | + if (prot_new != prot1) { | |
| 243 | + mprotect(host_start, qemu_host_page_size, prot_new); | |
| 244 | + } | |
| 245 | + } | |
| 246 | + return 0; | |
| 247 | +} | |
| 248 | + | |
| 249 | +#if defined(__CYGWIN__) | |
| 250 | +/* Cygwin doesn't have a whole lot of address space. */ | |
| 251 | +static abi_ulong mmap_next_start = 0x18000000; | |
| 252 | +#else | |
| 253 | +static abi_ulong mmap_next_start = 0x40000000; | |
| 254 | +#endif | |
| 255 | + | |
| 256 | +unsigned long last_brk; | |
| 257 | + | |
| 258 | +/* find a free memory area of size 'size'. The search starts at | |
| 259 | + 'start'. If 'start' == 0, then a default start address is used. | |
| 260 | + Return -1 if error. | |
| 261 | +*/ | |
| 262 | +/* page_init() marks pages used by the host as reserved to be sure not | |
| 263 | + to use them. */ | |
| 264 | +static abi_ulong mmap_find_vma(abi_ulong start, abi_ulong size) | |
| 265 | +{ | |
| 266 | + abi_ulong addr, addr1, addr_start; | |
| 267 | + int prot; | |
| 268 | + unsigned long new_brk; | |
| 269 | + | |
| 270 | + new_brk = (unsigned long)sbrk(0); | |
| 271 | + if (last_brk && last_brk < new_brk && last_brk == (target_ulong)last_brk) { | |
| 272 | + /* This is a hack to catch the host allocating memory with brk(). | |
| 273 | + If it uses mmap then we loose. | |
| 274 | + FIXME: We really want to avoid the host allocating memory in | |
| 275 | + the first place, and maybe leave some slack to avoid switching | |
| 276 | + to mmap. */ | |
| 277 | + page_set_flags(last_brk & TARGET_PAGE_MASK, | |
| 278 | + TARGET_PAGE_ALIGN(new_brk), | |
| 279 | + PAGE_RESERVED); | |
| 280 | + } | |
| 281 | + last_brk = new_brk; | |
| 282 | + | |
| 283 | + size = HOST_PAGE_ALIGN(size); | |
| 284 | + start = start & qemu_host_page_mask; | |
| 285 | + addr = start; | |
| 286 | + if (addr == 0) | |
| 287 | + addr = mmap_next_start; | |
| 288 | + addr_start = addr; | |
| 289 | + for(;;) { | |
| 290 | + prot = 0; | |
| 291 | + for(addr1 = addr; addr1 < (addr + size); addr1 += TARGET_PAGE_SIZE) { | |
| 292 | + prot |= page_get_flags(addr1); | |
| 293 | + } | |
| 294 | + if (prot == 0) | |
| 295 | + break; | |
| 296 | + addr += qemu_host_page_size; | |
| 297 | + /* we found nothing */ | |
| 298 | + if (addr == addr_start) | |
| 299 | + return (abi_ulong)-1; | |
| 300 | + } | |
| 301 | + if (start == 0) | |
| 302 | + mmap_next_start = addr + size; | |
| 303 | + return addr; | |
| 304 | +} | |
| 305 | + | |
| 306 | +/* NOTE: all the constants are the HOST ones */ | |
| 307 | +abi_long target_mmap(abi_ulong start, abi_ulong len, int prot, | |
| 308 | + int flags, int fd, abi_ulong offset) | |
| 309 | +{ | |
| 310 | + abi_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len; | |
| 311 | + unsigned long host_start; | |
| 312 | + | |
| 313 | + mmap_lock(); | |
| 314 | +#ifdef DEBUG_MMAP | |
| 315 | + { | |
| 316 | + printf("mmap: start=0x" TARGET_FMT_lx | |
| 317 | + " len=0x" TARGET_FMT_lx " prot=%c%c%c flags=", | |
| 318 | + start, len, | |
| 319 | + prot & PROT_READ ? 'r' : '-', | |
| 320 | + prot & PROT_WRITE ? 'w' : '-', | |
| 321 | + prot & PROT_EXEC ? 'x' : '-'); | |
| 322 | + if (flags & MAP_FIXED) | |
| 323 | + printf("MAP_FIXED "); | |
| 324 | + if (flags & MAP_ANON) | |
| 325 | + printf("MAP_ANON "); | |
| 326 | + switch(flags & MAP_FLAGMASK) { | |
| 327 | + case MAP_PRIVATE: | |
| 328 | + printf("MAP_PRIVATE "); | |
| 329 | + break; | |
| 330 | + case MAP_SHARED: | |
| 331 | + printf("MAP_SHARED "); | |
| 332 | + break; | |
| 333 | + default: | |
| 334 | + printf("[MAP_FLAGMASK=0x%x] ", flags & MAP_FLAGMASK); | |
| 335 | + break; | |
| 336 | + } | |
| 337 | + printf("fd=%d offset=" TARGET_FMT_lx "\n", fd, offset); | |
| 338 | + } | |
| 339 | +#endif | |
| 340 | + | |
| 341 | + if (offset & ~TARGET_PAGE_MASK) { | |
| 342 | + errno = EINVAL; | |
| 343 | + goto fail; | |
| 344 | + } | |
| 345 | + | |
| 346 | + len = TARGET_PAGE_ALIGN(len); | |
| 347 | + if (len == 0) | |
| 348 | + goto the_end; | |
| 349 | + real_start = start & qemu_host_page_mask; | |
| 350 | + | |
| 351 | + if (!(flags & MAP_FIXED)) { | |
| 352 | + abi_ulong mmap_start; | |
| 353 | + void *p; | |
| 354 | + host_offset = offset & qemu_host_page_mask; | |
| 355 | + host_len = len + offset - host_offset; | |
| 356 | + host_len = HOST_PAGE_ALIGN(host_len); | |
| 357 | + mmap_start = mmap_find_vma(real_start, host_len); | |
| 358 | + if (mmap_start == (abi_ulong)-1) { | |
| 359 | + errno = ENOMEM; | |
| 360 | + goto fail; | |
| 361 | + } | |
| 362 | + /* Note: we prefer to control the mapping address. It is | |
| 363 | + especially important if qemu_host_page_size > | |
| 364 | + qemu_real_host_page_size */ | |
| 365 | + p = mmap(g2h(mmap_start), | |
| 366 | + host_len, prot, flags | MAP_FIXED, fd, host_offset); | |
| 367 | + if (p == MAP_FAILED) | |
| 368 | + goto fail; | |
| 369 | + /* update start so that it points to the file position at 'offset' */ | |
| 370 | + host_start = (unsigned long)p; | |
| 371 | + if (!(flags & MAP_ANON)) | |
| 372 | + host_start += offset - host_offset; | |
| 373 | + start = h2g(host_start); | |
| 374 | + } else { | |
| 375 | + int flg; | |
| 376 | + target_ulong addr; | |
| 377 | + | |
| 378 | + if (start & ~TARGET_PAGE_MASK) { | |
| 379 | + errno = EINVAL; | |
| 380 | + goto fail; | |
| 381 | + } | |
| 382 | + end = start + len; | |
| 383 | + real_end = HOST_PAGE_ALIGN(end); | |
| 384 | + | |
| 385 | + for(addr = real_start; addr < real_end; addr += TARGET_PAGE_SIZE) { | |
| 386 | + flg = page_get_flags(addr); | |
| 387 | + if (flg & PAGE_RESERVED) { | |
| 388 | + errno = ENXIO; | |
| 389 | + goto fail; | |
| 390 | + } | |
| 391 | + } | |
| 392 | + | |
| 393 | + /* worst case: we cannot map the file because the offset is not | |
| 394 | + aligned, so we read it */ | |
| 395 | + if (!(flags & MAP_ANON) && | |
| 396 | + (offset & ~qemu_host_page_mask) != (start & ~qemu_host_page_mask)) { | |
| 397 | + /* msync() won't work here, so we return an error if write is | |
| 398 | + possible while it is a shared mapping */ | |
| 399 | + if ((flags & MAP_FLAGMASK) == MAP_SHARED && | |
| 400 | + (prot & PROT_WRITE)) { | |
| 401 | + errno = EINVAL; | |
| 402 | + goto fail; | |
| 403 | + } | |
| 404 | + retaddr = target_mmap(start, len, prot | PROT_WRITE, | |
| 405 | + MAP_FIXED | MAP_PRIVATE | MAP_ANON, | |
| 406 | + -1, 0); | |
| 407 | + if (retaddr == -1) | |
| 408 | + goto fail; | |
| 409 | + pread(fd, g2h(start), len, offset); | |
| 410 | + if (!(prot & PROT_WRITE)) { | |
| 411 | + ret = target_mprotect(start, len, prot); | |
| 412 | + if (ret != 0) { | |
| 413 | + start = ret; | |
| 414 | + goto the_end; | |
| 415 | + } | |
| 416 | + } | |
| 417 | + goto the_end; | |
| 418 | + } | |
| 419 | + | |
| 420 | + /* handle the start of the mapping */ | |
| 421 | + if (start > real_start) { | |
| 422 | + if (real_end == real_start + qemu_host_page_size) { | |
| 423 | + /* one single host page */ | |
| 424 | + ret = mmap_frag(real_start, start, end, | |
| 425 | + prot, flags, fd, offset); | |
| 426 | + if (ret == -1) | |
| 427 | + goto fail; | |
| 428 | + goto the_end1; | |
| 429 | + } | |
| 430 | + ret = mmap_frag(real_start, start, real_start + qemu_host_page_size, | |
| 431 | + prot, flags, fd, offset); | |
| 432 | + if (ret == -1) | |
| 433 | + goto fail; | |
| 434 | + real_start += qemu_host_page_size; | |
| 435 | + } | |
| 436 | + /* handle the end of the mapping */ | |
| 437 | + if (end < real_end) { | |
| 438 | + ret = mmap_frag(real_end - qemu_host_page_size, | |
| 439 | + real_end - qemu_host_page_size, real_end, | |
| 440 | + prot, flags, fd, | |
| 441 | + offset + real_end - qemu_host_page_size - start); | |
| 442 | + if (ret == -1) | |
| 443 | + goto fail; | |
| 444 | + real_end -= qemu_host_page_size; | |
| 445 | + } | |
| 446 | + | |
| 447 | + /* map the middle (easier) */ | |
| 448 | + if (real_start < real_end) { | |
| 449 | + void *p; | |
| 450 | + unsigned long offset1; | |
| 451 | + if (flags & MAP_ANON) | |
| 452 | + offset1 = 0; | |
| 453 | + else | |
| 454 | + offset1 = offset + real_start - start; | |
| 455 | + p = mmap(g2h(real_start), real_end - real_start, | |
| 456 | + prot, flags, fd, offset1); | |
| 457 | + if (p == MAP_FAILED) | |
| 458 | + goto fail; | |
| 459 | + } | |
| 460 | + } | |
| 461 | + the_end1: | |
| 462 | + page_set_flags(start, start + len, prot | PAGE_VALID); | |
| 463 | + the_end: | |
| 464 | +#ifdef DEBUG_MMAP | |
| 465 | + printf("ret=0x" TARGET_FMT_lx "\n", start); | |
| 466 | + page_dump(stdout); | |
| 467 | + printf("\n"); | |
| 468 | +#endif | |
| 469 | + mmap_unlock(); | |
| 470 | + return start; | |
| 471 | +fail: | |
| 472 | + mmap_unlock(); | |
| 473 | + return -1; | |
| 474 | +} | |
| 475 | + | |
| 476 | +int target_munmap(abi_ulong start, abi_ulong len) | |
| 477 | +{ | |
| 478 | + abi_ulong end, real_start, real_end, addr; | |
| 479 | + int prot, ret; | |
| 480 | + | |
| 481 | +#ifdef DEBUG_MMAP | |
| 482 | + printf("munmap: start=0x%lx len=0x%lx\n", start, len); | |
| 483 | +#endif | |
| 484 | + if (start & ~TARGET_PAGE_MASK) | |
| 485 | + return -EINVAL; | |
| 486 | + len = TARGET_PAGE_ALIGN(len); | |
| 487 | + if (len == 0) | |
| 488 | + return -EINVAL; | |
| 489 | + mmap_lock(); | |
| 490 | + end = start + len; | |
| 491 | + real_start = start & qemu_host_page_mask; | |
| 492 | + real_end = HOST_PAGE_ALIGN(end); | |
| 493 | + | |
| 494 | + if (start > real_start) { | |
| 495 | + /* handle host page containing start */ | |
| 496 | + prot = 0; | |
| 497 | + for(addr = real_start; addr < start; addr += TARGET_PAGE_SIZE) { | |
| 498 | + prot |= page_get_flags(addr); | |
| 499 | + } | |
| 500 | + if (real_end == real_start + qemu_host_page_size) { | |
| 501 | + for(addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) { | |
| 502 | + prot |= page_get_flags(addr); | |
| 503 | + } | |
| 504 | + end = real_end; | |
| 505 | + } | |
| 506 | + if (prot != 0) | |
| 507 | + real_start += qemu_host_page_size; | |
| 508 | + } | |
| 509 | + if (end < real_end) { | |
| 510 | + prot = 0; | |
| 511 | + for(addr = end; addr < real_end; addr += TARGET_PAGE_SIZE) { | |
| 512 | + prot |= page_get_flags(addr); | |
| 513 | + } | |
| 514 | + if (prot != 0) | |
| 515 | + real_end -= qemu_host_page_size; | |
| 516 | + } | |
| 517 | + | |
| 518 | + ret = 0; | |
| 519 | + /* unmap what we can */ | |
| 520 | + if (real_start < real_end) { | |
| 521 | + ret = munmap(g2h(real_start), real_end - real_start); | |
| 522 | + } | |
| 523 | + | |
| 524 | + if (ret == 0) | |
| 525 | + page_set_flags(start, start + len, 0); | |
| 526 | + mmap_unlock(); | |
| 527 | + return ret; | |
| 528 | +} | |
| 529 | + | |
| 530 | +int target_msync(abi_ulong start, abi_ulong len, int flags) | |
| 531 | +{ | |
| 532 | + abi_ulong end; | |
| 533 | + | |
| 534 | + if (start & ~TARGET_PAGE_MASK) | |
| 535 | + return -EINVAL; | |
| 536 | + len = TARGET_PAGE_ALIGN(len); | |
| 537 | + end = start + len; | |
| 538 | + if (end < start) | |
| 539 | + return -EINVAL; | |
| 540 | + if (end == start) | |
| 541 | + return 0; | |
| 542 | + | |
| 543 | + start &= qemu_host_page_mask; | |
| 544 | + return msync(g2h(start), end - start, flags); | |
| 545 | +} | ... | ... |
bsd-user/netbsd/strace.list
0 โ 100644
| 1 | +{ TARGET_NETBSD_NR___getcwd, "__getcwd", NULL, NULL, NULL }, | |
| 2 | +{ TARGET_NETBSD_NR___syscall, "__syscall", NULL, NULL, NULL }, | |
| 3 | +{ TARGET_NETBSD_NR___sysctl, "__sysctl", NULL, NULL, NULL }, | |
| 4 | +{ TARGET_NETBSD_NR_accept, "accept", "%s(%d,%#x,%#x)", NULL, NULL }, | |
| 5 | +{ TARGET_NETBSD_NR_access, "access", "%s(\"%s\",%#o)", NULL, NULL }, | |
| 6 | +{ TARGET_NETBSD_NR_acct, "acct", NULL, NULL, NULL }, | |
| 7 | +{ TARGET_NETBSD_NR_adjtime, "adjtime", NULL, NULL, NULL }, | |
| 8 | +{ TARGET_NETBSD_NR_bind, "bind", NULL, NULL, NULL }, | |
| 9 | +{ TARGET_NETBSD_NR_break, "break", NULL, NULL, NULL }, | |
| 10 | +{ TARGET_NETBSD_NR_chdir, "chdir", "%s(\"%s\")", NULL, NULL }, | |
| 11 | +{ TARGET_NETBSD_NR_chflags, "chflags", NULL, NULL, NULL }, | |
| 12 | +{ TARGET_NETBSD_NR_chmod, "chmod", "%s(\"%s\",%#o)", NULL, NULL }, | |
| 13 | +{ TARGET_NETBSD_NR_chown, "chown", NULL, NULL, NULL }, | |
| 14 | +{ TARGET_NETBSD_NR_chroot, "chroot", NULL, NULL, NULL }, | |
| 15 | +{ TARGET_NETBSD_NR_clock_getres, "clock_getres", NULL, NULL, NULL }, | |
| 16 | +{ TARGET_NETBSD_NR_clock_gettime, "clock_gettime", NULL, NULL, NULL }, | |
| 17 | +{ TARGET_NETBSD_NR_clock_settime, "clock_settime", NULL, NULL, NULL }, | |
| 18 | +{ TARGET_NETBSD_NR_close, "close", "%s(%d)", NULL, NULL }, | |
| 19 | +{ TARGET_NETBSD_NR_connect, "connect", "%s(%d,%#x,%d)", NULL, NULL }, | |
| 20 | +{ TARGET_NETBSD_NR_dup, "dup", NULL, NULL, NULL }, | |
| 21 | +{ TARGET_NETBSD_NR_dup2, "dup2", NULL, NULL, NULL }, | |
| 22 | +{ TARGET_NETBSD_NR_execve, "execve", NULL, print_execve, NULL }, | |
| 23 | +{ TARGET_NETBSD_NR_exit, "exit", "%s(%d)\n", NULL, NULL }, | |
| 24 | +{ TARGET_NETBSD_NR_fchdir, "fchdir", NULL, NULL, NULL }, | |
| 25 | +{ TARGET_NETBSD_NR_fchflags, "fchflags", NULL, NULL, NULL }, | |
| 26 | +{ TARGET_NETBSD_NR_fchmod, "fchmod", "%s(%d,%#o)", NULL, NULL }, | |
| 27 | +{ TARGET_NETBSD_NR_fchown, "fchown", "%s(\"%s\",%d,%d)", NULL, NULL }, | |
| 28 | +{ TARGET_NETBSD_NR_fcntl, "fcntl", NULL, NULL, NULL }, | |
| 29 | +{ TARGET_NETBSD_NR_flock, "flock", NULL, NULL, NULL }, | |
| 30 | +{ TARGET_NETBSD_NR_fork, "fork", "%s()", NULL, NULL }, | |
| 31 | +{ TARGET_NETBSD_NR_fpathconf, "fpathconf", NULL, NULL, NULL }, | |
| 32 | +{ TARGET_NETBSD_NR_fsync, "fsync", NULL, NULL, NULL }, | |
| 33 | +{ TARGET_NETBSD_NR_ftruncate, "ftruncate", NULL, NULL, NULL }, | |
| 34 | +{ TARGET_NETBSD_NR_futimes, "futimes", NULL, NULL, NULL }, | |
| 35 | +{ TARGET_NETBSD_NR_getegid, "getegid", "%s()", NULL, NULL }, | |
| 36 | +{ TARGET_NETBSD_NR_geteuid, "geteuid", "%s()", NULL, NULL }, | |
| 37 | +{ TARGET_NETBSD_NR_getgid, "getgid", "%s()", NULL, NULL }, | |
| 38 | +{ TARGET_NETBSD_NR_getgroups, "getgroups", NULL, NULL, NULL }, | |
| 39 | +{ TARGET_NETBSD_NR_getitimer, "getitimer", NULL, NULL, NULL }, | |
| 40 | +{ TARGET_NETBSD_NR_getpeername, "getpeername", NULL, NULL, NULL }, | |
| 41 | +{ TARGET_NETBSD_NR_getpgid, "getpgid", NULL, NULL, NULL }, | |
| 42 | +{ TARGET_NETBSD_NR_getpgrp, "getpgrp", "%s()", NULL, NULL }, | |
| 43 | +{ TARGET_NETBSD_NR_getpid, "getpid", "%s()", NULL, NULL }, | |
| 44 | +{ TARGET_NETBSD_NR_getppid, "getppid", "%s()", NULL, NULL }, | |
| 45 | +{ TARGET_NETBSD_NR_getpriority, "getpriority", "%s(%#x,%#x)", NULL, NULL }, | |
| 46 | +{ TARGET_NETBSD_NR_getrlimit, "getrlimit", NULL, NULL, NULL }, | |
| 47 | +{ TARGET_NETBSD_NR_getrusage, "getrusage", NULL, NULL, NULL }, | |
| 48 | +{ TARGET_NETBSD_NR_getsid, "getsid", NULL, NULL, NULL }, | |
| 49 | +{ TARGET_NETBSD_NR_getsockname, "getsockname", NULL, NULL, NULL }, | |
| 50 | +{ TARGET_NETBSD_NR_getsockopt, "getsockopt", NULL, NULL, NULL }, | |
| 51 | +{ TARGET_NETBSD_NR_gettimeofday, "gettimeofday", NULL, NULL, NULL }, | |
| 52 | +{ TARGET_NETBSD_NR_getuid, "getuid", "%s()", NULL, NULL }, | |
| 53 | +{ TARGET_NETBSD_NR_ioctl, "ioctl", NULL, NULL, NULL }, | |
| 54 | +{ TARGET_NETBSD_NR_issetugid, "issetugid", "%s()", NULL, NULL }, | |
| 55 | +{ TARGET_NETBSD_NR_kevent, "kevent", NULL, NULL, NULL }, | |
| 56 | +{ TARGET_NETBSD_NR_kill, "kill", NULL, NULL, NULL }, | |
| 57 | +{ TARGET_NETBSD_NR_kqueue, "kqueue", NULL, NULL, NULL }, | |
| 58 | +{ TARGET_NETBSD_NR_ktrace, "ktrace", NULL, NULL, NULL }, | |
| 59 | +{ TARGET_NETBSD_NR_lchown, "lchown", NULL, NULL, NULL }, | |
| 60 | +{ TARGET_NETBSD_NR_lfs_bmapv, "lfs_bmapv", NULL, NULL, NULL }, | |
| 61 | +{ TARGET_NETBSD_NR_lfs_markv, "lfs_markv", NULL, NULL, NULL }, | |
| 62 | +{ TARGET_NETBSD_NR_lfs_segclean, "lfs_segclean", NULL, NULL, NULL }, | |
| 63 | +{ TARGET_NETBSD_NR_lfs_segwait, "lfs_segwait", NULL, NULL, NULL }, | |
| 64 | +{ TARGET_NETBSD_NR_link, "link", "%s(\"%s\",\"%s\")", NULL, NULL }, | |
| 65 | +{ TARGET_NETBSD_NR_listen, "listen", NULL, NULL, NULL }, | |
| 66 | +{ TARGET_NETBSD_NR_lseek, "lseek", NULL, NULL, NULL }, | |
| 67 | +{ TARGET_NETBSD_NR_madvise, "madvise", NULL, NULL, NULL }, | |
| 68 | +{ TARGET_NETBSD_NR_mincore, "mincore", NULL, NULL, NULL }, | |
| 69 | +{ TARGET_NETBSD_NR_minherit, "minherit", NULL, NULL, NULL }, | |
| 70 | +{ TARGET_NETBSD_NR_mkdir, "mkdir", "%s(\"%s\",%#o)", NULL, NULL }, | |
| 71 | +{ TARGET_NETBSD_NR_mkfifo, "mkfifo", NULL, NULL, NULL }, | |
| 72 | +{ TARGET_NETBSD_NR_mknod, "mknod", "%s(\"%s\",%#o,%#x)", NULL, NULL }, | |
| 73 | +{ TARGET_NETBSD_NR_mlock, "mlock", NULL, NULL, NULL }, | |
| 74 | +{ TARGET_NETBSD_NR_mlockall, "mlockall", NULL, NULL, NULL }, | |
| 75 | +{ TARGET_NETBSD_NR_mmap, "mmap", NULL, NULL, print_syscall_ret_addr }, | |
| 76 | +{ TARGET_NETBSD_NR_mprotect, "mprotect", "%s(%#x,%#x,%d)", NULL, NULL }, | |
| 77 | +{ TARGET_NETBSD_NR_msgget, "msgget", NULL, NULL, NULL }, | |
| 78 | +{ TARGET_NETBSD_NR_msgrcv, "msgrcv", NULL, NULL, NULL }, | |
| 79 | +{ TARGET_NETBSD_NR_msgsnd, "msgsnd", NULL, NULL, NULL }, | |
| 80 | +{ TARGET_NETBSD_NR_munlock, "munlock", NULL, NULL, NULL }, | |
| 81 | +{ TARGET_NETBSD_NR_munlockall, "munlockall", NULL, NULL, NULL }, | |
| 82 | +{ TARGET_NETBSD_NR_munmap, "munmap", "%s(%p,%d)", NULL, NULL }, | |
| 83 | +{ TARGET_NETBSD_NR_nanosleep, "nanosleep", NULL, NULL, NULL }, | |
| 84 | +{ TARGET_NETBSD_NR_nfssvc, "nfssvc", NULL, NULL, NULL }, | |
| 85 | +{ TARGET_NETBSD_NR_open, "open", "%s(\"%s\",%#x,%#o)", NULL, NULL }, | |
| 86 | +{ TARGET_NETBSD_NR_pathconf, "pathconf", NULL, NULL, NULL }, | |
| 87 | +{ TARGET_NETBSD_NR_pipe, "pipe", NULL, NULL, NULL }, | |
| 88 | +{ TARGET_NETBSD_NR_poll, "poll", NULL, NULL, NULL }, | |
| 89 | +{ TARGET_NETBSD_NR_pread, "pread", NULL, NULL, NULL }, | |
| 90 | +{ TARGET_NETBSD_NR_preadv, "preadv", NULL, NULL, NULL }, | |
| 91 | +{ TARGET_NETBSD_NR_profil, "profil", NULL, NULL, NULL }, | |
| 92 | +{ TARGET_NETBSD_NR_ptrace, "ptrace", NULL, NULL, NULL }, | |
| 93 | +{ TARGET_NETBSD_NR_pwrite, "pwrite", NULL, NULL, NULL }, | |
| 94 | +{ TARGET_NETBSD_NR_pwritev, "pwritev", NULL, NULL, NULL }, | |
| 95 | +{ TARGET_NETBSD_NR_quotactl, "quotactl", NULL, NULL, NULL }, | |
| 96 | +{ TARGET_NETBSD_NR_read, "read", "%s(%d,%#x,%d)", NULL, NULL }, | |
| 97 | +{ TARGET_NETBSD_NR_readlink, "readlink", "%s(\"%s\",%p,%d)", NULL, NULL }, | |
| 98 | +{ TARGET_NETBSD_NR_readv, "readv", NULL, NULL, NULL }, | |
| 99 | +{ TARGET_NETBSD_NR_reboot, "reboot", NULL, NULL, NULL }, | |
| 100 | +{ TARGET_NETBSD_NR_recvfrom, "recvfrom", NULL, NULL, NULL }, | |
| 101 | +{ TARGET_NETBSD_NR_recvmsg, "recvmsg", NULL, NULL, NULL }, | |
| 102 | +{ TARGET_NETBSD_NR_rename, "rename", "%s(\"%s\",\"%s\")", NULL, NULL }, | |
| 103 | +{ TARGET_NETBSD_NR_revoke, "revoke", NULL, NULL, NULL }, | |
| 104 | +{ TARGET_NETBSD_NR_rmdir, "rmdir", NULL, NULL, NULL }, | |
| 105 | +{ TARGET_NETBSD_NR_sbrk, "sbrk", NULL, NULL, NULL }, | |
| 106 | +{ TARGET_NETBSD_NR_sched_yield, "sched_yield", NULL, NULL, NULL }, | |
| 107 | +{ TARGET_NETBSD_NR_select, "select", NULL, NULL, NULL }, | |
| 108 | +{ TARGET_NETBSD_NR_semget, "semget", NULL, NULL, NULL }, | |
| 109 | +{ TARGET_NETBSD_NR_semop, "semop", NULL, NULL, NULL }, | |
| 110 | +{ TARGET_NETBSD_NR_sendmsg, "sendmsg", NULL, NULL, NULL }, | |
| 111 | +{ TARGET_NETBSD_NR_sendto, "sendto", NULL, NULL, NULL }, | |
| 112 | +{ TARGET_NETBSD_NR_setegid, "setegid", NULL, NULL, NULL }, | |
| 113 | +{ TARGET_NETBSD_NR_seteuid, "seteuid", NULL, NULL, NULL }, | |
| 114 | +{ TARGET_NETBSD_NR_setgid, "setgid", NULL, NULL, NULL }, | |
| 115 | +{ TARGET_NETBSD_NR_setgroups, "setgroups", NULL, NULL, NULL }, | |
| 116 | +{ TARGET_NETBSD_NR_setitimer, "setitimer", NULL, NULL, NULL }, | |
| 117 | +{ TARGET_NETBSD_NR_setpgid, "setpgid", NULL, NULL, NULL }, | |
| 118 | +{ TARGET_NETBSD_NR_setpriority, "setpriority", NULL, NULL, NULL }, | |
| 119 | +{ TARGET_NETBSD_NR_setregid, "setregid", NULL, NULL, NULL }, | |
| 120 | +{ TARGET_NETBSD_NR_setreuid, "setreuid", NULL, NULL, NULL }, | |
| 121 | +{ TARGET_NETBSD_NR_setrlimit, "setrlimit", NULL, NULL, NULL }, | |
| 122 | +{ TARGET_NETBSD_NR_setsid, "setsid", NULL, NULL, NULL }, | |
| 123 | +{ TARGET_NETBSD_NR_setsockopt, "setsockopt", NULL, NULL, NULL }, | |
| 124 | +{ TARGET_NETBSD_NR_settimeofday, "settimeofday", NULL, NULL, NULL }, | |
| 125 | +{ TARGET_NETBSD_NR_setuid, "setuid", NULL, NULL, NULL }, | |
| 126 | +{ TARGET_NETBSD_NR_shmat, "shmat", NULL, NULL, NULL }, | |
| 127 | +{ TARGET_NETBSD_NR_shmdt, "shmdt", NULL, NULL, NULL }, | |
| 128 | +{ TARGET_NETBSD_NR_shmget, "shmget", NULL, NULL, NULL }, | |
| 129 | +{ TARGET_NETBSD_NR_shutdown, "shutdown", NULL, NULL, NULL }, | |
| 130 | +{ TARGET_NETBSD_NR_socketpair, "socketpair", NULL, NULL, NULL }, | |
| 131 | +{ TARGET_NETBSD_NR_sstk, "sstk", NULL, NULL, NULL }, | |
| 132 | +{ TARGET_NETBSD_NR_swapctl, "swapctl", NULL, NULL, NULL }, | |
| 133 | +{ TARGET_NETBSD_NR_symlink, "symlink", "%s(\"%s\",\"%s\")", NULL, NULL }, | |
| 134 | +{ TARGET_NETBSD_NR_sync, "sync", NULL, NULL, NULL }, | |
| 135 | +{ TARGET_NETBSD_NR_sysarch, "sysarch", NULL, NULL, NULL }, | |
| 136 | +{ TARGET_NETBSD_NR_syscall, "syscall", NULL, NULL, NULL }, | |
| 137 | +{ TARGET_NETBSD_NR_truncate, "truncate", NULL, NULL, NULL }, | |
| 138 | +{ TARGET_NETBSD_NR_umask, "umask", "%s(%#o)", NULL, NULL }, | |
| 139 | +{ TARGET_NETBSD_NR_unlink, "unlink", "%s(\"%s\")", NULL, NULL }, | |
| 140 | +{ TARGET_NETBSD_NR_unmount, "unmount", NULL, NULL, NULL }, | |
| 141 | +{ TARGET_NETBSD_NR_utimes, "utimes", NULL, NULL, NULL }, | |
| 142 | +{ TARGET_NETBSD_NR_vfork, "vfork", NULL, NULL, NULL }, | |
| 143 | +{ TARGET_NETBSD_NR_wait4, "wait4", NULL, NULL, NULL }, | |
| 144 | +{ TARGET_NETBSD_NR_write, "write", "%s(%d,%#x,%d)", NULL, NULL }, | |
| 145 | +{ TARGET_NETBSD_NR_writev, "writev", "%s(%d,%p,%#x)", NULL, NULL }, | ... | ... |
bsd-user/netbsd/syscall_nr.h
0 โ 100644
| 1 | +/* $NetBSD: syscall.h,v 1.215 2008/06/17 16:07:57 tsutsui Exp $ */ | |
| 2 | + | |
| 3 | +/* | |
| 4 | + * System call numbers. | |
| 5 | + * | |
| 6 | + * created from NetBSD: syscalls.master,v 1.204 2008/06/17 16:05:23 tsutsui Exp | |
| 7 | + */ | |
| 8 | + | |
| 9 | +#define TARGET_NETBSD_NR_syscall 0 | |
| 10 | +#define TARGET_NETBSD_NR_exit 1 | |
| 11 | +#define TARGET_NETBSD_NR_fork 2 | |
| 12 | +#define TARGET_NETBSD_NR_read 3 | |
| 13 | +#define TARGET_NETBSD_NR_write 4 | |
| 14 | +#define TARGET_NETBSD_NR_open 5 | |
| 15 | +#define TARGET_NETBSD_NR_close 6 | |
| 16 | +#define TARGET_NETBSD_NR_wait4 7 | |
| 17 | +#define TARGET_NETBSD_NR_compat_43_ocreat 8 | |
| 18 | +#define TARGET_NETBSD_NR_link 9 | |
| 19 | +#define TARGET_NETBSD_NR_unlink 10 | |
| 20 | +#define TARGET_NETBSD_NR_chdir 12 | |
| 21 | +#define TARGET_NETBSD_NR_fchdir 13 | |
| 22 | +#define TARGET_NETBSD_NR_mknod 14 | |
| 23 | +#define TARGET_NETBSD_NR_chmod 15 | |
| 24 | +#define TARGET_NETBSD_NR_chown 16 | |
| 25 | +#define TARGET_NETBSD_NR_break 17 | |
| 26 | +#define TARGET_NETBSD_NR_compat_20_getfsstat 18 | |
| 27 | +#define TARGET_NETBSD_NR_compat_43_olseek 19 | |
| 28 | +#define TARGET_NETBSD_NR_getpid 20 | |
| 29 | +#define TARGET_NETBSD_NR_getpid 20 | |
| 30 | +#define TARGET_NETBSD_NR_compat_40_mount 21 | |
| 31 | +#define TARGET_NETBSD_NR_unmount 22 | |
| 32 | +#define TARGET_NETBSD_NR_setuid 23 | |
| 33 | +#define TARGET_NETBSD_NR_getuid 24 | |
| 34 | +#define TARGET_NETBSD_NR_getuid 24 | |
| 35 | +#define TARGET_NETBSD_NR_geteuid 25 | |
| 36 | +#define TARGET_NETBSD_NR_ptrace 26 | |
| 37 | +#define TARGET_NETBSD_NR_recvmsg 27 | |
| 38 | +#define TARGET_NETBSD_NR_sendmsg 28 | |
| 39 | +#define TARGET_NETBSD_NR_recvfrom 29 | |
| 40 | +#define TARGET_NETBSD_NR_accept 30 | |
| 41 | +#define TARGET_NETBSD_NR_getpeername 31 | |
| 42 | +#define TARGET_NETBSD_NR_getsockname 32 | |
| 43 | +#define TARGET_NETBSD_NR_access 33 | |
| 44 | +#define TARGET_NETBSD_NR_chflags 34 | |
| 45 | +#define TARGET_NETBSD_NR_fchflags 35 | |
| 46 | +#define TARGET_NETBSD_NR_sync 36 | |
| 47 | +#define TARGET_NETBSD_NR_kill 37 | |
| 48 | +#define TARGET_NETBSD_NR_compat_43_stat43 38 | |
| 49 | +#define TARGET_NETBSD_NR_getppid 39 | |
| 50 | +#define TARGET_NETBSD_NR_compat_43_lstat43 40 | |
| 51 | +#define TARGET_NETBSD_NR_dup 41 | |
| 52 | +#define TARGET_NETBSD_NR_pipe 42 | |
| 53 | +#define TARGET_NETBSD_NR_getegid 43 | |
| 54 | +#define TARGET_NETBSD_NR_profil 44 | |
| 55 | +#define TARGET_NETBSD_NR_ktrace 45 | |
| 56 | +#define TARGET_NETBSD_NR_compat_13_sigaction13 46 | |
| 57 | +#define TARGET_NETBSD_NR_getgid 47 | |
| 58 | +#define TARGET_NETBSD_NR_getgid 47 | |
| 59 | +#define TARGET_NETBSD_NR_compat_13_sigprocmask13 48 | |
| 60 | +#define TARGET_NETBSD_NR___getlogin 49 | |
| 61 | +#define TARGET_NETBSD_NR___setlogin 50 | |
| 62 | +#define TARGET_NETBSD_NR_acct 51 | |
| 63 | +#define TARGET_NETBSD_NR_compat_13_sigpending13 52 | |
| 64 | +#define TARGET_NETBSD_NR_compat_13_sigaltstack13 53 | |
| 65 | +#define TARGET_NETBSD_NR_ioctl 54 | |
| 66 | +#define TARGET_NETBSD_NR_compat_12_oreboot 55 | |
| 67 | +#define TARGET_NETBSD_NR_revoke 56 | |
| 68 | +#define TARGET_NETBSD_NR_symlink 57 | |
| 69 | +#define TARGET_NETBSD_NR_readlink 58 | |
| 70 | +#define TARGET_NETBSD_NR_execve 59 | |
| 71 | +#define TARGET_NETBSD_NR_umask 60 | |
| 72 | +#define TARGET_NETBSD_NR_chroot 61 | |
| 73 | +#define TARGET_NETBSD_NR_compat_43_fstat43 62 | |
| 74 | +#define TARGET_NETBSD_NR_compat_43_ogetkerninfo 63 | |
| 75 | +#define TARGET_NETBSD_NR_compat_43_ogetpagesize 64 | |
| 76 | +#define TARGET_NETBSD_NR_compat_12_msync 65 | |
| 77 | +#define TARGET_NETBSD_NR_vfork 66 | |
| 78 | +#define TARGET_NETBSD_NR_sbrk 69 | |
| 79 | +#define TARGET_NETBSD_NR_sstk 70 | |
| 80 | +#define TARGET_NETBSD_NR_compat_43_ommap 71 | |
| 81 | +#define TARGET_NETBSD_NR_vadvise 72 | |
| 82 | +#define TARGET_NETBSD_NR_munmap 73 | |
| 83 | +#define TARGET_NETBSD_NR_mprotect 74 | |
| 84 | +#define TARGET_NETBSD_NR_madvise 75 | |
| 85 | +#define TARGET_NETBSD_NR_mincore 78 | |
| 86 | +#define TARGET_NETBSD_NR_getgroups 79 | |
| 87 | +#define TARGET_NETBSD_NR_setgroups 80 | |
| 88 | +#define TARGET_NETBSD_NR_getpgrp 81 | |
| 89 | +#define TARGET_NETBSD_NR_setpgid 82 | |
| 90 | +#define TARGET_NETBSD_NR_setitimer 83 | |
| 91 | +#define TARGET_NETBSD_NR_compat_43_owait 84 | |
| 92 | +#define TARGET_NETBSD_NR_compat_12_oswapon 85 | |
| 93 | +#define TARGET_NETBSD_NR_getitimer 86 | |
| 94 | +#define TARGET_NETBSD_NR_compat_43_ogethostname 87 | |
| 95 | +#define TARGET_NETBSD_NR_compat_43_osethostname 88 | |
| 96 | +#define TARGET_NETBSD_NR_compat_43_ogetdtablesize 89 | |
| 97 | +#define TARGET_NETBSD_NR_dup2 90 | |
| 98 | +#define TARGET_NETBSD_NR_fcntl 92 | |
| 99 | +#define TARGET_NETBSD_NR_select 93 | |
| 100 | +#define TARGET_NETBSD_NR_fsync 95 | |
| 101 | +#define TARGET_NETBSD_NR_setpriority 96 | |
| 102 | +#define TARGET_NETBSD_NR_compat_30_socket 97 | |
| 103 | +#define TARGET_NETBSD_NR_connect 98 | |
| 104 | +#define TARGET_NETBSD_NR_compat_43_oaccept 99 | |
| 105 | +#define TARGET_NETBSD_NR_getpriority 100 | |
| 106 | +#define TARGET_NETBSD_NR_compat_43_osend 101 | |
| 107 | +#define TARGET_NETBSD_NR_compat_43_orecv 102 | |
| 108 | +#define TARGET_NETBSD_NR_compat_13_sigreturn13 103 | |
| 109 | +#define TARGET_NETBSD_NR_bind 104 | |
| 110 | +#define TARGET_NETBSD_NR_setsockopt 105 | |
| 111 | +#define TARGET_NETBSD_NR_listen 106 | |
| 112 | +#define TARGET_NETBSD_NR_compat_43_osigvec 108 | |
| 113 | +#define TARGET_NETBSD_NR_compat_43_osigblock 109 | |
| 114 | +#define TARGET_NETBSD_NR_compat_43_osigsetmask 110 | |
| 115 | +#define TARGET_NETBSD_NR_compat_13_sigsuspend13 111 | |
| 116 | +#define TARGET_NETBSD_NR_compat_43_osigstack 112 | |
| 117 | +#define TARGET_NETBSD_NR_compat_43_orecvmsg 113 | |
| 118 | +#define TARGET_NETBSD_NR_compat_43_osendmsg 114 | |
| 119 | +#define TARGET_NETBSD_NR_gettimeofday 116 | |
| 120 | +#define TARGET_NETBSD_NR_getrusage 117 | |
| 121 | +#define TARGET_NETBSD_NR_getsockopt 118 | |
| 122 | +#define TARGET_NETBSD_NR_readv 120 | |
| 123 | +#define TARGET_NETBSD_NR_writev 121 | |
| 124 | +#define TARGET_NETBSD_NR_settimeofday 122 | |
| 125 | +#define TARGET_NETBSD_NR_fchown 123 | |
| 126 | +#define TARGET_NETBSD_NR_fchmod 124 | |
| 127 | +#define TARGET_NETBSD_NR_compat_43_orecvfrom 125 | |
| 128 | +#define TARGET_NETBSD_NR_setreuid 126 | |
| 129 | +#define TARGET_NETBSD_NR_setregid 127 | |
| 130 | +#define TARGET_NETBSD_NR_rename 128 | |
| 131 | +#define TARGET_NETBSD_NR_compat_43_otruncate 129 | |
| 132 | +#define TARGET_NETBSD_NR_compat_43_oftruncate 130 | |
| 133 | +#define TARGET_NETBSD_NR_flock 131 | |
| 134 | +#define TARGET_NETBSD_NR_mkfifo 132 | |
| 135 | +#define TARGET_NETBSD_NR_sendto 133 | |
| 136 | +#define TARGET_NETBSD_NR_shutdown 134 | |
| 137 | +#define TARGET_NETBSD_NR_socketpair 135 | |
| 138 | +#define TARGET_NETBSD_NR_mkdir 136 | |
| 139 | +#define TARGET_NETBSD_NR_rmdir 137 | |
| 140 | +#define TARGET_NETBSD_NR_utimes 138 | |
| 141 | +#define TARGET_NETBSD_NR_adjtime 140 | |
| 142 | +#define TARGET_NETBSD_NR_compat_43_ogetpeername 141 | |
| 143 | +#define TARGET_NETBSD_NR_compat_43_ogethostid 142 | |
| 144 | +#define TARGET_NETBSD_NR_compat_43_osethostid 143 | |
| 145 | +#define TARGET_NETBSD_NR_compat_43_ogetrlimit 144 | |
| 146 | +#define TARGET_NETBSD_NR_compat_43_osetrlimit 145 | |
| 147 | +#define TARGET_NETBSD_NR_compat_43_okillpg 146 | |
| 148 | +#define TARGET_NETBSD_NR_setsid 147 | |
| 149 | +#define TARGET_NETBSD_NR_quotactl 148 | |
| 150 | +#define TARGET_NETBSD_NR_compat_43_oquota 149 | |
| 151 | +#define TARGET_NETBSD_NR_compat_43_ogetsockname 150 | |
| 152 | +#define TARGET_NETBSD_NR_nfssvc 155 | |
| 153 | +#define TARGET_NETBSD_NR_compat_43_ogetdirentries 156 | |
| 154 | +#define TARGET_NETBSD_NR_compat_20_statfs 157 | |
| 155 | +#define TARGET_NETBSD_NR_compat_20_fstatfs 158 | |
| 156 | +#define TARGET_NETBSD_NR_compat_30_getfh 161 | |
| 157 | +#define TARGET_NETBSD_NR_compat_09_ogetdomainname 162 | |
| 158 | +#define TARGET_NETBSD_NR_compat_09_osetdomainname 163 | |
| 159 | +#define TARGET_NETBSD_NR_compat_09_ouname 164 | |
| 160 | +#define TARGET_NETBSD_NR_sysarch 165 | |
| 161 | +#define TARGET_NETBSD_NR_compat_10_osemsys 169 | |
| 162 | +#define TARGET_NETBSD_NR_compat_10_omsgsys 170 | |
| 163 | +#define TARGET_NETBSD_NR_compat_10_oshmsys 171 | |
| 164 | +#define TARGET_NETBSD_NR_pread 173 | |
| 165 | +#define TARGET_NETBSD_NR_pwrite 174 | |
| 166 | +#define TARGET_NETBSD_NR_compat_30_ntp_gettime 175 | |
| 167 | +#define TARGET_NETBSD_NR_ntp_adjtime 176 | |
| 168 | +#define TARGET_NETBSD_NR_setgid 181 | |
| 169 | +#define TARGET_NETBSD_NR_setegid 182 | |
| 170 | +#define TARGET_NETBSD_NR_seteuid 183 | |
| 171 | +#define TARGET_NETBSD_NR_lfs_bmapv 184 | |
| 172 | +#define TARGET_NETBSD_NR_lfs_markv 185 | |
| 173 | +#define TARGET_NETBSD_NR_lfs_segclean 186 | |
| 174 | +#define TARGET_NETBSD_NR_lfs_segwait 187 | |
| 175 | +#define TARGET_NETBSD_NR_compat_12_stat12 188 | |
| 176 | +#define TARGET_NETBSD_NR_compat_12_fstat12 189 | |
| 177 | +#define TARGET_NETBSD_NR_compat_12_lstat12 190 | |
| 178 | +#define TARGET_NETBSD_NR_pathconf 191 | |
| 179 | +#define TARGET_NETBSD_NR_fpathconf 192 | |
| 180 | +#define TARGET_NETBSD_NR_getrlimit 194 | |
| 181 | +#define TARGET_NETBSD_NR_setrlimit 195 | |
| 182 | +#define TARGET_NETBSD_NR_compat_12_getdirentries 196 | |
| 183 | +#define TARGET_NETBSD_NR_mmap 197 | |
| 184 | +#define TARGET_NETBSD_NR___syscall 198 | |
| 185 | +#define TARGET_NETBSD_NR_lseek 199 | |
| 186 | +#define TARGET_NETBSD_NR_truncate 200 | |
| 187 | +#define TARGET_NETBSD_NR_ftruncate 201 | |
| 188 | +#define TARGET_NETBSD_NR___sysctl 202 | |
| 189 | +#define TARGET_NETBSD_NR_mlock 203 | |
| 190 | +#define TARGET_NETBSD_NR_munlock 204 | |
| 191 | +#define TARGET_NETBSD_NR_undelete 205 | |
| 192 | +#define TARGET_NETBSD_NR_futimes 206 | |
| 193 | +#define TARGET_NETBSD_NR_getpgid 207 | |
| 194 | +#define TARGET_NETBSD_NR_reboot 208 | |
| 195 | +#define TARGET_NETBSD_NR_poll 209 | |
| 196 | +#define TARGET_NETBSD_NR_compat_14___semctl 220 | |
| 197 | +#define TARGET_NETBSD_NR_semget 221 | |
| 198 | +#define TARGET_NETBSD_NR_semop 222 | |
| 199 | +#define TARGET_NETBSD_NR_semconfig 223 | |
| 200 | +#define TARGET_NETBSD_NR_compat_14_msgctl 224 | |
| 201 | +#define TARGET_NETBSD_NR_msgget 225 | |
| 202 | +#define TARGET_NETBSD_NR_msgsnd 226 | |
| 203 | +#define TARGET_NETBSD_NR_msgrcv 227 | |
| 204 | +#define TARGET_NETBSD_NR_shmat 228 | |
| 205 | +#define TARGET_NETBSD_NR_compat_14_shmctl 229 | |
| 206 | +#define TARGET_NETBSD_NR_shmdt 230 | |
| 207 | +#define TARGET_NETBSD_NR_shmget 231 | |
| 208 | +#define TARGET_NETBSD_NR_clock_gettime 232 | |
| 209 | +#define TARGET_NETBSD_NR_clock_settime 233 | |
| 210 | +#define TARGET_NETBSD_NR_clock_getres 234 | |
| 211 | +#define TARGET_NETBSD_NR_timer_create 235 | |
| 212 | +#define TARGET_NETBSD_NR_timer_delete 236 | |
| 213 | +#define TARGET_NETBSD_NR_timer_settime 237 | |
| 214 | +#define TARGET_NETBSD_NR_timer_gettime 238 | |
| 215 | +#define TARGET_NETBSD_NR_timer_getoverrun 239 | |
| 216 | +#define TARGET_NETBSD_NR_nanosleep 240 | |
| 217 | +#define TARGET_NETBSD_NR_fdatasync 241 | |
| 218 | +#define TARGET_NETBSD_NR_mlockall 242 | |
| 219 | +#define TARGET_NETBSD_NR_munlockall 243 | |
| 220 | +#define TARGET_NETBSD_NR___sigtimedwait 244 | |
| 221 | +#define TARGET_NETBSD_NR_modctl 246 | |
| 222 | +#define TARGET_NETBSD_NR__ksem_init 247 | |
| 223 | +#define TARGET_NETBSD_NR__ksem_open 248 | |
| 224 | +#define TARGET_NETBSD_NR__ksem_unlink 249 | |
| 225 | +#define TARGET_NETBSD_NR__ksem_close 250 | |
| 226 | +#define TARGET_NETBSD_NR__ksem_post 251 | |
| 227 | +#define TARGET_NETBSD_NR__ksem_wait 252 | |
| 228 | +#define TARGET_NETBSD_NR__ksem_trywait 253 | |
| 229 | +#define TARGET_NETBSD_NR__ksem_getvalue 254 | |
| 230 | +#define TARGET_NETBSD_NR__ksem_destroy 255 | |
| 231 | +#define TARGET_NETBSD_NR_mq_open 257 | |
| 232 | +#define TARGET_NETBSD_NR_mq_close 258 | |
| 233 | +#define TARGET_NETBSD_NR_mq_unlink 259 | |
| 234 | +#define TARGET_NETBSD_NR_mq_getattr 260 | |
| 235 | +#define TARGET_NETBSD_NR_mq_setattr 261 | |
| 236 | +#define TARGET_NETBSD_NR_mq_notify 262 | |
| 237 | +#define TARGET_NETBSD_NR_mq_send 263 | |
| 238 | +#define TARGET_NETBSD_NR_mq_receive 264 | |
| 239 | +#define TARGET_NETBSD_NR_mq_timedsend 265 | |
| 240 | +#define TARGET_NETBSD_NR_mq_timedreceive 266 | |
| 241 | +#define TARGET_NETBSD_NR___posix_rename 270 | |
| 242 | +#define TARGET_NETBSD_NR_swapctl 271 | |
| 243 | +#define TARGET_NETBSD_NR_compat_30_getdents 272 | |
| 244 | +#define TARGET_NETBSD_NR_minherit 273 | |
| 245 | +#define TARGET_NETBSD_NR_lchmod 274 | |
| 246 | +#define TARGET_NETBSD_NR_lchown 275 | |
| 247 | +#define TARGET_NETBSD_NR_lutimes 276 | |
| 248 | +#define TARGET_NETBSD_NR___msync13 277 | |
| 249 | +#define TARGET_NETBSD_NR_compat_30___stat13 278 | |
| 250 | +#define TARGET_NETBSD_NR_compat_30___fstat13 279 | |
| 251 | +#define TARGET_NETBSD_NR_compat_30___lstat13 280 | |
| 252 | +#define TARGET_NETBSD_NR___sigaltstack14 281 | |
| 253 | +#define TARGET_NETBSD_NR___vfork14 282 | |
| 254 | +#define TARGET_NETBSD_NR___posix_chown 283 | |
| 255 | +#define TARGET_NETBSD_NR___posix_fchown 284 | |
| 256 | +#define TARGET_NETBSD_NR___posix_lchown 285 | |
| 257 | +#define TARGET_NETBSD_NR_getsid 286 | |
| 258 | +#define TARGET_NETBSD_NR___clone 287 | |
| 259 | +#define TARGET_NETBSD_NR_fktrace 288 | |
| 260 | +#define TARGET_NETBSD_NR_preadv 289 | |
| 261 | +#define TARGET_NETBSD_NR_pwritev 290 | |
| 262 | +#define TARGET_NETBSD_NR_compat_16___sigaction14 291 | |
| 263 | +#define TARGET_NETBSD_NR___sigpending14 292 | |
| 264 | +#define TARGET_NETBSD_NR___sigprocmask14 293 | |
| 265 | +#define TARGET_NETBSD_NR___sigsuspend14 294 | |
| 266 | +#define TARGET_NETBSD_NR_compat_16___sigreturn14 295 | |
| 267 | +#define TARGET_NETBSD_NR___getcwd 296 | |
| 268 | +#define TARGET_NETBSD_NR_fchroot 297 | |
| 269 | +#define TARGET_NETBSD_NR_compat_30_fhopen 298 | |
| 270 | +#define TARGET_NETBSD_NR_compat_30_fhstat 299 | |
| 271 | +#define TARGET_NETBSD_NR_compat_20_fhstatfs 300 | |
| 272 | +#define TARGET_NETBSD_NR_____semctl13 301 | |
| 273 | +#define TARGET_NETBSD_NR___msgctl13 302 | |
| 274 | +#define TARGET_NETBSD_NR___shmctl13 303 | |
| 275 | +#define TARGET_NETBSD_NR_lchflags 304 | |
| 276 | +#define TARGET_NETBSD_NR_issetugid 305 | |
| 277 | +#define TARGET_NETBSD_NR_utrace 306 | |
| 278 | +#define TARGET_NETBSD_NR_getcontext 307 | |
| 279 | +#define TARGET_NETBSD_NR_setcontext 308 | |
| 280 | +#define TARGET_NETBSD_NR__lwp_create 309 | |
| 281 | +#define TARGET_NETBSD_NR__lwp_exit 310 | |
| 282 | +#define TARGET_NETBSD_NR__lwp_self 311 | |
| 283 | +#define TARGET_NETBSD_NR__lwp_wait 312 | |
| 284 | +#define TARGET_NETBSD_NR__lwp_suspend 313 | |
| 285 | +#define TARGET_NETBSD_NR__lwp_continue 314 | |
| 286 | +#define TARGET_NETBSD_NR__lwp_wakeup 315 | |
| 287 | +#define TARGET_NETBSD_NR__lwp_getprivate 316 | |
| 288 | +#define TARGET_NETBSD_NR__lwp_setprivate 317 | |
| 289 | +#define TARGET_NETBSD_NR__lwp_kill 318 | |
| 290 | +#define TARGET_NETBSD_NR__lwp_detach 319 | |
| 291 | +#define TARGET_NETBSD_NR__lwp_park 320 | |
| 292 | +#define TARGET_NETBSD_NR__lwp_unpark 321 | |
| 293 | +#define TARGET_NETBSD_NR__lwp_unpark_all 322 | |
| 294 | +#define TARGET_NETBSD_NR__lwp_setname 323 | |
| 295 | +#define TARGET_NETBSD_NR__lwp_getname 324 | |
| 296 | +#define TARGET_NETBSD_NR__lwp_ctl 325 | |
| 297 | +#define TARGET_NETBSD_NR_sa_register 330 | |
| 298 | +#define TARGET_NETBSD_NR_sa_stacks 331 | |
| 299 | +#define TARGET_NETBSD_NR_sa_enable 332 | |
| 300 | +#define TARGET_NETBSD_NR_sa_setconcurrency 333 | |
| 301 | +#define TARGET_NETBSD_NR_sa_yield 334 | |
| 302 | +#define TARGET_NETBSD_NR_sa_preempt 335 | |
| 303 | +#define TARGET_NETBSD_NR_sa_unblockyield 336 | |
| 304 | +#define TARGET_NETBSD_NR___sigaction_sigtramp 340 | |
| 305 | +#define TARGET_NETBSD_NR_pmc_get_info 341 | |
| 306 | +#define TARGET_NETBSD_NR_pmc_control 342 | |
| 307 | +#define TARGET_NETBSD_NR_rasctl 343 | |
| 308 | +#define TARGET_NETBSD_NR_kqueue 344 | |
| 309 | +#define TARGET_NETBSD_NR_kevent 345 | |
| 310 | +#define TARGET_NETBSD_NR__sched_setparam 346 | |
| 311 | +#define TARGET_NETBSD_NR__sched_getparam 347 | |
| 312 | +#define TARGET_NETBSD_NR__sched_setaffinity 348 | |
| 313 | +#define TARGET_NETBSD_NR__sched_getaffinity 349 | |
| 314 | +#define TARGET_NETBSD_NR_sched_yield 350 | |
| 315 | +#define TARGET_NETBSD_NR_fsync_range 354 | |
| 316 | +#define TARGET_NETBSD_NR_uuidgen 355 | |
| 317 | +#define TARGET_NETBSD_NR_getvfsstat 356 | |
| 318 | +#define TARGET_NETBSD_NR_statvfs1 357 | |
| 319 | +#define TARGET_NETBSD_NR_fstatvfs1 358 | |
| 320 | +#define TARGET_NETBSD_NR_compat_30_fhstatvfs1 359 | |
| 321 | +#define TARGET_NETBSD_NR_extattrctl 360 | |
| 322 | +#define TARGET_NETBSD_NR_extattr_set_file 361 | |
| 323 | +#define TARGET_NETBSD_NR_extattr_get_file 362 | |
| 324 | +#define TARGET_NETBSD_NR_extattr_delete_file 363 | |
| 325 | +#define TARGET_NETBSD_NR_extattr_set_fd 364 | |
| 326 | +#define TARGET_NETBSD_NR_extattr_get_fd 365 | |
| 327 | +#define TARGET_NETBSD_NR_extattr_delete_fd 366 | |
| 328 | +#define TARGET_NETBSD_NR_extattr_set_link 367 | |
| 329 | +#define TARGET_NETBSD_NR_extattr_get_link 368 | |
| 330 | +#define TARGET_NETBSD_NR_extattr_delete_link 369 | |
| 331 | +#define TARGET_NETBSD_NR_extattr_list_fd 370 | |
| 332 | +#define TARGET_NETBSD_NR_extattr_list_file 371 | |
| 333 | +#define TARGET_NETBSD_NR_extattr_list_link 372 | |
| 334 | +#define TARGET_NETBSD_NR_pselect 373 | |
| 335 | +#define TARGET_NETBSD_NR_pollts 374 | |
| 336 | +#define TARGET_NETBSD_NR_setxattr 375 | |
| 337 | +#define TARGET_NETBSD_NR_lsetxattr 376 | |
| 338 | +#define TARGET_NETBSD_NR_fsetxattr 377 | |
| 339 | +#define TARGET_NETBSD_NR_getxattr 378 | |
| 340 | +#define TARGET_NETBSD_NR_lgetxattr 379 | |
| 341 | +#define TARGET_NETBSD_NR_fgetxattr 380 | |
| 342 | +#define TARGET_NETBSD_NR_listxattr 381 | |
| 343 | +#define TARGET_NETBSD_NR_llistxattr 382 | |
| 344 | +#define TARGET_NETBSD_NR_flistxattr 383 | |
| 345 | +#define TARGET_NETBSD_NR_removexattr 384 | |
| 346 | +#define TARGET_NETBSD_NR_lremovexattr 385 | |
| 347 | +#define TARGET_NETBSD_NR_fremovexattr 386 | |
| 348 | +#define TARGET_NETBSD_NR___stat30 387 | |
| 349 | +#define TARGET_NETBSD_NR___fstat30 388 | |
| 350 | +#define TARGET_NETBSD_NR___lstat30 389 | |
| 351 | +#define TARGET_NETBSD_NR___getdents30 390 | |
| 352 | +#define TARGET_NETBSD_NR_compat_30___fhstat30 392 | |
| 353 | +#define TARGET_NETBSD_NR___ntp_gettime30 393 | |
| 354 | +#define TARGET_NETBSD_NR___socket30 394 | |
| 355 | +#define TARGET_NETBSD_NR___getfh30 395 | |
| 356 | +#define TARGET_NETBSD_NR___fhopen40 396 | |
| 357 | +#define TARGET_NETBSD_NR___fhstatvfs140 397 | |
| 358 | +#define TARGET_NETBSD_NR___fhstat40 398 | |
| 359 | +#define TARGET_NETBSD_NR_aio_cancel 399 | |
| 360 | +#define TARGET_NETBSD_NR_aio_error 400 | |
| 361 | +#define TARGET_NETBSD_NR_aio_fsync 401 | |
| 362 | +#define TARGET_NETBSD_NR_aio_read 402 | |
| 363 | +#define TARGET_NETBSD_NR_aio_return 403 | |
| 364 | +#define TARGET_NETBSD_NR_aio_suspend 404 | |
| 365 | +#define TARGET_NETBSD_NR_aio_write 405 | |
| 366 | +#define TARGET_NETBSD_NR_lio_listio 406 | |
| 367 | +#define TARGET_NETBSD_NR___mount50 410 | |
| 368 | +#define TARGET_NETBSD_NR_mremap 411 | |
| 369 | +#define TARGET_NETBSD_NR_pset_create 412 | |
| 370 | +#define TARGET_NETBSD_NR_pset_destroy 413 | |
| 371 | +#define TARGET_NETBSD_NR_pset_assign 414 | |
| 372 | +#define TARGET_NETBSD_NR__pset_bind 415 | |
| 373 | +#define TARGET_NETBSD_NR___posix_fadvise50 416 | ... | ... |
bsd-user/openbsd/strace.list
0 โ 100644
| 1 | +{ TARGET_OPENBSD_NR___getcwd, "__getcwd", NULL, NULL, NULL }, | |
| 2 | +{ TARGET_OPENBSD_NR___semctl, "__semctl", NULL, NULL, NULL }, | |
| 3 | +{ TARGET_OPENBSD_NR___syscall, "__syscall", NULL, NULL, NULL }, | |
| 4 | +{ TARGET_OPENBSD_NR___sysctl, "__sysctl", NULL, NULL, NULL }, | |
| 5 | +{ TARGET_OPENBSD_NR_accept, "accept", "%s(%d,%#x,%#x)", NULL, NULL }, | |
| 6 | +{ TARGET_OPENBSD_NR_access, "access", "%s(\"%s\",%#o)", NULL, NULL }, | |
| 7 | +{ TARGET_OPENBSD_NR_acct, "acct", NULL, NULL, NULL }, | |
| 8 | +{ TARGET_OPENBSD_NR_adjfreq, "adjfreq", NULL, NULL, NULL }, | |
| 9 | +{ TARGET_OPENBSD_NR_adjtime, "adjtime", NULL, NULL, NULL }, | |
| 10 | +{ TARGET_OPENBSD_NR_bind, "bind", NULL, NULL, NULL }, | |
| 11 | +{ TARGET_OPENBSD_NR_break, "break", NULL, NULL, NULL }, | |
| 12 | +{ TARGET_OPENBSD_NR_chdir, "chdir", "%s(\"%s\")", NULL, NULL }, | |
| 13 | +{ TARGET_OPENBSD_NR_chflags, "chflags", NULL, NULL, NULL }, | |
| 14 | +{ TARGET_OPENBSD_NR_chmod, "chmod", "%s(\"%s\",%#o)", NULL, NULL }, | |
| 15 | +{ TARGET_OPENBSD_NR_chown, "chown", NULL, NULL, NULL }, | |
| 16 | +{ TARGET_OPENBSD_NR_chroot, "chroot", NULL, NULL, NULL }, | |
| 17 | +{ TARGET_OPENBSD_NR_clock_getres, "clock_getres", NULL, NULL, NULL }, | |
| 18 | +{ TARGET_OPENBSD_NR_clock_gettime, "clock_gettime", NULL, NULL, NULL }, | |
| 19 | +{ TARGET_OPENBSD_NR_clock_settime, "clock_settime", NULL, NULL, NULL }, | |
| 20 | +{ TARGET_OPENBSD_NR_close, "close", "%s(%d)", NULL, NULL }, | |
| 21 | +{ TARGET_OPENBSD_NR_closefrom, "closefrom", NULL, NULL, NULL }, | |
| 22 | +{ TARGET_OPENBSD_NR_connect, "connect", "%s(%d,%#x,%d)", NULL, NULL }, | |
| 23 | +{ TARGET_OPENBSD_NR_dup, "dup", NULL, NULL, NULL }, | |
| 24 | +{ TARGET_OPENBSD_NR_dup2, "dup2", NULL, NULL, NULL }, | |
| 25 | +{ TARGET_OPENBSD_NR_execve, "execve", NULL, print_execve, NULL }, | |
| 26 | +{ TARGET_OPENBSD_NR_exit, "exit", "%s(%d)\n", NULL, NULL }, | |
| 27 | +{ TARGET_OPENBSD_NR_fchdir, "fchdir", NULL, NULL, NULL }, | |
| 28 | +{ TARGET_OPENBSD_NR_fchflags, "fchflags", NULL, NULL, NULL }, | |
| 29 | +{ TARGET_OPENBSD_NR_fchmod, "fchmod", "%s(%d,%#o)", NULL, NULL }, | |
| 30 | +{ TARGET_OPENBSD_NR_fchown, "fchown", "%s(\"%s\",%d,%d)", NULL, NULL }, | |
| 31 | +{ TARGET_OPENBSD_NR_fcntl, "fcntl", NULL, NULL, NULL }, | |
| 32 | +{ TARGET_OPENBSD_NR_fhopen, "fhopen", NULL, NULL, NULL }, | |
| 33 | +{ TARGET_OPENBSD_NR_fhstat, "fhstat", NULL, NULL, NULL }, | |
| 34 | +{ TARGET_OPENBSD_NR_fhstatfs, "fhstatfs", NULL, NULL, NULL }, | |
| 35 | +{ TARGET_OPENBSD_NR_flock, "flock", NULL, NULL, NULL }, | |
| 36 | +{ TARGET_OPENBSD_NR_fork, "fork", "%s()", NULL, NULL }, | |
| 37 | +{ TARGET_OPENBSD_NR_fpathconf, "fpathconf", NULL, NULL, NULL }, | |
| 38 | +{ TARGET_OPENBSD_NR_fstat, "fstat", "%s(%d,%p)", NULL, NULL }, | |
| 39 | +{ TARGET_OPENBSD_NR_fstatfs, "fstatfs", "%s(%d,%p)", NULL, NULL }, | |
| 40 | +{ TARGET_OPENBSD_NR_fsync, "fsync", NULL, NULL, NULL }, | |
| 41 | +{ TARGET_OPENBSD_NR_ftruncate, "ftruncate", NULL, NULL, NULL }, | |
| 42 | +{ TARGET_OPENBSD_NR_futimes, "futimes", NULL, NULL, NULL }, | |
| 43 | +{ TARGET_OPENBSD_NR_getdirentries, "getdirentries", NULL, NULL, NULL }, | |
| 44 | +{ TARGET_OPENBSD_NR_getegid, "getegid", "%s()", NULL, NULL }, | |
| 45 | +{ TARGET_OPENBSD_NR_geteuid, "geteuid", "%s()", NULL, NULL }, | |
| 46 | +{ TARGET_OPENBSD_NR_getfh, "getfh", NULL, NULL, NULL }, | |
| 47 | +{ TARGET_OPENBSD_NR_getfsstat, "getfsstat", NULL, NULL, NULL }, | |
| 48 | +{ TARGET_OPENBSD_NR_getgid, "getgid", "%s()", NULL, NULL }, | |
| 49 | +{ TARGET_OPENBSD_NR_getgroups, "getgroups", NULL, NULL, NULL }, | |
| 50 | +{ TARGET_OPENBSD_NR_getitimer, "getitimer", NULL, NULL, NULL }, | |
| 51 | +{ TARGET_OPENBSD_NR_getlogin, "getlogin", NULL, NULL, NULL }, | |
| 52 | +{ TARGET_OPENBSD_NR_getpeereid, "getpeereid", NULL, NULL, NULL }, | |
| 53 | +{ TARGET_OPENBSD_NR_getpeername, "getpeername", NULL, NULL, NULL }, | |
| 54 | +{ TARGET_OPENBSD_NR_getpgid, "getpgid", NULL, NULL, NULL }, | |
| 55 | +{ TARGET_OPENBSD_NR_getpgrp, "getpgrp", "%s()", NULL, NULL }, | |
| 56 | +{ TARGET_OPENBSD_NR_getpid, "getpid", "%s()", NULL, NULL }, | |
| 57 | +{ TARGET_OPENBSD_NR_getppid, "getppid", "%s()", NULL, NULL }, | |
| 58 | +{ TARGET_OPENBSD_NR_getpriority, "getpriority", "%s(%#x,%#x)", NULL, NULL }, | |
| 59 | +{ TARGET_OPENBSD_NR_getresgid, "getresgid", NULL, NULL, NULL }, | |
| 60 | +{ TARGET_OPENBSD_NR_getresuid, "getresuid", NULL, NULL, NULL }, | |
| 61 | +{ TARGET_OPENBSD_NR_getrlimit, "getrlimit", NULL, NULL, NULL }, | |
| 62 | +{ TARGET_OPENBSD_NR_getrusage, "getrusage", NULL, NULL, NULL }, | |
| 63 | +{ TARGET_OPENBSD_NR_getsid, "getsid", NULL, NULL, NULL }, | |
| 64 | +{ TARGET_OPENBSD_NR_getsockname, "getsockname", NULL, NULL, NULL }, | |
| 65 | +{ TARGET_OPENBSD_NR_getsockopt, "getsockopt", NULL, NULL, NULL }, | |
| 66 | +{ TARGET_OPENBSD_NR_getthrid, "getthrid", NULL, NULL, NULL }, | |
| 67 | +{ TARGET_OPENBSD_NR_gettimeofday, "gettimeofday", NULL, NULL, NULL }, | |
| 68 | +{ TARGET_OPENBSD_NR_getuid, "getuid", "%s()", NULL, NULL }, | |
| 69 | +{ TARGET_OPENBSD_NR_ioctl, "ioctl", NULL, NULL, NULL }, | |
| 70 | +{ TARGET_OPENBSD_NR_issetugid, "issetugid", "%s()", NULL, NULL }, | |
| 71 | +{ TARGET_OPENBSD_NR_kevent, "kevent", NULL, NULL, NULL }, | |
| 72 | +{ TARGET_OPENBSD_NR_kill, "kill", NULL, NULL, NULL }, | |
| 73 | +{ TARGET_OPENBSD_NR_kqueue, "kqueue", NULL, NULL, NULL }, | |
| 74 | +{ TARGET_OPENBSD_NR_ktrace, "ktrace", NULL, NULL, NULL }, | |
| 75 | +{ TARGET_OPENBSD_NR_lchown, "lchown", NULL, NULL, NULL }, | |
| 76 | +{ TARGET_OPENBSD_NR_lfs_bmapv, "lfs_bmapv", NULL, NULL, NULL }, | |
| 77 | +{ TARGET_OPENBSD_NR_lfs_markv, "lfs_markv", NULL, NULL, NULL }, | |
| 78 | +{ TARGET_OPENBSD_NR_lfs_segclean, "lfs_segclean", NULL, NULL, NULL }, | |
| 79 | +{ TARGET_OPENBSD_NR_lfs_segwait, "lfs_segwait", NULL, NULL, NULL }, | |
| 80 | +{ TARGET_OPENBSD_NR_link, "link", "%s(\"%s\",\"%s\")", NULL, NULL }, | |
| 81 | +{ TARGET_OPENBSD_NR_listen, "listen", NULL, NULL, NULL }, | |
| 82 | +{ TARGET_OPENBSD_NR_lseek, "lseek", NULL, NULL, NULL }, | |
| 83 | +{ TARGET_OPENBSD_NR_lstat, "lstat", "%s(\"%s\",%p)", NULL, NULL }, | |
| 84 | +{ TARGET_OPENBSD_NR_madvise, "madvise", NULL, NULL, NULL }, | |
| 85 | +{ TARGET_OPENBSD_NR_mincore, "mincore", NULL, NULL, NULL }, | |
| 86 | +{ TARGET_OPENBSD_NR_minherit, "minherit", NULL, NULL, NULL }, | |
| 87 | +{ TARGET_OPENBSD_NR_mkdir, "mkdir", "%s(\"%s\",%#o)", NULL, NULL }, | |
| 88 | +{ TARGET_OPENBSD_NR_mkfifo, "mkfifo", NULL, NULL, NULL }, | |
| 89 | +{ TARGET_OPENBSD_NR_mknod, "mknod", "%s(\"%s\",%#o,%#x)", NULL, NULL }, | |
| 90 | +{ TARGET_OPENBSD_NR_mlock, "mlock", NULL, NULL, NULL }, | |
| 91 | +{ TARGET_OPENBSD_NR_mlockall, "mlockall", NULL, NULL, NULL }, | |
| 92 | +{ TARGET_OPENBSD_NR_mmap, "mmap", NULL, NULL, print_syscall_ret_addr }, | |
| 93 | +{ TARGET_OPENBSD_NR_mount, "mount", NULL, NULL, NULL }, | |
| 94 | +{ TARGET_OPENBSD_NR_mprotect, "mprotect", "%s(%#x,%#x,%d)", NULL, NULL }, | |
| 95 | +{ TARGET_OPENBSD_NR_mquery, "mquery", NULL, NULL, NULL }, | |
| 96 | +{ TARGET_OPENBSD_NR_msgctl, "msgctl", NULL, NULL, NULL }, | |
| 97 | +{ TARGET_OPENBSD_NR_msgget, "msgget", NULL, NULL, NULL }, | |
| 98 | +{ TARGET_OPENBSD_NR_msgrcv, "msgrcv", NULL, NULL, NULL }, | |
| 99 | +{ TARGET_OPENBSD_NR_msgsnd, "msgsnd", NULL, NULL, NULL }, | |
| 100 | +{ TARGET_OPENBSD_NR_msync, "msync", NULL, NULL, NULL }, | |
| 101 | +{ TARGET_OPENBSD_NR_munlock, "munlock", NULL, NULL, NULL }, | |
| 102 | +{ TARGET_OPENBSD_NR_munlockall, "munlockall", NULL, NULL, NULL }, | |
| 103 | +{ TARGET_OPENBSD_NR_munmap, "munmap", "%s(%p,%d)", NULL, NULL }, | |
| 104 | +{ TARGET_OPENBSD_NR_nanosleep, "nanosleep", NULL, NULL, NULL }, | |
| 105 | +{ TARGET_OPENBSD_NR_nfssvc, "nfssvc", NULL, NULL, NULL }, | |
| 106 | +{ TARGET_OPENBSD_NR_open, "open", "%s(\"%s\",%#x,%#o)", NULL, NULL }, | |
| 107 | +{ TARGET_OPENBSD_NR_opipe, "opipe", NULL, NULL, NULL }, | |
| 108 | +{ TARGET_OPENBSD_NR_osigaltstack, "osigaltstack", NULL, NULL, NULL }, | |
| 109 | +{ TARGET_OPENBSD_NR_pathconf, "pathconf", NULL, NULL, NULL }, | |
| 110 | +{ TARGET_OPENBSD_NR_pipe, "pipe", NULL, NULL, NULL }, | |
| 111 | +{ TARGET_OPENBSD_NR_poll, "poll", NULL, NULL, NULL }, | |
| 112 | +{ TARGET_OPENBSD_NR_pread, "pread", NULL, NULL, NULL }, | |
| 113 | +{ TARGET_OPENBSD_NR_preadv, "preadv", NULL, NULL, NULL }, | |
| 114 | +{ TARGET_OPENBSD_NR_profil, "profil", NULL, NULL, NULL }, | |
| 115 | +{ TARGET_OPENBSD_NR_ptrace, "ptrace", NULL, NULL, NULL }, | |
| 116 | +{ TARGET_OPENBSD_NR_pwrite, "pwrite", NULL, NULL, NULL }, | |
| 117 | +{ TARGET_OPENBSD_NR_pwritev, "pwritev", NULL, NULL, NULL }, | |
| 118 | +{ TARGET_OPENBSD_NR_quotactl, "quotactl", NULL, NULL, NULL }, | |
| 119 | +{ TARGET_OPENBSD_NR_read, "read", "%s(%d,%#x,%d)", NULL, NULL }, | |
| 120 | +{ TARGET_OPENBSD_NR_readlink, "readlink", "%s(\"%s\",%p,%d)", NULL, NULL }, | |
| 121 | +{ TARGET_OPENBSD_NR_readv, "readv", NULL, NULL, NULL }, | |
| 122 | +{ TARGET_OPENBSD_NR_reboot, "reboot", NULL, NULL, NULL }, | |
| 123 | +{ TARGET_OPENBSD_NR_recvfrom, "recvfrom", NULL, NULL, NULL }, | |
| 124 | +{ TARGET_OPENBSD_NR_recvmsg, "recvmsg", NULL, NULL, NULL }, | |
| 125 | +{ TARGET_OPENBSD_NR_rename, "rename", "%s(\"%s\",\"%s\")", NULL, NULL }, | |
| 126 | +{ TARGET_OPENBSD_NR_revoke, "revoke", NULL, NULL, NULL }, | |
| 127 | +{ TARGET_OPENBSD_NR_rfork, "rfork", NULL, NULL, NULL }, | |
| 128 | +{ TARGET_OPENBSD_NR_rmdir, "rmdir", NULL, NULL, NULL }, | |
| 129 | +{ TARGET_OPENBSD_NR_sbrk, "sbrk", NULL, NULL, NULL }, | |
| 130 | +{ TARGET_OPENBSD_NR_sched_yield, "sched_yield", NULL, NULL, NULL }, | |
| 131 | +{ TARGET_OPENBSD_NR_select, "select", NULL, NULL, NULL }, | |
| 132 | +{ TARGET_OPENBSD_NR_semget, "semget", NULL, NULL, NULL }, | |
| 133 | +{ TARGET_OPENBSD_NR_semop, "semop", NULL, NULL, NULL }, | |
| 134 | +{ TARGET_OPENBSD_NR_sendmsg, "sendmsg", NULL, NULL, NULL }, | |
| 135 | +{ TARGET_OPENBSD_NR_sendto, "sendto", NULL, NULL, NULL }, | |
| 136 | +{ TARGET_OPENBSD_NR_setegid, "setegid", NULL, NULL, NULL }, | |
| 137 | +{ TARGET_OPENBSD_NR_seteuid, "seteuid", NULL, NULL, NULL }, | |
| 138 | +{ TARGET_OPENBSD_NR_setgid, "setgid", NULL, NULL, NULL }, | |
| 139 | +{ TARGET_OPENBSD_NR_setgroups, "setgroups", NULL, NULL, NULL }, | |
| 140 | +{ TARGET_OPENBSD_NR_setitimer, "setitimer", NULL, NULL, NULL }, | |
| 141 | +{ TARGET_OPENBSD_NR_setlogin, "setlogin", NULL, NULL, NULL }, | |
| 142 | +{ TARGET_OPENBSD_NR_setpgid, "setpgid", NULL, NULL, NULL }, | |
| 143 | +{ TARGET_OPENBSD_NR_setpriority, "setpriority", NULL, NULL, NULL }, | |
| 144 | +{ TARGET_OPENBSD_NR_setregid, "setregid", NULL, NULL, NULL }, | |
| 145 | +{ TARGET_OPENBSD_NR_setresgid, "setresgid", NULL, NULL, NULL }, | |
| 146 | +{ TARGET_OPENBSD_NR_setresuid, "setresuid", NULL, NULL, NULL }, | |
| 147 | +{ TARGET_OPENBSD_NR_setreuid, "setreuid", NULL, NULL, NULL }, | |
| 148 | +{ TARGET_OPENBSD_NR_setrlimit, "setrlimit", NULL, NULL, NULL }, | |
| 149 | +{ TARGET_OPENBSD_NR_setsid, "setsid", NULL, NULL, NULL }, | |
| 150 | +{ TARGET_OPENBSD_NR_setsockopt, "setsockopt", NULL, NULL, NULL }, | |
| 151 | +{ TARGET_OPENBSD_NR_settimeofday, "settimeofday", NULL, NULL, NULL }, | |
| 152 | +{ TARGET_OPENBSD_NR_setuid, "setuid", NULL, NULL, NULL }, | |
| 153 | +{ TARGET_OPENBSD_NR_shmat, "shmat", NULL, NULL, NULL }, | |
| 154 | +{ TARGET_OPENBSD_NR_shmctl, "shmctl", NULL, NULL, NULL }, | |
| 155 | +{ TARGET_OPENBSD_NR_shmdt, "shmdt", NULL, NULL, NULL }, | |
| 156 | +{ TARGET_OPENBSD_NR_shmget, "shmget", NULL, NULL, NULL }, | |
| 157 | +{ TARGET_OPENBSD_NR_shutdown, "shutdown", NULL, NULL, NULL }, | |
| 158 | +{ TARGET_OPENBSD_NR_sigaction, "sigaction", NULL, NULL, NULL }, | |
| 159 | +{ TARGET_OPENBSD_NR_sigaltstack, "sigaltstack", "%s(%p,%p)", NULL, NULL }, | |
| 160 | +{ TARGET_OPENBSD_NR_sigpending, "sigpending", NULL, NULL, NULL }, | |
| 161 | +{ TARGET_OPENBSD_NR_sigprocmask, "sigprocmask", NULL, NULL, NULL }, | |
| 162 | +{ TARGET_OPENBSD_NR_sigreturn, "sigreturn", NULL, NULL, NULL }, | |
| 163 | +{ TARGET_OPENBSD_NR_sigsuspend, "sigsuspend", NULL, NULL, NULL }, | |
| 164 | +{ TARGET_OPENBSD_NR_socket, "socket", NULL, NULL, NULL }, | |
| 165 | +{ TARGET_OPENBSD_NR_socketpair, "socketpair", NULL, NULL, NULL }, | |
| 166 | +{ TARGET_OPENBSD_NR_sstk, "sstk", NULL, NULL, NULL }, | |
| 167 | +{ TARGET_OPENBSD_NR_stat, "stat", "%s(\"%s\",%p)", NULL, NULL }, | |
| 168 | +{ TARGET_OPENBSD_NR_statfs, "statfs", "%s(\"%s\",%p)", NULL, NULL }, | |
| 169 | +{ TARGET_OPENBSD_NR_swapctl, "swapctl", NULL, NULL, NULL }, | |
| 170 | +{ TARGET_OPENBSD_NR_symlink, "symlink", "%s(\"%s\",\"%s\")", NULL, NULL }, | |
| 171 | +{ TARGET_OPENBSD_NR_sync, "sync", NULL, NULL, NULL }, | |
| 172 | +{ TARGET_OPENBSD_NR_sysarch, "sysarch", NULL, NULL, NULL }, | |
| 173 | +{ TARGET_OPENBSD_NR_syscall, "syscall", NULL, NULL, NULL }, | |
| 174 | +{ TARGET_OPENBSD_NR_threxit, "threxit", NULL, NULL, NULL }, | |
| 175 | +{ TARGET_OPENBSD_NR_thrsigdivert, "thrsigdivert", NULL, NULL, NULL }, | |
| 176 | +{ TARGET_OPENBSD_NR_thrsleep, "thrsleep", NULL, NULL, NULL }, | |
| 177 | +{ TARGET_OPENBSD_NR_thrwakeup, "thrwakeup", NULL, NULL, NULL }, | |
| 178 | +{ TARGET_OPENBSD_NR_truncate, "truncate", NULL, NULL, NULL }, | |
| 179 | +{ TARGET_OPENBSD_NR_umask, "umask", "%s(%#o)", NULL, NULL }, | |
| 180 | +{ TARGET_OPENBSD_NR_unlink, "unlink", "%s(\"%s\")", NULL, NULL }, | |
| 181 | +{ TARGET_OPENBSD_NR_unmount, "unmount", NULL, NULL, NULL }, | |
| 182 | +{ TARGET_OPENBSD_NR_utimes, "utimes", NULL, NULL, NULL }, | |
| 183 | +{ TARGET_OPENBSD_NR_vfork, "vfork", NULL, NULL, NULL }, | |
| 184 | +{ TARGET_OPENBSD_NR_wait4, "wait4", NULL, NULL, NULL }, | |
| 185 | +{ TARGET_OPENBSD_NR_write, "write", "%s(%d,%#x,%d)", NULL, NULL }, | |
| 186 | +{ TARGET_OPENBSD_NR_writev, "writev", "%s(%d,%p,%#x)", NULL, NULL }, | |
| 187 | +{ TARGET_OPENBSD_NR_xfspioctl, "xfspioctl", NULL, NULL, NULL }, | ... | ... |
bsd-user/openbsd/syscall_nr.h
0 โ 100644
| 1 | +/* $OpenBSD: syscall.h,v 1.101 2008/03/16 19:43:41 otto Exp $ */ | |
| 2 | + | |
| 3 | +/* | |
| 4 | + * System call numbers. | |
| 5 | + * | |
| 6 | + * created from; OpenBSD: syscalls.master,v 1.90 2008/03/16 19:42:57 otto Exp | |
| 7 | + */ | |
| 8 | + | |
| 9 | +#define TARGET_OPENBSD_NR_syscall 0 | |
| 10 | +#define TARGET_OPENBSD_NR_exit 1 | |
| 11 | +#define TARGET_OPENBSD_NR_fork 2 | |
| 12 | +#define TARGET_OPENBSD_NR_read 3 | |
| 13 | +#define TARGET_OPENBSD_NR_write 4 | |
| 14 | +#define TARGET_OPENBSD_NR_open 5 | |
| 15 | +#define TARGET_OPENBSD_NR_close 6 | |
| 16 | +#define TARGET_OPENBSD_NR_wait4 7 | |
| 17 | +#define TARGET_OPENBSD_NR_link 9 | |
| 18 | +#define TARGET_OPENBSD_NR_unlink 10 | |
| 19 | +#define TARGET_OPENBSD_NR_chdir 12 | |
| 20 | +#define TARGET_OPENBSD_NR_fchdir 13 | |
| 21 | +#define TARGET_OPENBSD_NR_mknod 14 | |
| 22 | +#define TARGET_OPENBSD_NR_chmod 15 | |
| 23 | +#define TARGET_OPENBSD_NR_chown 16 | |
| 24 | +#define TARGET_OPENBSD_NR_break 17 | |
| 25 | +#define TARGET_OPENBSD_NR_getpid 20 | |
| 26 | +#define TARGET_OPENBSD_NR_mount 21 | |
| 27 | +#define TARGET_OPENBSD_NR_unmount 22 | |
| 28 | +#define TARGET_OPENBSD_NR_setuid 23 | |
| 29 | +#define TARGET_OPENBSD_NR_getuid 24 | |
| 30 | +#define TARGET_OPENBSD_NR_geteuid 25 | |
| 31 | +#define TARGET_OPENBSD_NR_ptrace 26 | |
| 32 | +#define TARGET_OPENBSD_NR_recvmsg 27 | |
| 33 | +#define TARGET_OPENBSD_NR_sendmsg 28 | |
| 34 | +#define TARGET_OPENBSD_NR_recvfrom 29 | |
| 35 | +#define TARGET_OPENBSD_NR_accept 30 | |
| 36 | +#define TARGET_OPENBSD_NR_getpeername 31 | |
| 37 | +#define TARGET_OPENBSD_NR_getsockname 32 | |
| 38 | +#define TARGET_OPENBSD_NR_access 33 | |
| 39 | +#define TARGET_OPENBSD_NR_chflags 34 | |
| 40 | +#define TARGET_OPENBSD_NR_fchflags 35 | |
| 41 | +#define TARGET_OPENBSD_NR_sync 36 | |
| 42 | +#define TARGET_OPENBSD_NR_kill 37 | |
| 43 | +#define TARGET_OPENBSD_NR_getppid 39 | |
| 44 | +#define TARGET_OPENBSD_NR_dup 41 | |
| 45 | +#define TARGET_OPENBSD_NR_opipe 42 | |
| 46 | +#define TARGET_OPENBSD_NR_getegid 43 | |
| 47 | +#define TARGET_OPENBSD_NR_profil 44 | |
| 48 | +#define TARGET_OPENBSD_NR_ktrace 45 | |
| 49 | +#define TARGET_OPENBSD_NR_sigaction 46 | |
| 50 | +#define TARGET_OPENBSD_NR_getgid 47 | |
| 51 | +#define TARGET_OPENBSD_NR_sigprocmask 48 | |
| 52 | +#define TARGET_OPENBSD_NR_getlogin 49 | |
| 53 | +#define TARGET_OPENBSD_NR_setlogin 50 | |
| 54 | +#define TARGET_OPENBSD_NR_acct 51 | |
| 55 | +#define TARGET_OPENBSD_NR_sigpending 52 | |
| 56 | +#define TARGET_OPENBSD_NR_osigaltstack 53 | |
| 57 | +#define TARGET_OPENBSD_NR_ioctl 54 | |
| 58 | +#define TARGET_OPENBSD_NR_reboot 55 | |
| 59 | +#define TARGET_OPENBSD_NR_revoke 56 | |
| 60 | +#define TARGET_OPENBSD_NR_symlink 57 | |
| 61 | +#define TARGET_OPENBSD_NR_readlink 58 | |
| 62 | +#define TARGET_OPENBSD_NR_execve 59 | |
| 63 | +#define TARGET_OPENBSD_NR_umask 60 | |
| 64 | +#define TARGET_OPENBSD_NR_chroot 61 | |
| 65 | +#define TARGET_OPENBSD_NR_vfork 66 | |
| 66 | +#define TARGET_OPENBSD_NR_sbrk 69 | |
| 67 | +#define TARGET_OPENBSD_NR_sstk 70 | |
| 68 | +#define TARGET_OPENBSD_NR_munmap 73 | |
| 69 | +#define TARGET_OPENBSD_NR_mprotect 74 | |
| 70 | +#define TARGET_OPENBSD_NR_madvise 75 | |
| 71 | +#define TARGET_OPENBSD_NR_mincore 78 | |
| 72 | +#define TARGET_OPENBSD_NR_getgroups 79 | |
| 73 | +#define TARGET_OPENBSD_NR_setgroups 80 | |
| 74 | +#define TARGET_OPENBSD_NR_getpgrp 81 | |
| 75 | +#define TARGET_OPENBSD_NR_setpgid 82 | |
| 76 | +#define TARGET_OPENBSD_NR_setitimer 83 | |
| 77 | +#define TARGET_OPENBSD_NR_getitimer 86 | |
| 78 | +#define TARGET_OPENBSD_NR_dup2 90 | |
| 79 | +#define TARGET_OPENBSD_NR_fcntl 92 | |
| 80 | +#define TARGET_OPENBSD_NR_select 93 | |
| 81 | +#define TARGET_OPENBSD_NR_fsync 95 | |
| 82 | +#define TARGET_OPENBSD_NR_setpriority 96 | |
| 83 | +#define TARGET_OPENBSD_NR_socket 97 | |
| 84 | +#define TARGET_OPENBSD_NR_connect 98 | |
| 85 | +#define TARGET_OPENBSD_NR_getpriority 100 | |
| 86 | +#define TARGET_OPENBSD_NR_sigreturn 103 | |
| 87 | +#define TARGET_OPENBSD_NR_bind 104 | |
| 88 | +#define TARGET_OPENBSD_NR_setsockopt 105 | |
| 89 | +#define TARGET_OPENBSD_NR_listen 106 | |
| 90 | +#define TARGET_OPENBSD_NR_sigsuspend 111 | |
| 91 | +#define TARGET_OPENBSD_NR_gettimeofday 116 | |
| 92 | +#define TARGET_OPENBSD_NR_getrusage 117 | |
| 93 | +#define TARGET_OPENBSD_NR_getsockopt 118 | |
| 94 | +#define TARGET_OPENBSD_NR_readv 120 | |
| 95 | +#define TARGET_OPENBSD_NR_writev 121 | |
| 96 | +#define TARGET_OPENBSD_NR_settimeofday 122 | |
| 97 | +#define TARGET_OPENBSD_NR_fchown 123 | |
| 98 | +#define TARGET_OPENBSD_NR_fchmod 124 | |
| 99 | +#define TARGET_OPENBSD_NR_setreuid 126 | |
| 100 | +#define TARGET_OPENBSD_NR_setregid 127 | |
| 101 | +#define TARGET_OPENBSD_NR_rename 128 | |
| 102 | +#define TARGET_OPENBSD_NR_flock 131 | |
| 103 | +#define TARGET_OPENBSD_NR_mkfifo 132 | |
| 104 | +#define TARGET_OPENBSD_NR_sendto 133 | |
| 105 | +#define TARGET_OPENBSD_NR_shutdown 134 | |
| 106 | +#define TARGET_OPENBSD_NR_socketpair 135 | |
| 107 | +#define TARGET_OPENBSD_NR_mkdir 136 | |
| 108 | +#define TARGET_OPENBSD_NR_rmdir 137 | |
| 109 | +#define TARGET_OPENBSD_NR_utimes 138 | |
| 110 | +#define TARGET_OPENBSD_NR_adjtime 140 | |
| 111 | +#define TARGET_OPENBSD_NR_setsid 147 | |
| 112 | +#define TARGET_OPENBSD_NR_quotactl 148 | |
| 113 | +#define TARGET_OPENBSD_NR_nfssvc 155 | |
| 114 | +#define TARGET_OPENBSD_NR_getfh 161 | |
| 115 | +#define TARGET_OPENBSD_NR_sysarch 165 | |
| 116 | +#define TARGET_OPENBSD_NR_pread 173 | |
| 117 | +#define TARGET_OPENBSD_NR_pwrite 174 | |
| 118 | +#define TARGET_OPENBSD_NR_setgid 181 | |
| 119 | +#define TARGET_OPENBSD_NR_setegid 182 | |
| 120 | +#define TARGET_OPENBSD_NR_seteuid 183 | |
| 121 | +#define TARGET_OPENBSD_NR_lfs_bmapv 184 | |
| 122 | +#define TARGET_OPENBSD_NR_lfs_markv 185 | |
| 123 | +#define TARGET_OPENBSD_NR_lfs_segclean 186 | |
| 124 | +#define TARGET_OPENBSD_NR_lfs_segwait 187 | |
| 125 | +#define TARGET_OPENBSD_NR_pathconf 191 | |
| 126 | +#define TARGET_OPENBSD_NR_fpathconf 192 | |
| 127 | +#define TARGET_OPENBSD_NR_swapctl 193 | |
| 128 | +#define TARGET_OPENBSD_NR_getrlimit 194 | |
| 129 | +#define TARGET_OPENBSD_NR_setrlimit 195 | |
| 130 | +#define TARGET_OPENBSD_NR_getdirentries 196 | |
| 131 | +#define TARGET_OPENBSD_NR_mmap 197 | |
| 132 | +#define TARGET_OPENBSD_NR___syscall 198 | |
| 133 | +#define TARGET_OPENBSD_NR_lseek 199 | |
| 134 | +#define TARGET_OPENBSD_NR_truncate 200 | |
| 135 | +#define TARGET_OPENBSD_NR_ftruncate 201 | |
| 136 | +#define TARGET_OPENBSD_NR___sysctl 202 | |
| 137 | +#define TARGET_OPENBSD_NR_mlock 203 | |
| 138 | +#define TARGET_OPENBSD_NR_munlock 204 | |
| 139 | +#define TARGET_OPENBSD_NR_futimes 206 | |
| 140 | +#define TARGET_OPENBSD_NR_getpgid 207 | |
| 141 | +#define TARGET_OPENBSD_NR_xfspioctl 208 | |
| 142 | +#define TARGET_OPENBSD_NR_semget 221 | |
| 143 | +#define TARGET_OPENBSD_NR_msgget 225 | |
| 144 | +#define TARGET_OPENBSD_NR_msgsnd 226 | |
| 145 | +#define TARGET_OPENBSD_NR_msgrcv 227 | |
| 146 | +#define TARGET_OPENBSD_NR_shmat 228 | |
| 147 | +#define TARGET_OPENBSD_NR_shmdt 230 | |
| 148 | +#define TARGET_OPENBSD_NR_clock_gettime 232 | |
| 149 | +#define TARGET_OPENBSD_NR_clock_settime 233 | |
| 150 | +#define TARGET_OPENBSD_NR_clock_getres 234 | |
| 151 | +#define TARGET_OPENBSD_NR_nanosleep 240 | |
| 152 | +#define TARGET_OPENBSD_NR_minherit 250 | |
| 153 | +#define TARGET_OPENBSD_NR_rfork 251 | |
| 154 | +#define TARGET_OPENBSD_NR_poll 252 | |
| 155 | +#define TARGET_OPENBSD_NR_issetugid 253 | |
| 156 | +#define TARGET_OPENBSD_NR_lchown 254 | |
| 157 | +#define TARGET_OPENBSD_NR_getsid 255 | |
| 158 | +#define TARGET_OPENBSD_NR_msync 256 | |
| 159 | +#define TARGET_OPENBSD_NR_pipe 263 | |
| 160 | +#define TARGET_OPENBSD_NR_fhopen 264 | |
| 161 | +#define TARGET_OPENBSD_NR_preadv 267 | |
| 162 | +#define TARGET_OPENBSD_NR_pwritev 268 | |
| 163 | +#define TARGET_OPENBSD_NR_kqueue 269 | |
| 164 | +#define TARGET_OPENBSD_NR_kevent 270 | |
| 165 | +#define TARGET_OPENBSD_NR_mlockall 271 | |
| 166 | +#define TARGET_OPENBSD_NR_munlockall 272 | |
| 167 | +#define TARGET_OPENBSD_NR_getpeereid 273 | |
| 168 | +#define TARGET_OPENBSD_NR_getresuid 281 | |
| 169 | +#define TARGET_OPENBSD_NR_setresuid 282 | |
| 170 | +#define TARGET_OPENBSD_NR_getresgid 283 | |
| 171 | +#define TARGET_OPENBSD_NR_setresgid 284 | |
| 172 | +#define TARGET_OPENBSD_NR_mquery 286 | |
| 173 | +#define TARGET_OPENBSD_NR_closefrom 287 | |
| 174 | +#define TARGET_OPENBSD_NR_sigaltstack 288 | |
| 175 | +#define TARGET_OPENBSD_NR_shmget 289 | |
| 176 | +#define TARGET_OPENBSD_NR_semop 290 | |
| 177 | +#define TARGET_OPENBSD_NR_stat 291 | |
| 178 | +#define TARGET_OPENBSD_NR_fstat 292 | |
| 179 | +#define TARGET_OPENBSD_NR_lstat 293 | |
| 180 | +#define TARGET_OPENBSD_NR_fhstat 294 | |
| 181 | +#define TARGET_OPENBSD_NR___semctl 295 | |
| 182 | +#define TARGET_OPENBSD_NR_shmctl 296 | |
| 183 | +#define TARGET_OPENBSD_NR_msgctl 297 | |
| 184 | +#define TARGET_OPENBSD_NR_sched_yield 298 | |
| 185 | +#define TARGET_OPENBSD_NR_getthrid 299 | |
| 186 | +#define TARGET_OPENBSD_NR_thrsleep 300 | |
| 187 | +#define TARGET_OPENBSD_NR_thrwakeup 301 | |
| 188 | +#define TARGET_OPENBSD_NR_threxit 302 | |
| 189 | +#define TARGET_OPENBSD_NR_thrsigdivert 303 | |
| 190 | +#define TARGET_OPENBSD_NR___getcwd 304 | |
| 191 | +#define TARGET_OPENBSD_NR_adjfreq 305 | |
| 192 | +#define TARGET_OPENBSD_NR_getfsstat 306 | |
| 193 | +#define TARGET_OPENBSD_NR_statfs 307 | |
| 194 | +#define TARGET_OPENBSD_NR_fstatfs 308 | |
| 195 | +#define TARGET_OPENBSD_NR_fhstatfs 309 | ... | ... |
bsd-user/path.c
0 โ 100644
| 1 | +/* Code to mangle pathnames into those matching a given prefix. | |
| 2 | + eg. open("/lib/foo.so") => open("/usr/gnemul/i386-linux/lib/foo.so"); | |
| 3 | + | |
| 4 | + The assumption is that this area does not change. | |
| 5 | +*/ | |
| 6 | +#include <sys/types.h> | |
| 7 | +#include <sys/param.h> | |
| 8 | +#include <dirent.h> | |
| 9 | +#include <unistd.h> | |
| 10 | +#include <stdlib.h> | |
| 11 | +#include <string.h> | |
| 12 | +#include <errno.h> | |
| 13 | +#include <stdio.h> | |
| 14 | +#include "qemu.h" | |
| 15 | +#include "qemu-common.h" | |
| 16 | + | |
| 17 | +struct pathelem | |
| 18 | +{ | |
| 19 | + /* Name of this, eg. lib */ | |
| 20 | + char *name; | |
| 21 | + /* Full path name, eg. /usr/gnemul/x86-linux/lib. */ | |
| 22 | + char *pathname; | |
| 23 | + struct pathelem *parent; | |
| 24 | + /* Children */ | |
| 25 | + unsigned int num_entries; | |
| 26 | + struct pathelem *entries[0]; | |
| 27 | +}; | |
| 28 | + | |
| 29 | +static struct pathelem *base; | |
| 30 | + | |
| 31 | +/* First N chars of S1 match S2, and S2 is N chars long. */ | |
| 32 | +static int strneq(const char *s1, unsigned int n, const char *s2) | |
| 33 | +{ | |
| 34 | + unsigned int i; | |
| 35 | + | |
| 36 | + for (i = 0; i < n; i++) | |
| 37 | + if (s1[i] != s2[i]) | |
| 38 | + return 0; | |
| 39 | + return s2[i] == 0; | |
| 40 | +} | |
| 41 | + | |
| 42 | +static struct pathelem *add_entry(struct pathelem *root, const char *name); | |
| 43 | + | |
| 44 | +static struct pathelem *new_entry(const char *root, | |
| 45 | + struct pathelem *parent, | |
| 46 | + const char *name) | |
| 47 | +{ | |
| 48 | + struct pathelem *new = malloc(sizeof(*new)); | |
| 49 | + new->name = strdup(name); | |
| 50 | + asprintf(&new->pathname, "%s/%s", root, name); | |
| 51 | + new->num_entries = 0; | |
| 52 | + return new; | |
| 53 | +} | |
| 54 | + | |
| 55 | +#define streq(a,b) (strcmp((a), (b)) == 0) | |
| 56 | + | |
| 57 | +static struct pathelem *add_dir_maybe(struct pathelem *path) | |
| 58 | +{ | |
| 59 | + DIR *dir; | |
| 60 | + | |
| 61 | + if ((dir = opendir(path->pathname)) != NULL) { | |
| 62 | + struct dirent *dirent; | |
| 63 | + | |
| 64 | + while ((dirent = readdir(dir)) != NULL) { | |
| 65 | + if (!streq(dirent->d_name,".") && !streq(dirent->d_name,"..")){ | |
| 66 | + path = add_entry(path, dirent->d_name); | |
| 67 | + } | |
| 68 | + } | |
| 69 | + closedir(dir); | |
| 70 | + } | |
| 71 | + return path; | |
| 72 | +} | |
| 73 | + | |
| 74 | +static struct pathelem *add_entry(struct pathelem *root, const char *name) | |
| 75 | +{ | |
| 76 | + root->num_entries++; | |
| 77 | + | |
| 78 | + root = realloc(root, sizeof(*root) | |
| 79 | + + sizeof(root->entries[0])*root->num_entries); | |
| 80 | + | |
| 81 | + root->entries[root->num_entries-1] = new_entry(root->pathname, root, name); | |
| 82 | + root->entries[root->num_entries-1] | |
| 83 | + = add_dir_maybe(root->entries[root->num_entries-1]); | |
| 84 | + return root; | |
| 85 | +} | |
| 86 | + | |
| 87 | +/* This needs to be done after tree is stabilized (ie. no more reallocs!). */ | |
| 88 | +static void set_parents(struct pathelem *child, struct pathelem *parent) | |
| 89 | +{ | |
| 90 | + unsigned int i; | |
| 91 | + | |
| 92 | + child->parent = parent; | |
| 93 | + for (i = 0; i < child->num_entries; i++) | |
| 94 | + set_parents(child->entries[i], child); | |
| 95 | +} | |
| 96 | + | |
| 97 | +/* FIXME: Doesn't handle DIR/.. where DIR is not in emulated dir. */ | |
| 98 | +static const char * | |
| 99 | +follow_path(const struct pathelem *cursor, const char *name) | |
| 100 | +{ | |
| 101 | + unsigned int i, namelen; | |
| 102 | + | |
| 103 | + name += strspn(name, "/"); | |
| 104 | + namelen = strcspn(name, "/"); | |
| 105 | + | |
| 106 | + if (namelen == 0) | |
| 107 | + return cursor->pathname; | |
| 108 | + | |
| 109 | + if (strneq(name, namelen, "..")) | |
| 110 | + return follow_path(cursor->parent, name + namelen); | |
| 111 | + | |
| 112 | + if (strneq(name, namelen, ".")) | |
| 113 | + return follow_path(cursor, name + namelen); | |
| 114 | + | |
| 115 | + for (i = 0; i < cursor->num_entries; i++) | |
| 116 | + if (strneq(name, namelen, cursor->entries[i]->name)) | |
| 117 | + return follow_path(cursor->entries[i], name + namelen); | |
| 118 | + | |
| 119 | + /* Not found */ | |
| 120 | + return NULL; | |
| 121 | +} | |
| 122 | + | |
| 123 | +void init_paths(const char *prefix) | |
| 124 | +{ | |
| 125 | + char pref_buf[PATH_MAX]; | |
| 126 | + | |
| 127 | + if (prefix[0] == '\0' || | |
| 128 | + !strcmp(prefix, "/")) | |
| 129 | + return; | |
| 130 | + | |
| 131 | + if (prefix[0] != '/') { | |
| 132 | + char *cwd = getcwd(NULL, 0); | |
| 133 | + size_t pref_buf_len = sizeof(pref_buf); | |
| 134 | + | |
| 135 | + if (!cwd) | |
| 136 | + abort(); | |
| 137 | + pstrcpy(pref_buf, sizeof(pref_buf), cwd); | |
| 138 | + pstrcat(pref_buf, pref_buf_len, "/"); | |
| 139 | + pstrcat(pref_buf, pref_buf_len, prefix); | |
| 140 | + free(cwd); | |
| 141 | + } else | |
| 142 | + pstrcpy(pref_buf, sizeof(pref_buf), prefix + 1); | |
| 143 | + | |
| 144 | + base = new_entry("", NULL, pref_buf); | |
| 145 | + base = add_dir_maybe(base); | |
| 146 | + if (base->num_entries == 0) { | |
| 147 | + free (base); | |
| 148 | + base = NULL; | |
| 149 | + } else { | |
| 150 | + set_parents(base, base); | |
| 151 | + } | |
| 152 | +} | |
| 153 | + | |
| 154 | +/* Look for path in emulation dir, otherwise return name. */ | |
| 155 | +const char *path(const char *name) | |
| 156 | +{ | |
| 157 | + /* Only do absolute paths: quick and dirty, but should mostly be OK. | |
| 158 | + Could do relative by tracking cwd. */ | |
| 159 | + if (!base || name[0] != '/') | |
| 160 | + return name; | |
| 161 | + | |
| 162 | + return follow_path(base, name) ?: name; | |
| 163 | +} | ... | ... |