* commit 'c58d08d655fbb3e0472fcb6ea9879fd1ced39172': x86_64: Add x86_64 syscalls and tune gen scripts for x86_64
This commit is contained in:
commit
1e99886172
@ -6,7 +6,7 @@
|
|||||||
#
|
#
|
||||||
# where:
|
# where:
|
||||||
# arch_list ::= "all" | "custom" | arch+
|
# arch_list ::= "all" | "custom" | arch+
|
||||||
# arch ::= "arm" | "mips" | "x86"
|
# arch ::= "arm" | "mips" | "x86" | "x86_64"
|
||||||
#
|
#
|
||||||
# Note:
|
# Note:
|
||||||
# - syscall_name corresponds to the name of the syscall, which may differ from
|
# - syscall_name corresponds to the name of the syscall, which may differ from
|
||||||
@ -40,56 +40,56 @@ pid_t __sys_clone:clone(int, void*, int*, void*, int*) all
|
|||||||
int execve(const char*, char* const*, char* const*) all
|
int execve(const char*, char* const*, char* const*) all
|
||||||
|
|
||||||
int __setuid:setuid32(uid_t) arm,x86
|
int __setuid:setuid32(uid_t) arm,x86
|
||||||
int __setuid:setuid(uid_t) mips
|
int __setuid:setuid(uid_t) mips,x86_64
|
||||||
uid_t getuid:getuid32() arm,x86
|
uid_t getuid:getuid32() arm,x86
|
||||||
uid_t getuid:getuid() mips
|
uid_t getuid:getuid() mips,x86_64
|
||||||
gid_t getgid:getgid32() arm,x86
|
gid_t getgid:getgid32() arm,x86
|
||||||
gid_t getgid:getgid() mips
|
gid_t getgid:getgid() mips,x86_64
|
||||||
uid_t geteuid:geteuid32() arm,x86
|
uid_t geteuid:geteuid32() arm,x86
|
||||||
uid_t geteuid:geteuid() mips
|
uid_t geteuid:geteuid() mips,x86_64
|
||||||
gid_t getegid:getegid32() arm,x86
|
gid_t getegid:getegid32() arm,x86
|
||||||
gid_t getegid:getegid() mips
|
gid_t getegid:getegid() mips,x86_64
|
||||||
uid_t getresuid:getresuid32(uid_t* ruid, uid_t* euid, uid_t* suid) arm,x86
|
uid_t getresuid:getresuid32(uid_t* ruid, uid_t* euid, uid_t* suid) arm,x86
|
||||||
uid_t getresuid:getresuid(uid_t* ruid, uid_t* euid, uid_t* suid) mips
|
uid_t getresuid:getresuid(uid_t* ruid, uid_t* euid, uid_t* suid) mips,x86_64
|
||||||
gid_t getresgid:getresgid32(gid_t* rgid, gid_t* egid, gid_t* sgid) arm,x86
|
gid_t getresgid:getresgid32(gid_t* rgid, gid_t* egid, gid_t* sgid) arm,x86
|
||||||
gid_t getresgid:getresgid(gid_t* rgid, gid_t* egid, gid_t* sgid) mips
|
gid_t getresgid:getresgid(gid_t* rgid, gid_t* egid, gid_t* sgid) mips,x86_64
|
||||||
pid_t gettid() all
|
pid_t gettid() all
|
||||||
ssize_t readahead(int, off64_t, size_t) all
|
ssize_t readahead(int, off64_t, size_t) all
|
||||||
int getgroups:getgroups32(int, gid_t*) arm,x86
|
int getgroups:getgroups32(int, gid_t*) arm,x86
|
||||||
int getgroups:getgroups(int, gid_t*) mips
|
int getgroups:getgroups(int, gid_t*) mips,x86_64
|
||||||
pid_t getpgid(pid_t) all
|
pid_t getpgid(pid_t) all
|
||||||
pid_t getppid() all
|
pid_t getppid() all
|
||||||
pid_t getsid(pid_t) all
|
pid_t getsid(pid_t) all
|
||||||
pid_t setsid() all
|
pid_t setsid() all
|
||||||
int setgid:setgid32(gid_t) arm,x86
|
int setgid:setgid32(gid_t) arm,x86
|
||||||
int setgid:setgid(gid_t) mips
|
int setgid:setgid(gid_t) mips,x86_64
|
||||||
int seteuid:seteuid32(uid_t) custom
|
int seteuid:seteuid32(uid_t) custom
|
||||||
int __setreuid:setreuid32(uid_t, uid_t) arm,x86
|
int __setreuid:setreuid32(uid_t, uid_t) arm,x86
|
||||||
int __setreuid:setreuid(uid_t, uid_t) mips
|
int __setreuid:setreuid(uid_t, uid_t) mips,x86_64
|
||||||
int __setresuid:setresuid32(uid_t, uid_t, uid_t) arm,x86
|
int __setresuid:setresuid32(uid_t, uid_t, uid_t) arm,x86
|
||||||
int __setresuid:setresuid(uid_t, uid_t, uid_t) mips
|
int __setresuid:setresuid(uid_t, uid_t, uid_t) mips,x86_64
|
||||||
int setresgid:setresgid32(gid_t, gid_t, gid_t) arm,x86
|
int setresgid:setresgid32(gid_t, gid_t, gid_t) arm,x86
|
||||||
int setresgid:setresgid(gid_t, gid_t, gid_t) mips
|
int setresgid:setresgid(gid_t, gid_t, gid_t) mips,x86_64
|
||||||
void* __brk:brk(void*) all
|
void* __brk:brk(void*) all
|
||||||
# See comments in kill.S to understand why we don't generate ARM stubs for kill/tkill/tgkill.
|
# See comments in kill.S to understand why we don't generate ARM stubs for kill/tkill/tgkill.
|
||||||
int kill(pid_t, int) mips,x86
|
int kill(pid_t, int) mips,x86,x86_64
|
||||||
int tkill(pid_t tid, int sig) mips,x86
|
int tkill(pid_t tid, int sig) mips,x86,x86_64
|
||||||
int tgkill(pid_t tgid, pid_t tid, int sig) mips,x86
|
int tgkill(pid_t tgid, pid_t tid, int sig) mips,x86,x86_64
|
||||||
int __ptrace:ptrace(int request, int pid, void* addr, void* data) all
|
int __ptrace:ptrace(int request, int pid, void* addr, void* data) all
|
||||||
int __set_thread_area:set_thread_area(void* user_desc) mips,x86
|
int __set_thread_area:set_thread_area(void* user_desc) mips,x86
|
||||||
int __getpriority:getpriority(int, int) all
|
int __getpriority:getpriority(int, int) all
|
||||||
int setpriority(int, int, int) all
|
int setpriority(int, int, int) all
|
||||||
int setrlimit(int resource, const struct rlimit* rlp) all
|
int setrlimit(int resource, const struct rlimit* rlp) all
|
||||||
int getrlimit:ugetrlimit(int resource, struct rlimit* rlp) arm,x86
|
int getrlimit:ugetrlimit(int resource, struct rlimit* rlp) arm,x86
|
||||||
int getrlimit:getrlimit(int resource, struct rlimit* rlp) mips
|
int getrlimit:getrlimit(int resource, struct rlimit* rlp) mips,x86_64
|
||||||
int getrusage(int who, struct rusage* r_usage) all
|
int getrusage(int who, struct rusage* r_usage) all
|
||||||
int setgroups:setgroups32(int, const gid_t*) arm,x86
|
int setgroups:setgroups32(int, const gid_t*) arm,x86
|
||||||
int setgroups:setgroups(int, const gid_t*) mips
|
int setgroups:setgroups(int, const gid_t*) mips,x86_64
|
||||||
pid_t getpgrp(void) custom
|
pid_t getpgrp(void) custom
|
||||||
int setpgid(pid_t, pid_t) all
|
int setpgid(pid_t, pid_t) all
|
||||||
pid_t vfork(void) arm
|
pid_t vfork(void) arm,x86_64
|
||||||
int setregid:setregid32(gid_t, gid_t) arm,x86
|
int setregid:setregid32(gid_t, gid_t) arm,x86
|
||||||
int setregid:setregid(gid_t, gid_t) mips
|
int setregid:setregid(gid_t, gid_t) mips,x86_64
|
||||||
int chroot(const char*) all
|
int chroot(const char*) all
|
||||||
# IMPORTANT: Even though <sys/prctl.h> declares prctl(int, ...), the syscall stub must take 6 arguments
|
# IMPORTANT: Even though <sys/prctl.h> declares prctl(int, ...), the syscall stub must take 6 arguments
|
||||||
# to match the kernel implementation.
|
# to match the kernel implementation.
|
||||||
@ -109,10 +109,10 @@ int __openat:openat(int, const char*, int, mode_t) all
|
|||||||
int close(int) all
|
int close(int) all
|
||||||
int creat(const char*, mode_t) custom
|
int creat(const char*, mode_t) custom
|
||||||
off_t lseek(int, off_t, int) all
|
off_t lseek(int, off_t, int) all
|
||||||
int __llseek:_llseek(int, unsigned long, unsigned long, off64_t*, int) all
|
int __llseek:_llseek(int, unsigned long, unsigned long, off64_t*, int) arm,x86,mips
|
||||||
pid_t getpid() all
|
pid_t getpid() all
|
||||||
void* mmap(void*, size_t, int, int, int, long) custom
|
void* mmap(void*, size_t, int, int, int, long) x86_64
|
||||||
void* __mmap2:mmap2(void*, size_t, int, int, int, long) all
|
void* __mmap2:mmap2(void*, size_t, int, int, int, long) arm,x86,mips
|
||||||
int munmap(void*, size_t) all
|
int munmap(void*, size_t) all
|
||||||
void* mremap(void*, size_t, size_t, unsigned long) all
|
void* mremap(void*, size_t, size_t, unsigned long) all
|
||||||
int msync(const void*, size_t, int) all
|
int msync(const void*, size_t, int) all
|
||||||
@ -126,27 +126,30 @@ int mincore(void* start, size_t length, unsigned char* vec) all
|
|||||||
int __ioctl:ioctl(int, int, void*) all
|
int __ioctl:ioctl(int, int, void*) all
|
||||||
int readv(int, const struct iovec*, int) all
|
int readv(int, const struct iovec*, int) all
|
||||||
int writev(int, const struct iovec*, int) all
|
int writev(int, const struct iovec*, int) all
|
||||||
int __fcntl:fcntl(int, int, void*) all
|
int __fcntl:fcntl(int, int, void*) arm,x86,mips
|
||||||
|
int fcntl(int, void*) x86_64
|
||||||
int flock(int, int) all
|
int flock(int, int) all
|
||||||
int fchmod(int, mode_t) all
|
int fchmod(int, mode_t) all
|
||||||
int dup(int) all
|
int dup(int) all
|
||||||
int pipe(int*) arm,x86
|
int pipe(int*) arm,x86,x86_64
|
||||||
int pipe2(int*, int) all
|
int pipe2(int*, int) all
|
||||||
int dup2(int, int) all
|
int dup2(int, int) all
|
||||||
int select:_newselect(int, struct fd_set*, struct fd_set*, struct fd_set*, struct timeval*) all
|
int select:_newselect(int, struct fd_set*, struct fd_set*, struct fd_set*, struct timeval*) arm,x86,mips
|
||||||
|
int select(int, struct fd_set*, struct fd_set*, struct fd_set*, struct timeval*) x86_64
|
||||||
int ftruncate(int, off_t) all
|
int ftruncate(int, off_t) all
|
||||||
int ftruncate64(int, off64_t) all
|
int ftruncate64(int, off64_t) arm,x86,mips
|
||||||
int getdents:getdents64(unsigned int, struct dirent*, unsigned int) all
|
int getdents:getdents64(unsigned int, struct dirent*, unsigned int) all
|
||||||
int fsync(int) all
|
int fsync(int) all
|
||||||
int fdatasync(int) all
|
int fdatasync(int) all
|
||||||
int fchown:fchown32(int, uid_t, gid_t) arm,x86
|
int fchown:fchown32(int, uid_t, gid_t) arm,x86
|
||||||
int fchown:fchown(int, uid_t, gid_t) mips
|
int fchown:fchown(int, uid_t, gid_t) mips,x86_64
|
||||||
void sync(void) all
|
void sync(void) all
|
||||||
int __fcntl64:fcntl64(int, int, void*) all
|
int __fcntl64:fcntl64(int, int, void*) arm,x86,mips
|
||||||
int __fstatfs64:fstatfs64(int, size_t, struct statfs*) all
|
int __fstatfs64:fstatfs64(int, size_t, struct statfs*) arm,x86,mips
|
||||||
|
int fstatfs(int, struct statfs*) x86_64
|
||||||
ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count) all
|
ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count) all
|
||||||
ssize_t sendfile64(int out_fd, int in_fd, off64_t* offset, size_t count) all
|
ssize_t sendfile64(int out_fd, int in_fd, off64_t* offset, size_t count) arm,x86,mips
|
||||||
int fstatat:fstatat64(int dirfd, const char* path, struct stat* buf, int flags) all
|
int fstatat:fstatat64(int dirfd, const char* path, struct stat* buf, int flags) arm,x86,mips
|
||||||
int mkdirat(int dirfd, const char* pathname, mode_t mode) all
|
int mkdirat(int dirfd, const char* pathname, mode_t mode) all
|
||||||
int fchownat(int dirfd, const char* path, uid_t owner, gid_t group, int flags) all
|
int fchownat(int dirfd, const char* path, uid_t owner, gid_t group, int flags) all
|
||||||
int fchmodat(int dirfd, const char* path, mode_t mode, int flags) all
|
int fchmodat(int dirfd, const char* path, mode_t mode, int flags) all
|
||||||
@ -164,15 +167,18 @@ int chdir(const char*) all
|
|||||||
int mknod(const char*, mode_t, dev_t) all
|
int mknod(const char*, mode_t, dev_t) all
|
||||||
int chmod(const char*, mode_t) all
|
int chmod(const char*, mode_t) all
|
||||||
int chown:chown32(const char*, uid_t, gid_t) arm,x86
|
int chown:chown32(const char*, uid_t, gid_t) arm,x86
|
||||||
int chown:chown(const char*, uid_t, gid_t) mips
|
int chown:chown(const char*, uid_t, gid_t) mips,x86_64
|
||||||
int lchown:lchown32(const char*, uid_t, gid_t) arm,x86
|
int lchown:lchown32(const char*, uid_t, gid_t) arm,x86
|
||||||
int lchown:lchown(const char*, uid_t, gid_t) mips
|
int lchown:lchown(const char*, uid_t, gid_t) mips,x86_64
|
||||||
int mount(const char*, const char*, const char*, unsigned long, const void*) all
|
int mount(const char*, const char*, const char*, unsigned long, const void*) all
|
||||||
int umount(const char*) custom
|
int umount(const char*) custom
|
||||||
int umount2(const char*, int) all
|
int umount2(const char*, int) all
|
||||||
int fstat:fstat64(int, struct stat*) all
|
int fstat:fstat64(int, struct stat*) arm,x86,mips
|
||||||
int stat:stat64(const char*, struct stat*) all
|
int fstat(int, struct stat*) x86_64
|
||||||
int lstat:lstat64(const char*, struct stat*) all
|
int stat:stat64(const char*, struct stat*) arm,x86,mips
|
||||||
|
int stat(const char*, struct stat*) x86_64
|
||||||
|
int lstat:lstat64(const char*, struct stat*) arm,x86,mips
|
||||||
|
int lstat(const char*, struct stat*) x86_64
|
||||||
int mkdir(const char*, mode_t) all
|
int mkdir(const char*, mode_t) all
|
||||||
int readlink(const char*, char*, size_t) all
|
int readlink(const char*, char*, size_t) all
|
||||||
int rmdir(const char*) all
|
int rmdir(const char*) all
|
||||||
@ -183,7 +189,7 @@ int faccessat(int, const char*, int, int) all
|
|||||||
int symlink(const char*, const char*) all
|
int symlink(const char*, const char*) all
|
||||||
int fchdir(int) all
|
int fchdir(int) all
|
||||||
int truncate(const char*, off_t) all
|
int truncate(const char*, off_t) all
|
||||||
int truncate64(const char*, off64_t) all
|
int truncate64(const char*, off64_t) arm,x86,mips
|
||||||
int setxattr(const char*, const char*, const void*, size_t, int) all
|
int setxattr(const char*, const char*, const void*, size_t, int) all
|
||||||
int lsetxattr(const char*, const char*, const void*, size_t, int) all
|
int lsetxattr(const char*, const char*, const void*, size_t, int) all
|
||||||
ssize_t getxattr(const char*, const char*, void*, size_t) all
|
ssize_t getxattr(const char*, const char*, void*, size_t) all
|
||||||
@ -192,7 +198,8 @@ ssize_t listxattr(const char*, char*, size_t) all
|
|||||||
ssize_t llistxattr(const char*, char*, size_t) all
|
ssize_t llistxattr(const char*, char*, size_t) all
|
||||||
int removexattr(const char*, const char*) all
|
int removexattr(const char*, const char*) all
|
||||||
int lremovexattr(const char*, const char*) all
|
int lremovexattr(const char*, const char*) all
|
||||||
int __statfs64:statfs64(const char*, size_t, struct statfs*) all
|
int __statfs64:statfs64(const char*, size_t, struct statfs*) arm,x86,mips
|
||||||
|
int statfs(const char*, struct statfs*) x86_64
|
||||||
long unshare(unsigned long) all
|
long unshare(unsigned long) all
|
||||||
int swapon(const char*, int) all
|
int swapon(const char*, int) all
|
||||||
int swapoff(const char*) all
|
int swapoff(const char*) all
|
||||||
@ -221,32 +228,33 @@ int timerfd_settime(int, int, const struct itimerspec*, struct itimers
|
|||||||
int timerfd_gettime(int, struct itimerspec*) all
|
int timerfd_gettime(int, struct itimerspec*) all
|
||||||
|
|
||||||
# signals
|
# signals
|
||||||
int sigaction(int, const struct sigaction*, struct sigaction*) all
|
int sigaction(int, const struct sigaction*, struct sigaction*) arm,x86,mips
|
||||||
int sigprocmask(int, const sigset_t*, sigset_t*) all
|
int sigprocmask(int, const sigset_t*, sigset_t*) arm,x86,mips
|
||||||
int __sigsuspend:sigsuspend(int unused1, int unused2, unsigned mask) arm,x86
|
int __sigsuspend:sigsuspend(int unused1, int unused2, unsigned mask) arm,x86
|
||||||
int __sigsuspend:sigsuspend(const sigset_t* mask) mips
|
int __sigsuspend:sigsuspend(const sigset_t* mask) mips
|
||||||
|
int __rt_sigsuspend:rt_sigsuspend(const sigset_t *unewset, size_t sigset_size) x86_64
|
||||||
int __rt_sigaction:rt_sigaction(int sig, const struct sigaction* act, struct sigaction* oact, size_t sigsetsize) all
|
int __rt_sigaction:rt_sigaction(int sig, const struct sigaction* act, struct sigaction* oact, size_t sigsetsize) all
|
||||||
int __rt_sigprocmask:rt_sigprocmask(int how, const sigset_t* set, sigset_t* oset, size_t sigsetsize) all
|
int __rt_sigprocmask:rt_sigprocmask(int how, const sigset_t* set, sigset_t* oset, size_t sigsetsize) all
|
||||||
int __rt_sigtimedwait:rt_sigtimedwait(const sigset_t* set, struct siginfo_t* info, struct timespec_t* timeout, size_t sigset_size) all
|
int __rt_sigtimedwait:rt_sigtimedwait(const sigset_t* set, struct siginfo_t* info, struct timespec_t* timeout, size_t sigset_size) all
|
||||||
int sigpending(sigset_t*) all
|
int sigpending(sigset_t*) arm,x86,mips
|
||||||
int signalfd4(int fd, const sigset_t* mask, size_t sizemask, int flags) all
|
int signalfd4(int fd, const sigset_t* mask, size_t sizemask, int flags) all
|
||||||
|
|
||||||
# sockets
|
# sockets
|
||||||
int socket(int, int, int) arm,mips
|
int socket(int, int, int) arm,mips,x86_64
|
||||||
int socketpair(int, int, int, int*) arm,mips
|
int socketpair(int, int, int, int*) arm,mips,x86_64
|
||||||
int bind(int, struct sockaddr*, int) arm,mips
|
int bind(int, struct sockaddr*, int) arm,mips,x86_64
|
||||||
int connect(int, struct sockaddr*, socklen_t) arm,mips
|
int connect(int, struct sockaddr*, socklen_t) arm,mips,x86_64
|
||||||
int listen(int, int) arm,mips
|
int listen(int, int) arm,mips,x86_64
|
||||||
int accept(int, struct sockaddr*, socklen_t*) arm,mips
|
int accept(int, struct sockaddr*, socklen_t*) arm,mips,x86_64
|
||||||
int getsockname(int, struct sockaddr*, socklen_t*) arm,mips
|
int getsockname(int, struct sockaddr*, socklen_t*) arm,mips,x86_64
|
||||||
int getpeername(int, struct sockaddr*, socklen_t*) arm,mips
|
int getpeername(int, struct sockaddr*, socklen_t*) arm,mips,x86_64
|
||||||
int sendto(int, const void*, size_t, int, const struct sockaddr*, socklen_t) arm,mips
|
int sendto(int, const void*, size_t, int, const struct sockaddr*, socklen_t) arm,mips,x86_64
|
||||||
int recvfrom(int, void*, size_t, unsigned int, struct sockaddr*, socklen_t*) arm,mips
|
int recvfrom(int, void*, size_t, unsigned int, struct sockaddr*, socklen_t*) arm,mips,x86_64
|
||||||
int shutdown(int, int) arm,mips
|
int shutdown(int, int) arm,mips,x86_64
|
||||||
int setsockopt(int, int, int, const void*, socklen_t) arm,mips
|
int setsockopt(int, int, int, const void*, socklen_t) arm,mips,x86_64
|
||||||
int getsockopt(int, int, int, void*, socklen_t*) arm,mips
|
int getsockopt(int, int, int, void*, socklen_t*) arm,mips,x86_64
|
||||||
int sendmsg(int, const struct msghdr*, unsigned int) arm,mips
|
int sendmsg(int, const struct msghdr*, unsigned int) arm,mips,x86_64
|
||||||
int recvmsg(int, struct msghdr*, unsigned int) arm,mips
|
int recvmsg(int, struct msghdr*, unsigned int) arm,mips,x86_64
|
||||||
|
|
||||||
# sockets for x86. These are done as an "indexed" call to socketcall syscall.
|
# sockets for x86. These are done as an "indexed" call to socketcall syscall.
|
||||||
int socket:socketcall:1(int, int, int) x86
|
int socket:socketcall:1(int, int, int) x86
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import sys, os, commands, string
|
import sys, os, commands, string
|
||||||
|
|
||||||
all_arches = [ "arm", "mips", "x86" ]
|
all_arches = [ "arm", "mips", "x86", "x86_64" ]
|
||||||
|
|
||||||
# basic debugging trace support
|
# basic debugging trace support
|
||||||
# call D_setlevel to set the verbosity level
|
# call D_setlevel to set the verbosity level
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
#
|
|
||||||
# this tool is used to generate the syscall assembler templates
|
# This tool is used to generate the assembler system call stubs,
|
||||||
# to be placed into arch-{arm,x86,mips}/syscalls, as well as the content
|
# the header files listing all available system calls, and the
|
||||||
# of arch-{arm,x86,mips}/linux/_syscalls.h
|
# makefiles used to build all the stubs.
|
||||||
#
|
|
||||||
|
|
||||||
import sys, os.path, glob, re, commands, filecmp, shutil
|
import sys, os.path, glob, re, commands, filecmp, shutil
|
||||||
import getpass
|
|
||||||
|
|
||||||
from bionic_utils import *
|
from bionic_utils import *
|
||||||
|
|
||||||
@ -15,7 +13,9 @@ bionic_libc_root = os.environ["ANDROID_BUILD_TOP"] + "/bionic/libc/"
|
|||||||
# temp directory where we store all intermediate files
|
# temp directory where we store all intermediate files
|
||||||
bionic_temp = "/tmp/bionic_gensyscalls/"
|
bionic_temp = "/tmp/bionic_gensyscalls/"
|
||||||
|
|
||||||
def make_dir( path ):
|
DRY_RUN = False
|
||||||
|
|
||||||
|
def make_dir(path):
|
||||||
path = os.path.abspath(path)
|
path = os.path.abspath(path)
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
parent = os.path.dirname(path)
|
parent = os.path.dirname(path)
|
||||||
@ -23,23 +23,25 @@ def make_dir( path ):
|
|||||||
make_dir(parent)
|
make_dir(parent)
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
|
|
||||||
def create_file( relpath ):
|
def create_file(relpath):
|
||||||
dir = os.path.dirname( bionic_temp + relpath )
|
dir = os.path.dirname(bionic_temp + relpath)
|
||||||
make_dir(dir)
|
make_dir(dir)
|
||||||
return open( bionic_temp + relpath, "w" )
|
return open(bionic_temp + relpath, "w")
|
||||||
|
|
||||||
|
|
||||||
|
syscall_stub_header = """/* autogenerated by gensyscalls.py */
|
||||||
|
#include <asm/unistd.h>
|
||||||
|
#include <linux/err.h>
|
||||||
|
#include <machine/asm.h>
|
||||||
|
|
||||||
|
ENTRY(%(fname)s)
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# x86 assembler templates for each syscall stub
|
# x86 assembler templates for each syscall stub
|
||||||
#
|
#
|
||||||
|
|
||||||
x86_header = """/* autogenerated by gensyscalls.py */
|
|
||||||
#include <linux/err.h>
|
|
||||||
#include <machine/asm.h>
|
|
||||||
#include <asm/unistd.h>
|
|
||||||
|
|
||||||
ENTRY(%(fname)s)
|
|
||||||
"""
|
|
||||||
|
|
||||||
x86_registers = [ "%ebx", "%ecx", "%edx", "%esi", "%edi", "%ebp" ]
|
x86_registers = [ "%ebx", "%ecx", "%edx", "%esi", "%edi", "%ebp" ]
|
||||||
|
|
||||||
x86_call = """ movl $%(idname)s, %%eax
|
x86_call = """ movl $%(idname)s, %%eax
|
||||||
@ -58,19 +60,28 @@ x86_return = """ ret
|
|||||||
END(%(fname)s)
|
END(%(fname)s)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
#
|
||||||
|
# x86_64 assembler templates for each syscall stub
|
||||||
|
#
|
||||||
|
|
||||||
|
x86_64_call = """ movl $%(idname)s, %%eax
|
||||||
|
syscall
|
||||||
|
cmpq $-MAX_ERRNO, %%rax
|
||||||
|
jb 1f
|
||||||
|
negl %%eax
|
||||||
|
movl %%eax, %%edi
|
||||||
|
call __set_errno
|
||||||
|
orq $-1, %%rax
|
||||||
|
1:
|
||||||
|
ret
|
||||||
|
END(%(fname)s)
|
||||||
|
"""
|
||||||
|
|
||||||
#
|
#
|
||||||
# ARM assembler templates for each syscall stub
|
# ARM assembler templates for each syscall stub
|
||||||
#
|
#
|
||||||
|
|
||||||
arm_header = """/* autogenerated by gensyscalls.py */
|
arm_eabi_call_default = syscall_stub_header + """\
|
||||||
#include <asm/unistd.h>
|
|
||||||
#include <linux/err.h>
|
|
||||||
#include <machine/asm.h>
|
|
||||||
|
|
||||||
ENTRY(%(fname)s)
|
|
||||||
"""
|
|
||||||
|
|
||||||
arm_eabi_call_default = arm_header + """\
|
|
||||||
mov ip, r7
|
mov ip, r7
|
||||||
ldr r7, =%(idname)s
|
ldr r7, =%(idname)s
|
||||||
swi #0
|
swi #0
|
||||||
@ -82,7 +93,7 @@ arm_eabi_call_default = arm_header + """\
|
|||||||
END(%(fname)s)
|
END(%(fname)s)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
arm_eabi_call_long = arm_header + """\
|
arm_eabi_call_long = syscall_stub_header + """\
|
||||||
mov ip, sp
|
mov ip, sp
|
||||||
.save {r4, r5, r6, r7}
|
.save {r4, r5, r6, r7}
|
||||||
stmfd sp!, {r4, r5, r6, r7}
|
stmfd sp!, {r4, r5, r6, r7}
|
||||||
@ -178,6 +189,12 @@ def count_generic_param_registers(params):
|
|||||||
count += 1
|
count += 1
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
def count_generic_param_registers64(params):
|
||||||
|
count = 0
|
||||||
|
for param in params:
|
||||||
|
count += 1
|
||||||
|
return count
|
||||||
|
|
||||||
# This lets us support regular system calls like __NR_write and also weird
|
# This lets us support regular system calls like __NR_write and also weird
|
||||||
# ones like __ARM_NR_cacheflush, where the NR doesn't come at the start.
|
# ones like __ARM_NR_cacheflush, where the NR doesn't come at the start.
|
||||||
def make__NR_name(name):
|
def make__NR_name(name):
|
||||||
@ -193,11 +210,22 @@ class State:
|
|||||||
self.other_files = []
|
self.other_files = []
|
||||||
self.syscalls = []
|
self.syscalls = []
|
||||||
|
|
||||||
|
def x86_64_genstub(self, fname, numparams, idname):
|
||||||
|
t = { "fname" : fname, "idname" : idname }
|
||||||
|
|
||||||
|
result = syscall_stub_header % t
|
||||||
|
# rcx is used as 4th argument. Kernel wants it at r10.
|
||||||
|
if (numparams > 3):
|
||||||
|
result += " movq %rcx, %r10\n"
|
||||||
|
|
||||||
|
result += x86_64_call % t
|
||||||
|
return result
|
||||||
|
|
||||||
def x86_genstub(self, fname, numparams, idname):
|
def x86_genstub(self, fname, numparams, idname):
|
||||||
t = { "fname" : fname,
|
t = { "fname" : fname,
|
||||||
"idname" : idname }
|
"idname" : idname }
|
||||||
|
|
||||||
result = x86_header % t
|
result = syscall_stub_header % t
|
||||||
stack_bias = 4
|
stack_bias = 4
|
||||||
for r in range(numparams):
|
for r in range(numparams):
|
||||||
result += " pushl " + x86_registers[r] + "\n"
|
result += " pushl " + x86_registers[r] + "\n"
|
||||||
@ -222,7 +250,7 @@ class State:
|
|||||||
t = { "fname" : fname,
|
t = { "fname" : fname,
|
||||||
"idname" : idname }
|
"idname" : idname }
|
||||||
|
|
||||||
result = x86_header % t
|
result = syscall_stub_header % t
|
||||||
stack_bias = 4
|
stack_bias = 4
|
||||||
|
|
||||||
# save the regs we need
|
# save the regs we need
|
||||||
@ -294,6 +322,9 @@ class State:
|
|||||||
if t.has_key("mips"):
|
if t.has_key("mips"):
|
||||||
t["asm-mips"] = self.mips_genstub(syscall_func, make__NR_name(syscall_name))
|
t["asm-mips"] = self.mips_genstub(syscall_func, make__NR_name(syscall_name))
|
||||||
|
|
||||||
|
if t.has_key("x86_64"):
|
||||||
|
num_regs = count_generic_param_registers64(syscall_params)
|
||||||
|
t["asm-x86_64"] = self.x86_64_genstub(syscall_func, num_regs, __NR_name)
|
||||||
|
|
||||||
# Scan a Linux kernel asm/unistd.h file containing __NR_* constants
|
# Scan a Linux kernel asm/unistd.h file containing __NR_* constants
|
||||||
# and write out equivalent SYS_* constants for glibc source compatibility.
|
# and write out equivalent SYS_* constants for glibc source compatibility.
|
||||||
@ -323,6 +354,8 @@ class State:
|
|||||||
self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/arch-mips/asm/unistd.h")
|
self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/arch-mips/asm/unistd.h")
|
||||||
glibc_fp.write("#elif defined(__i386__)\n")
|
glibc_fp.write("#elif defined(__i386__)\n")
|
||||||
self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/arch-x86/asm/unistd_32.h")
|
self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/arch-x86/asm/unistd_32.h")
|
||||||
|
glibc_fp.write("#elif defined(__x86_64__)\n")
|
||||||
|
self.scan_linux_unistd_h(glibc_fp, bionic_libc_root + "/kernel/arch-x86/asm/unistd_64.h")
|
||||||
glibc_fp.write("#endif\n")
|
glibc_fp.write("#endif\n")
|
||||||
|
|
||||||
glibc_fp.write("#endif /* _BIONIC_GLIBC_SYSCALLS_H_ */\n")
|
glibc_fp.write("#endif /* _BIONIC_GLIBC_SYSCALLS_H_ */\n")
|
||||||
@ -358,63 +391,62 @@ class State:
|
|||||||
|
|
||||||
|
|
||||||
def regenerate(self):
|
def regenerate(self):
|
||||||
D( "scanning for existing architecture-specific stub files" )
|
D("scanning for existing architecture-specific stub files...")
|
||||||
|
|
||||||
bionic_libc_root_len = len(bionic_libc_root)
|
bionic_libc_root_len = len(bionic_libc_root)
|
||||||
|
|
||||||
for arch in all_arches:
|
for arch in all_arches:
|
||||||
arch_path = bionic_libc_root + "arch-" + arch
|
arch_path = bionic_libc_root + "arch-" + arch
|
||||||
D( "scanning " + arch_path )
|
D("scanning " + arch_path)
|
||||||
files = glob.glob( arch_path + "/syscalls/*.S" )
|
files = glob.glob(arch_path + "/syscalls/*.S")
|
||||||
for f in files:
|
for f in files:
|
||||||
self.old_stubs.append( f[bionic_libc_root_len:] )
|
self.old_stubs.append(f[bionic_libc_root_len:])
|
||||||
|
|
||||||
D( "found %d stub files" % len(self.old_stubs) )
|
D("found %d stub files" % len(self.old_stubs))
|
||||||
|
|
||||||
if not os.path.exists( bionic_temp ):
|
if not os.path.exists(bionic_temp):
|
||||||
D( "creating %s" % bionic_temp )
|
D("creating %s..." % bionic_temp)
|
||||||
make_dir( bionic_temp )
|
make_dir(bionic_temp)
|
||||||
|
|
||||||
D( "re-generating stubs and support files" )
|
D("re-generating stubs and support files...")
|
||||||
|
|
||||||
self.gen_glibc_syscalls_h()
|
self.gen_glibc_syscalls_h()
|
||||||
for arch in all_arches:
|
for arch in all_arches:
|
||||||
self.gen_arch_syscalls_mk(arch)
|
self.gen_arch_syscalls_mk(arch)
|
||||||
self.gen_syscall_stubs()
|
self.gen_syscall_stubs()
|
||||||
|
|
||||||
D( "comparing files" )
|
D("comparing files...")
|
||||||
adds = []
|
adds = []
|
||||||
edits = []
|
edits = []
|
||||||
|
|
||||||
for stub in self.new_stubs + self.other_files:
|
for stub in self.new_stubs + self.other_files:
|
||||||
if not os.path.exists( bionic_libc_root + stub ):
|
if not os.path.exists(bionic_libc_root + stub):
|
||||||
# new file, git add it
|
# new file, git add it
|
||||||
D( "new file: " + stub)
|
D("new file: " + stub)
|
||||||
adds.append( bionic_libc_root + stub )
|
adds.append(bionic_libc_root + stub)
|
||||||
shutil.copyfile( bionic_temp + stub, bionic_libc_root + stub )
|
shutil.copyfile(bionic_temp + stub, bionic_libc_root + stub)
|
||||||
|
|
||||||
elif not filecmp.cmp( bionic_temp + stub, bionic_libc_root + stub ):
|
elif not filecmp.cmp(bionic_temp + stub, bionic_libc_root + stub):
|
||||||
D( "changed file: " + stub)
|
D("changed file: " + stub)
|
||||||
edits.append( stub )
|
edits.append(stub)
|
||||||
|
|
||||||
deletes = []
|
deletes = []
|
||||||
for stub in self.old_stubs:
|
for stub in self.old_stubs:
|
||||||
if not stub in self.new_stubs:
|
if not stub in self.new_stubs:
|
||||||
D( "deleted file: " + stub)
|
D("deleted file: " + stub)
|
||||||
deletes.append( bionic_libc_root + stub )
|
deletes.append(bionic_libc_root + stub)
|
||||||
|
|
||||||
|
if not DRY_RUN:
|
||||||
|
if adds:
|
||||||
|
commands.getoutput("git add " + " ".join(adds))
|
||||||
|
if deletes:
|
||||||
|
commands.getoutput("git rm " + " ".join(deletes))
|
||||||
|
if edits:
|
||||||
|
for file in edits:
|
||||||
|
shutil.copyfile(bionic_temp + file, bionic_libc_root + file)
|
||||||
|
commands.getoutput("git add " + " ".join((bionic_libc_root + file) for file in edits))
|
||||||
|
|
||||||
if adds:
|
commands.getoutput("git add %s%s" % (bionic_libc_root,"SYSCALLS.TXT"))
|
||||||
commands.getoutput("git add " + " ".join(adds))
|
|
||||||
if deletes:
|
|
||||||
commands.getoutput("git rm " + " ".join(deletes))
|
|
||||||
if edits:
|
|
||||||
for file in edits:
|
|
||||||
shutil.copyfile( bionic_temp + file, bionic_libc_root + file )
|
|
||||||
commands.getoutput("git add " +
|
|
||||||
" ".join((bionic_libc_root + file) for file in edits))
|
|
||||||
|
|
||||||
commands.getoutput("git add %s%s" % (bionic_libc_root,"SYSCALLS.TXT"))
|
|
||||||
|
|
||||||
if (not adds) and (not deletes) and (not edits):
|
if (not adds) and (not deletes) and (not edits):
|
||||||
D("no changes detected!")
|
D("no changes detected!")
|
||||||
|
Loading…
Reference in New Issue
Block a user