diff --git a/build.py b/build.py index 678a1fece..ccbc9bee2 100755 --- a/build.py +++ b/build.py @@ -241,7 +241,6 @@ def clean_elf(): def run_ndk_build(flags): os.chdir("native") flags = "NDK_PROJECT_PATH=. NDK_APPLICATION_MK=src/Application.mk " + flags - cpu_count = 1 proc = system(f"{ndk_build} {flags} -j{cpu_count}") if proc.returncode != 0: error("Build binary failed!") diff --git a/native/src/crt0/bionic/syscall-x86.S b/native/src/crt0/bionic/syscall-x86.S index bc3fb2a73..c44ce3623 100644 --- a/native/src/crt0/bionic/syscall-x86.S +++ b/native/src/crt0/bionic/syscall-x86.S @@ -27,25 +27,18 @@ ENTRY(syscall) .cfi_adjust_cfa_offset 4 .cfi_rel_offset ebp, 0 - # Get and save the system call entry address. - call __kernel_syscall - push %eax - .cfi_adjust_cfa_offset 4 - .cfi_rel_offset eax, 0 - # Load all the arguments from the calling frame. # (Not all will be valid, depending on the syscall.) - mov 24(%esp),%eax - mov 28(%esp),%ebx - mov 32(%esp),%ecx - mov 36(%esp),%edx - mov 40(%esp),%esi - mov 44(%esp),%edi - mov 48(%esp),%ebp + mov 20(%esp),%eax + mov 24(%esp),%ebx + mov 28(%esp),%ecx + mov 32(%esp),%edx + mov 36(%esp),%esi + mov 40(%esp),%edi + mov 44(%esp),%ebp # Make the system call. - call *(%esp) - addl $4, %esp + int $0x80 # Error? cmpl $-MAX_ERRNO, %eax diff --git a/native/src/crt0/mem.c b/native/src/crt0/mem.c index 31a66d1c2..28c232208 100644 --- a/native/src/crt0/mem.c +++ b/native/src/crt0/mem.c @@ -1,6 +1,14 @@ #include #include +void *memset(void *dst, int ch, size_t n) { + return __builtin_memset(dst, ch, n); +} + +void *memmove(void *dst, const void *src, size_t n) { + return __builtin_memmove(dst, src, n); +} + void *memcpy(void *dst, const void *src, size_t size) { return __builtin_memcpy(dst, src, size); } diff --git a/native/src/crt0/misc.c b/native/src/crt0/misc.c index 367cb83b7..6c38eab7e 100644 --- a/native/src/crt0/misc.c +++ b/native/src/crt0/misc.c @@ -161,3 +161,23 @@ void __wrap_abort_message(const char* format, ...) { int __cxa_atexit(void (*func) (void *), void * arg, void * dso_handle) { return 0; } + +// Dummy function symbols + +long dummy() { return 0; } + +#define DUMMY_SYMBOL(name) \ +__asm__(".global " #name " \n " #name " = dummy") + +DUMMY_SYMBOL(pthread_setspecific); +DUMMY_SYMBOL(pthread_key_create); +DUMMY_SYMBOL(pthread_key_delete); +DUMMY_SYMBOL(pthread_getspecific); + +// Workaround LTO bug: https://github.com/llvm/llvm-project/issues/61101 +#if defined(__i386__) +extern long *_GLOBAL_OFFSET_TABLE_; +long unused() { + return *_GLOBAL_OFFSET_TABLE_; +} +#endif