mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
Merge pull request #22049 from alexrp/musl-gen-stubs
`gen_stubs`: No compiler-rt hacks, more compact output, and more arch support
This commit is contained in:
Vendored
+1
@@ -3,6 +3,7 @@ __asm__(
|
||||
".weak _DYNAMIC \n"
|
||||
".hidden _DYNAMIC \n"
|
||||
".global " START "\n"
|
||||
".type " START ",%function \n"
|
||||
START ":\n"
|
||||
" xor %ebp,%ebp \n"
|
||||
" mov %esp,%eax \n"
|
||||
|
||||
Vendored
+1
@@ -1,6 +1,7 @@
|
||||
__asm__(
|
||||
".text \n"
|
||||
".global " START " \n"
|
||||
".type " START ",%function \n"
|
||||
START ": \n"
|
||||
" xor %rbp,%rbp \n"
|
||||
" mov %rsp,%rdi \n"
|
||||
|
||||
Vendored
+109
-51
@@ -7,6 +7,13 @@
|
||||
#define PTR_SIZE_BYTES 4
|
||||
#define PTR2_SIZE_BYTES 8
|
||||
#endif
|
||||
|
||||
#ifdef TIME32
|
||||
#define WEAKTIME64 .globl
|
||||
#else
|
||||
#define WEAKTIME64 .weak
|
||||
#endif
|
||||
|
||||
.bss
|
||||
.weak ___environ
|
||||
.type ___environ, %object;
|
||||
@@ -168,18 +175,64 @@ _IO_putc:
|
||||
.weak _IO_putc_unlocked
|
||||
.type _IO_putc_unlocked, %function;
|
||||
_IO_putc_unlocked:
|
||||
#if !defined(ARCH_riscv64) && !defined(ARCH_mips) && !defined(ARCH_mips64) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64) && !defined(ARCH_riscv32) && !defined(ARCH_loongarch64)
|
||||
#ifdef ARCH_i386
|
||||
.globl ___tls_get_addr
|
||||
.type ___tls_get_addr, %function;
|
||||
___tls_get_addr:
|
||||
#endif
|
||||
#ifdef PTR32
|
||||
#ifdef TIME32
|
||||
.globl __adjtime64
|
||||
.type __adjtime64, %function;
|
||||
__adjtime64:
|
||||
.globl __adjtimex_time64
|
||||
.type __adjtimex_time64, %function;
|
||||
__adjtimex_time64:
|
||||
#endif
|
||||
#ifdef ARCH_arm
|
||||
.globl __aeabi_atexit
|
||||
.type __aeabi_atexit, %function;
|
||||
__aeabi_atexit:
|
||||
.globl __aeabi_memclr
|
||||
.type __aeabi_memclr, %function;
|
||||
__aeabi_memclr:
|
||||
.globl __aeabi_memclr4
|
||||
.type __aeabi_memclr4, %function;
|
||||
__aeabi_memclr4:
|
||||
.globl __aeabi_memclr8
|
||||
.type __aeabi_memclr8, %function;
|
||||
__aeabi_memclr8:
|
||||
.globl __aeabi_memcpy
|
||||
.type __aeabi_memcpy, %function;
|
||||
__aeabi_memcpy:
|
||||
.globl __aeabi_memcpy4
|
||||
.type __aeabi_memcpy4, %function;
|
||||
__aeabi_memcpy4:
|
||||
.globl __aeabi_memcpy8
|
||||
.type __aeabi_memcpy8, %function;
|
||||
__aeabi_memcpy8:
|
||||
.globl __aeabi_memmove
|
||||
.type __aeabi_memmove, %function;
|
||||
__aeabi_memmove:
|
||||
.globl __aeabi_memmove4
|
||||
.type __aeabi_memmove4, %function;
|
||||
__aeabi_memmove4:
|
||||
.globl __aeabi_memmove8
|
||||
.type __aeabi_memmove8, %function;
|
||||
__aeabi_memmove8:
|
||||
.globl __aeabi_memset
|
||||
.type __aeabi_memset, %function;
|
||||
__aeabi_memset:
|
||||
.globl __aeabi_memset4
|
||||
.type __aeabi_memset4, %function;
|
||||
__aeabi_memset4:
|
||||
.globl __aeabi_memset8
|
||||
.type __aeabi_memset8, %function;
|
||||
__aeabi_memset8:
|
||||
.globl __aeabi_read_tp
|
||||
.type __aeabi_read_tp, %function;
|
||||
__aeabi_read_tp:
|
||||
#endif
|
||||
#ifdef TIME32
|
||||
.globl __aio_suspend_time64
|
||||
.type __aio_suspend_time64, %function;
|
||||
__aio_suspend_time64:
|
||||
@@ -187,12 +240,12 @@ __aio_suspend_time64:
|
||||
.globl __assert_fail
|
||||
.type __assert_fail, %function;
|
||||
__assert_fail:
|
||||
#if !defined(ARCH_riscv64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64) && !defined(ARCH_riscv32) && !defined(ARCH_loongarch64)
|
||||
#ifdef FAMILY_mips
|
||||
.globl __cachectl
|
||||
.type __cachectl, %function;
|
||||
__cachectl:
|
||||
#endif
|
||||
#ifdef PTR32
|
||||
#ifdef TIME32
|
||||
.globl __clock_adjtime64
|
||||
.type __clock_adjtime64, %function;
|
||||
__clock_adjtime64:
|
||||
@@ -236,7 +289,7 @@ __cxa_atexit:
|
||||
.globl __cxa_finalize
|
||||
.type __cxa_finalize, %function;
|
||||
__cxa_finalize:
|
||||
#ifdef PTR32
|
||||
#ifdef TIME32
|
||||
.globl __difftime64
|
||||
.type __difftime64, %function;
|
||||
__difftime64:
|
||||
@@ -247,7 +300,12 @@ __dls2b:
|
||||
.globl __dls3
|
||||
.type __dls3, %function;
|
||||
__dls3:
|
||||
#ifdef PTR32
|
||||
#ifdef FAMILY_mips
|
||||
.globl __dlstart
|
||||
.type __dlstart, %function;
|
||||
__dlstart:
|
||||
#endif
|
||||
#ifdef TIME32
|
||||
.globl __dlsym_time64
|
||||
.type __dlsym_time64, %function;
|
||||
__dlsym_time64:
|
||||
@@ -312,7 +370,7 @@ __fseterr:
|
||||
.globl __fsetlocking
|
||||
.type __fsetlocking, %function;
|
||||
__fsetlocking:
|
||||
#ifdef PTR32
|
||||
#ifdef TIME32
|
||||
.weak __fstat_time64
|
||||
.type __fstat_time64, %function;
|
||||
__fstat_time64:
|
||||
@@ -347,7 +405,7 @@ __fxstatat:
|
||||
.weak __getdelim
|
||||
.type __getdelim, %function;
|
||||
__getdelim:
|
||||
#ifdef PTR32
|
||||
#ifdef TIME32
|
||||
.globl __getitimer_time64
|
||||
.type __getitimer_time64, %function;
|
||||
__getitimer_time64:
|
||||
@@ -364,6 +422,11 @@ __gmtime64:
|
||||
.type __gmtime64_r, %function;
|
||||
__gmtime64_r:
|
||||
#endif
|
||||
#ifdef ARCH_arm
|
||||
.globl __gnu_Unwind_Find_exidx
|
||||
.type __gnu_Unwind_Find_exidx, %function;
|
||||
__gnu_Unwind_Find_exidx:
|
||||
#endif
|
||||
.globl __h_errno_location
|
||||
.type __h_errno_location, %function;
|
||||
__h_errno_location:
|
||||
@@ -490,7 +553,7 @@ __libc_current_sigrtmin:
|
||||
.globl __libc_start_main
|
||||
.type __libc_start_main, %function;
|
||||
__libc_start_main:
|
||||
#ifdef PTR32
|
||||
#ifdef TIME32
|
||||
.globl __localtime64
|
||||
.type __localtime64, %function;
|
||||
__localtime64:
|
||||
@@ -498,12 +561,12 @@ __localtime64:
|
||||
.type __localtime64_r, %function;
|
||||
__localtime64_r:
|
||||
#endif
|
||||
#if !defined(ARCH_mips) && !defined(ARCH_mips64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64) && !defined(ARCH_loongarch64)
|
||||
#ifdef FAMILY_riscv
|
||||
.globl __longjmp
|
||||
.type __longjmp, %function;
|
||||
__longjmp:
|
||||
#endif
|
||||
#ifdef PTR32
|
||||
#ifdef TIME32
|
||||
.globl __lstat_time64
|
||||
.type __lstat_time64, %function;
|
||||
__lstat_time64:
|
||||
@@ -514,7 +577,7 @@ __lutimes_time64:
|
||||
.globl __lxstat
|
||||
.type __lxstat, %function;
|
||||
__lxstat:
|
||||
#ifdef PTR32
|
||||
#ifdef TIME32
|
||||
.globl __mktime64
|
||||
.type __mktime64, %function;
|
||||
__mktime64:
|
||||
@@ -547,7 +610,7 @@ __overflow:
|
||||
.weak __posix_getopt
|
||||
.type __posix_getopt, %function;
|
||||
__posix_getopt:
|
||||
#ifdef PTR32
|
||||
#ifdef TIME32
|
||||
.globl __ppoll_time64
|
||||
.type __ppoll_time64, %function;
|
||||
__ppoll_time64:
|
||||
@@ -576,17 +639,7 @@ __recvmmsg_time64:
|
||||
.globl __res_state
|
||||
.type __res_state, %function;
|
||||
__res_state:
|
||||
#if !defined(ARCH_mips) && !defined(ARCH_mips64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64) && !defined(ARCH_riscv32) && !defined(ARCH_loongarch64)
|
||||
.globl __restore
|
||||
.type __restore, %function;
|
||||
__restore:
|
||||
#endif
|
||||
#if !defined(ARCH_mips) && !defined(ARCH_mips64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64) && !defined(ARCH_riscv32) && !defined(ARCH_loongarch64)
|
||||
.globl __restore_rt
|
||||
.type __restore_rt, %function;
|
||||
__restore_rt:
|
||||
#endif
|
||||
#if !defined(ARCH_mips) && !defined(ARCH_mips64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64) && !defined(ARCH_loongarch64)
|
||||
#ifdef FAMILY_riscv
|
||||
.globl __riscv_flush_icache
|
||||
.type __riscv_flush_icache, %function;
|
||||
__riscv_flush_icache:
|
||||
@@ -594,7 +647,7 @@ __riscv_flush_icache:
|
||||
.globl __sched_cpucount
|
||||
.type __sched_cpucount, %function;
|
||||
__sched_cpucount:
|
||||
#ifdef PTR32
|
||||
#ifdef TIME32
|
||||
.globl __sched_rr_get_interval_time64
|
||||
.type __sched_rr_get_interval_time64, %function;
|
||||
__sched_rr_get_interval_time64:
|
||||
@@ -614,7 +667,7 @@ __setitimer_time64:
|
||||
.globl __setjmp
|
||||
.type __setjmp, %function;
|
||||
__setjmp:
|
||||
#ifdef PTR32
|
||||
#ifdef TIME32
|
||||
.globl __settimeofday_time64
|
||||
.type __settimeofday_time64, %function;
|
||||
__settimeofday_time64:
|
||||
@@ -631,7 +684,7 @@ __signbitl:
|
||||
.globl __sigsetjmp
|
||||
.type __sigsetjmp, %function;
|
||||
__sigsetjmp:
|
||||
#ifdef PTR32
|
||||
#ifdef TIME32
|
||||
.globl __sigtimedwait_time64
|
||||
.type __sigtimedwait_time64, %function;
|
||||
__sigtimedwait_time64:
|
||||
@@ -639,7 +692,7 @@ __sigtimedwait_time64:
|
||||
.globl __stack_chk_fail
|
||||
.type __stack_chk_fail, %function;
|
||||
__stack_chk_fail:
|
||||
#ifdef PTR32
|
||||
#ifdef TIME32
|
||||
.globl __stat_time64
|
||||
.type __stat_time64, %function;
|
||||
__stat_time64:
|
||||
@@ -692,7 +745,7 @@ __strxfrm_l:
|
||||
.weak __sysv_signal
|
||||
.type __sysv_signal, %function;
|
||||
__sysv_signal:
|
||||
#ifdef PTR32
|
||||
#ifdef TIME32
|
||||
.globl __thrd_sleep_time64
|
||||
.type __thrd_sleep_time64, %function;
|
||||
__thrd_sleep_time64:
|
||||
@@ -718,9 +771,16 @@ __timerfd_settime64:
|
||||
.type __timespec_get_time64, %function;
|
||||
__timespec_get_time64:
|
||||
#endif
|
||||
#if !defined(ARCH_s390x)
|
||||
.globl __tls_get_addr
|
||||
.type __tls_get_addr, %function;
|
||||
__tls_get_addr:
|
||||
#endif
|
||||
#ifdef ARCH_s390x
|
||||
.globl __tls_get_offset
|
||||
.type __tls_get_offset, %function;
|
||||
__tls_get_offset:
|
||||
#endif
|
||||
.globl __tolower_l
|
||||
.type __tolower_l, %function;
|
||||
__tolower_l:
|
||||
@@ -743,7 +803,7 @@ __uflow:
|
||||
.globl __uselocale
|
||||
.type __uselocale, %function;
|
||||
__uselocale:
|
||||
#ifdef PTR32
|
||||
#ifdef TIME32
|
||||
.globl __utime64
|
||||
.type __utime64, %function;
|
||||
__utime64:
|
||||
@@ -796,7 +856,7 @@ _dl_debug_state:
|
||||
.globl _dlstart
|
||||
.type _dlstart, %function;
|
||||
_dlstart:
|
||||
#if !defined(ARCH_riscv64) && !defined(ARCH_mips) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64) && !defined(ARCH_riscv32) && !defined(ARCH_loongarch64)
|
||||
#ifdef FAMILY_mips
|
||||
.globl _dlstart_data
|
||||
.type _dlstart_data, %function;
|
||||
_dlstart_data:
|
||||
@@ -807,7 +867,7 @@ _exit:
|
||||
.weak _fini
|
||||
.type _fini, %function;
|
||||
_fini:
|
||||
#if !defined(ARCH_riscv64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64) && !defined(ARCH_riscv32) && !defined(ARCH_loongarch64)
|
||||
#ifdef FAMILY_mips
|
||||
.globl _flush_cache
|
||||
.type _flush_cache, %function;
|
||||
_flush_cache:
|
||||
@@ -908,7 +968,7 @@ aligned_alloc:
|
||||
.globl alphasort
|
||||
.type alphasort, %function;
|
||||
alphasort:
|
||||
#if !defined(ARCH_riscv64) && !defined(ARCH_mips) && !defined(ARCH_mips64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64) && !defined(ARCH_riscv32) && !defined(ARCH_loongarch64)
|
||||
#ifdef FAMILY_x86
|
||||
.globl arch_prctl
|
||||
.type arch_prctl, %function;
|
||||
arch_prctl:
|
||||
@@ -1033,12 +1093,10 @@ cabsf:
|
||||
.globl cabsl
|
||||
.type cabsl, %function;
|
||||
cabsl:
|
||||
#if !defined(ARCH_riscv64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64) && !defined(ARCH_riscv32) && !defined(ARCH_loongarch64)
|
||||
#ifdef FAMILY_mips
|
||||
.weak cachectl
|
||||
.type cachectl, %function;
|
||||
cachectl:
|
||||
#endif
|
||||
#if !defined(ARCH_riscv64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64) && !defined(ARCH_riscv32) && !defined(ARCH_loongarch64)
|
||||
.weak cacheflush
|
||||
.type cacheflush, %function;
|
||||
cacheflush:
|
||||
@@ -1232,10 +1290,10 @@ clock_getcpuclockid:
|
||||
.globl clock_getres
|
||||
.type clock_getres, %function;
|
||||
clock_getres:
|
||||
WEAK64 clock_gettime
|
||||
WEAKTIME64 clock_gettime
|
||||
.type clock_gettime, %function;
|
||||
clock_gettime:
|
||||
WEAK64 clock_nanosleep
|
||||
WEAKTIME64 clock_nanosleep
|
||||
.type clock_nanosleep, %function;
|
||||
clock_nanosleep:
|
||||
.globl clock_settime
|
||||
@@ -2018,10 +2076,10 @@ fsetpos:
|
||||
.globl fsetxattr
|
||||
.type fsetxattr, %function;
|
||||
fsetxattr:
|
||||
WEAK64 fstat
|
||||
WEAKTIME64 fstat
|
||||
.type fstat, %function;
|
||||
fstat:
|
||||
WEAK64 fstatat
|
||||
WEAKTIME64 fstatat
|
||||
.type fstatat, %function;
|
||||
fstatat:
|
||||
.weak fstatfs
|
||||
@@ -2063,7 +2121,7 @@ futimens:
|
||||
.globl futimes
|
||||
.type futimes, %function;
|
||||
futimes:
|
||||
WEAK64 futimesat
|
||||
WEAKTIME64 futimesat
|
||||
.type futimesat, %function;
|
||||
futimesat:
|
||||
.globl fwide
|
||||
@@ -2408,7 +2466,7 @@ globfree:
|
||||
.globl gmtime
|
||||
.type gmtime, %function;
|
||||
gmtime:
|
||||
WEAK64 gmtime_r
|
||||
WEAKTIME64 gmtime_r
|
||||
.type gmtime_r, %function;
|
||||
gmtime_r:
|
||||
.globl grantpt
|
||||
@@ -2549,12 +2607,12 @@ insque:
|
||||
.globl ioctl
|
||||
.type ioctl, %function;
|
||||
ioctl:
|
||||
#if !defined(ARCH_riscv64) && !defined(ARCH_mips64) && !defined(ARCH_aarch64) && !defined(ARCH_riscv32) && !defined(ARCH_loongarch64)
|
||||
#if !defined(ARCH_aarch64) && !defined(ARCH_arm) && !defined(ARCH_loongarch64) && !defined(ARCH_mips64) && !defined(ARCH_mipsn32) && !defined(ARCH_riscv32) && !defined(ARCH_riscv64) && !defined(ARCH_s390x)
|
||||
.globl ioperm
|
||||
.type ioperm, %function;
|
||||
ioperm:
|
||||
#endif
|
||||
#if !defined(ARCH_riscv64) && !defined(ARCH_mips64) && !defined(ARCH_aarch64) && !defined(ARCH_riscv32) && !defined(ARCH_loongarch64)
|
||||
#if !defined(ARCH_aarch64) && !defined(ARCH_arm) && !defined(ARCH_loongarch64) && !defined(ARCH_mips64) && !defined(ARCH_mipsn32) && !defined(ARCH_riscv32) && !defined(ARCH_riscv64) && !defined(ARCH_s390x)
|
||||
.globl iopl
|
||||
.type iopl, %function;
|
||||
iopl:
|
||||
@@ -2853,7 +2911,7 @@ localeconv:
|
||||
.globl localtime
|
||||
.type localtime, %function;
|
||||
localtime:
|
||||
WEAK64 localtime_r
|
||||
WEAKTIME64 localtime_r
|
||||
.type localtime_r, %function;
|
||||
localtime_r:
|
||||
.globl lockf
|
||||
@@ -3552,7 +3610,7 @@ pthread_cond_init:
|
||||
.globl pthread_cond_signal
|
||||
.type pthread_cond_signal, %function;
|
||||
pthread_cond_signal:
|
||||
WEAK64 pthread_cond_timedwait
|
||||
WEAKTIME64 pthread_cond_timedwait
|
||||
.type pthread_cond_timedwait, %function;
|
||||
pthread_cond_timedwait:
|
||||
.globl pthread_cond_wait
|
||||
@@ -3642,7 +3700,7 @@ pthread_mutex_lock:
|
||||
.globl pthread_mutex_setprioceiling
|
||||
.type pthread_mutex_setprioceiling, %function;
|
||||
pthread_mutex_setprioceiling:
|
||||
WEAK64 pthread_mutex_timedlock
|
||||
WEAKTIME64 pthread_mutex_timedlock
|
||||
.type pthread_mutex_timedlock, %function;
|
||||
pthread_mutex_timedlock:
|
||||
.weak pthread_mutex_trylock
|
||||
@@ -3693,10 +3751,10 @@ pthread_rwlock_init:
|
||||
.weak pthread_rwlock_rdlock
|
||||
.type pthread_rwlock_rdlock, %function;
|
||||
pthread_rwlock_rdlock:
|
||||
WEAK64 pthread_rwlock_timedrdlock
|
||||
WEAKTIME64 pthread_rwlock_timedrdlock
|
||||
.type pthread_rwlock_timedrdlock, %function;
|
||||
pthread_rwlock_timedrdlock:
|
||||
WEAK64 pthread_rwlock_timedwrlock
|
||||
WEAKTIME64 pthread_rwlock_timedwrlock
|
||||
.type pthread_rwlock_timedwrlock, %function;
|
||||
pthread_rwlock_timedwrlock:
|
||||
.weak pthread_rwlock_tryrdlock
|
||||
@@ -3774,7 +3832,7 @@ pthread_spin_unlock:
|
||||
.weak pthread_testcancel
|
||||
.type pthread_testcancel, %function;
|
||||
pthread_testcancel:
|
||||
WEAK64 pthread_timedjoin_np
|
||||
WEAKTIME64 pthread_timedjoin_np
|
||||
.type pthread_timedjoin_np, %function;
|
||||
pthread_timedjoin_np:
|
||||
.weak pthread_tryjoin_np
|
||||
@@ -3999,7 +4057,7 @@ rintf:
|
||||
.globl rintl
|
||||
.type rintl, %function;
|
||||
rintl:
|
||||
#if !defined(ARCH_mips) && !defined(ARCH_mips64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64) && !defined(ARCH_loongarch64)
|
||||
#ifdef FAMILY_riscv
|
||||
.weak riscv_flush_icache
|
||||
.type riscv_flush_icache, %function;
|
||||
riscv_flush_icache:
|
||||
|
||||
+2
@@ -1,7 +1,9 @@
|
||||
.global __restore
|
||||
.hidden __restore
|
||||
.type __restore, %function
|
||||
__restore:
|
||||
.global __restore_rt
|
||||
.hidden __restore_rt
|
||||
.type __restore_rt, %function
|
||||
__restore_rt:
|
||||
li a7, 139 # SYS_rt_sigreturn
|
||||
|
||||
+2
@@ -1,7 +1,9 @@
|
||||
.global __restore
|
||||
.hidden __restore
|
||||
.type __restore, %function
|
||||
__restore:
|
||||
.global __restore_rt
|
||||
.hidden __restore_rt
|
||||
.type __restore_rt, %function
|
||||
__restore_rt:
|
||||
li a7, 139 # SYS_rt_sigreturn
|
||||
|
||||
@@ -5,6 +5,7 @@ __tls_get_offset:
|
||||
aghi %r15, -160
|
||||
|
||||
la %r2, 0(%r2, %r12)
|
||||
.hidden __tls_get_addr
|
||||
brasl %r14, __tls_get_addr
|
||||
|
||||
ear %r1, %a0
|
||||
|
||||
+3
-1
@@ -5884,7 +5884,9 @@ pub const FileExt = enum {
|
||||
};
|
||||
|
||||
pub fn hasObjectExt(filename: []const u8) bool {
|
||||
return mem.endsWith(u8, filename, ".o") or mem.endsWith(u8, filename, ".obj");
|
||||
return mem.endsWith(u8, filename, ".o") or
|
||||
mem.endsWith(u8, filename, ".lo") or
|
||||
mem.endsWith(u8, filename, ".obj");
|
||||
}
|
||||
|
||||
pub fn hasStaticLibraryExt(filename: []const u8) bool {
|
||||
|
||||
+33
-16
@@ -138,17 +138,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
|
||||
try addSrcFile(arena, &source_table, src_file);
|
||||
}
|
||||
|
||||
const time32_compat_arch_list = [_][]const u8{
|
||||
"arm",
|
||||
"i386",
|
||||
"m68k",
|
||||
"microblaze",
|
||||
"mips",
|
||||
"mipsn32",
|
||||
"or1k",
|
||||
"powerpc",
|
||||
"sh",
|
||||
};
|
||||
for (time32_compat_arch_list) |time32_compat_arch| {
|
||||
if (mem.eql(u8, arch_name, time32_compat_arch)) {
|
||||
for (compat_time32_files) |compat_time32_file| {
|
||||
@@ -239,13 +228,29 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
|
||||
});
|
||||
|
||||
const target = comp.root_mod.resolved_target.result;
|
||||
const arch_define = try std.fmt.allocPrint(arena, "-DARCH_{s}", .{
|
||||
@tagName(target.cpu.arch),
|
||||
});
|
||||
const arch_name = std.zig.target.muslArchName(target.cpu.arch, target.abi);
|
||||
const time32 = for (time32_compat_arch_list) |time32_compat_arch| {
|
||||
if (mem.eql(u8, arch_name, time32_compat_arch)) break true;
|
||||
} else false;
|
||||
const arch_define = try std.fmt.allocPrint(arena, "-DARCH_{s}", .{arch_name});
|
||||
const family_define = switch (target.cpu.arch) {
|
||||
.arm, .armeb, .thumb, .thumbeb => "-DFAMILY_arm",
|
||||
.aarch64, .aarch64_be => "-DFAMILY_aarch64",
|
||||
.loongarch64 => "-DFAMILY_loongarch",
|
||||
.m68k => "-DFAMILY_m68k",
|
||||
.mips, .mipsel, .mips64, .mips64el => "-DFAMILY_mips",
|
||||
.powerpc, .powerpc64, .powerpc64le => "-DFAMILY_powerpc",
|
||||
.riscv32, .riscv64 => "-DFAMILY_riscv",
|
||||
.s390x => "-DFAMILY_s390x",
|
||||
.x86, .x86_64 => "-DFAMILY_x86",
|
||||
else => unreachable,
|
||||
};
|
||||
const cc_argv: []const []const u8 = if (target.ptrBitWidth() == 64)
|
||||
&.{ "-DPTR64", arch_define }
|
||||
&.{ "-DPTR64", arch_define, family_define }
|
||||
else if (time32)
|
||||
&.{ "-DTIME32", arch_define, family_define }
|
||||
else
|
||||
&.{arch_define};
|
||||
&.{ arch_define, family_define };
|
||||
|
||||
const root_mod = try Module.create(arena, .{
|
||||
.global_cache_directory = comp.global_cache_directory,
|
||||
@@ -347,6 +352,18 @@ pub fn needsCrt0(output_mode: std.builtin.OutputMode, link_mode: std.builtin.Lin
|
||||
};
|
||||
}
|
||||
|
||||
const time32_compat_arch_list = [_][]const u8{
|
||||
"arm",
|
||||
"i386",
|
||||
"m68k",
|
||||
"microblaze",
|
||||
"mips",
|
||||
"mipsn32",
|
||||
"or1k",
|
||||
"powerpc",
|
||||
"sh",
|
||||
};
|
||||
|
||||
fn isArchName(name: []const u8) bool {
|
||||
const musl_arch_names = [_][]const u8{
|
||||
"aarch64",
|
||||
|
||||
+241
-681
@@ -2,23 +2,51 @@
|
||||
//! ./gen_stubs /path/to/musl/build-all >libc.S
|
||||
//!
|
||||
//! The directory 'build-all' is expected to contain these subdirectories:
|
||||
//! arm x86 mips mips64 powerpc powerpc64 riscv32 riscv64 x86_64 loongarch64
|
||||
//!
|
||||
//! * aarch64
|
||||
//! * arm
|
||||
//! * i386
|
||||
//! * loongarch64
|
||||
//! * mips
|
||||
//! * mips64
|
||||
//! * mipsn32
|
||||
//! * powerpc
|
||||
//! * powerpc64
|
||||
//! * riscv32
|
||||
//! * riscv64
|
||||
//! * s390x
|
||||
//! * x32 (currently broken)
|
||||
//! * x86_64
|
||||
//!
|
||||
//! ...each with 'lib/libc.so' inside of them.
|
||||
//!
|
||||
//! When building the resulting libc.S file, these defines are required:
|
||||
//! * `-DPTR64`: when the architecture is 64-bit
|
||||
//! * `-DTIME32`: When the target's primary time ABI is 32-bit
|
||||
//! * `-DPTR64`: When the target has 64-bit pointers
|
||||
//! * One of the following, corresponding to the CPU architecture:
|
||||
//! - `-DARCH_riscv32`
|
||||
//! - `-DARCH_riscv64`
|
||||
//! - `-DARCH_aarch64`
|
||||
//! - `-DARCH_arm`
|
||||
//! - `-DARCH_i386`
|
||||
//! - `-DARCH_loongarch64`
|
||||
//! - `-DARCH_mips`
|
||||
//! - `-DARCH_mips64`
|
||||
//! - `-DARCH_i386`
|
||||
//! - `-DARCH_x86_64`
|
||||
//! - `-DARCH_mipsn32`
|
||||
//! - `-DARCH_powerpc`
|
||||
//! - `-DARCH_powerpc64`
|
||||
//! - `-DARCH_aarch64`
|
||||
//! - `-DARCH_loongarch64`
|
||||
//! - `-DARCH_riscv32`
|
||||
//! - `-DARCH_riscv64`
|
||||
//! - `-DARCH_s390x`
|
||||
//! - `-DARCH_x32`
|
||||
//! - `-DARCH_x86_64`
|
||||
//! * One of the following, corresponding to the CPU architecture family:
|
||||
//! - `-DFAMILY_aarch64`
|
||||
//! - `-DFAMILY_arm`
|
||||
//! - `-DFAMILY_loongarch`
|
||||
//! - `-DFAMILY_mips`
|
||||
//! - `-DFAMILY_powerpc`
|
||||
//! - `-DFAMILY_riscv`
|
||||
//! - `-DFAMILY_s390x`
|
||||
//! - `-DFAMILY_x86`
|
||||
|
||||
// TODO: pick the best index to put them into instead of at the end
|
||||
// - e.g. find a common previous symbol and put it after that one
|
||||
@@ -29,24 +57,85 @@ const builtin = std.builtin;
|
||||
const mem = std.mem;
|
||||
const log = std.log;
|
||||
const elf = std.elf;
|
||||
const native_endian = @import("builtin").target.cpu.arch.endian();
|
||||
const native_endian = @import("builtin").cpu.arch.endian();
|
||||
|
||||
const inputs = .{
|
||||
.riscv32,
|
||||
.riscv64,
|
||||
.loongarch64,
|
||||
.mips,
|
||||
.mips64,
|
||||
.x86,
|
||||
.x86_64,
|
||||
.powerpc,
|
||||
.powerpc64,
|
||||
.aarch64,
|
||||
const Arch = enum {
|
||||
aarch64,
|
||||
arm,
|
||||
i386,
|
||||
loongarch64,
|
||||
mips,
|
||||
mips64,
|
||||
mipsn32,
|
||||
powerpc,
|
||||
powerpc64,
|
||||
riscv32,
|
||||
riscv64,
|
||||
s390x,
|
||||
x86_64,
|
||||
|
||||
pub fn ptrSize(arch: Arch) u16 {
|
||||
return switch (arch) {
|
||||
.arm,
|
||||
.i386,
|
||||
.mips,
|
||||
.mipsn32,
|
||||
.powerpc,
|
||||
.riscv32,
|
||||
=> 4,
|
||||
.aarch64,
|
||||
.loongarch64,
|
||||
.mips64,
|
||||
.powerpc64,
|
||||
.riscv64,
|
||||
.s390x,
|
||||
.x86_64,
|
||||
=> 8,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn isTime32(arch: Arch) bool {
|
||||
return switch (arch) {
|
||||
// This list will never grow; newer 32-bit ports will be time64 (e.g. riscv32).
|
||||
.arm,
|
||||
.i386,
|
||||
.mips,
|
||||
.mipsn32,
|
||||
.powerpc,
|
||||
=> true,
|
||||
else => false,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn family(arch: Arch) Family {
|
||||
return switch (arch) {
|
||||
.aarch64 => .aarch64,
|
||||
.arm => .arm,
|
||||
.i386, .x86_64 => .x86,
|
||||
.loongarch64 => .loongarch,
|
||||
.mips, .mips64, .mipsn32 => .mips,
|
||||
.powerpc, .powerpc64 => .powerpc,
|
||||
.riscv32, .riscv64 => .riscv,
|
||||
.s390x => .s390x,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const arches: [inputs.len]std.Target.Cpu.Arch = blk: {
|
||||
var result: [inputs.len]std.Target.Cpu.Arch = undefined;
|
||||
for (inputs) |arch| {
|
||||
const Family = enum {
|
||||
aarch64,
|
||||
arm,
|
||||
loongarch,
|
||||
mips,
|
||||
powerpc,
|
||||
riscv,
|
||||
s390x,
|
||||
x86,
|
||||
};
|
||||
|
||||
const arches: [@typeInfo(Arch).@"enum".fields.len]Arch = blk: {
|
||||
var result: [@typeInfo(Arch).@"enum".fields.len]Arch = undefined;
|
||||
for (@typeInfo(Arch).@"enum".fields) |field| {
|
||||
const arch: Arch = @enumFromInt(field.value);
|
||||
result[archIndex(arch)] = arch;
|
||||
}
|
||||
break :blk result;
|
||||
@@ -60,6 +149,31 @@ const MultiSym = struct {
|
||||
ty: u4,
|
||||
visib: elf.STV,
|
||||
|
||||
fn isSingleArch(ms: MultiSym) ?Arch {
|
||||
var result: ?Arch = null;
|
||||
inline for (@typeInfo(Arch).@"enum".fields) |field| {
|
||||
const arch: Arch = @enumFromInt(field.value);
|
||||
if (ms.present[archIndex(arch)]) {
|
||||
if (result != null) return null;
|
||||
result = arch;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
fn isFamily(ms: MultiSym) ?Family {
|
||||
var result: ?Family = null;
|
||||
inline for (@typeInfo(Arch).@"enum".fields) |field| {
|
||||
const arch: Arch = @enumFromInt(field.value);
|
||||
if (ms.present[archIndex(arch)]) {
|
||||
const family = arch.family();
|
||||
if (result) |r| if (family != r) return null;
|
||||
result = family;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
fn allPresent(ms: MultiSym) bool {
|
||||
for (arches, 0..) |_, i| {
|
||||
if (!ms.present[i]) {
|
||||
@@ -69,17 +183,14 @@ const MultiSym = struct {
|
||||
return true;
|
||||
}
|
||||
|
||||
fn is32Only(ms: MultiSym) bool {
|
||||
return ms.present[archIndex(.riscv32)] == true and
|
||||
ms.present[archIndex(.riscv64)] == false and
|
||||
ms.present[archIndex(.mips)] == true and
|
||||
ms.present[archIndex(.mips64)] == false and
|
||||
ms.present[archIndex(.x86)] == true and
|
||||
ms.present[archIndex(.x86_64)] == false and
|
||||
ms.present[archIndex(.powerpc)] == true and
|
||||
ms.present[archIndex(.powerpc64)] == false and
|
||||
ms.present[archIndex(.aarch64)] == false and
|
||||
ms.present[archIndex(.loongarch64)] == false;
|
||||
fn isTime32Only(ms: MultiSym) bool {
|
||||
inline for (@typeInfo(Arch).@"enum".fields) |field| {
|
||||
const arch: Arch = @enumFromInt(field.value);
|
||||
if (ms.present[archIndex(arch)] != arch.isTime32()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
fn commonSize(ms: MultiSym) ?u64 {
|
||||
@@ -112,48 +223,11 @@ const MultiSym = struct {
|
||||
return binding.?;
|
||||
}
|
||||
|
||||
fn isPtrSize(ms: MultiSym) bool {
|
||||
const map = .{
|
||||
.{ .riscv32, 4 },
|
||||
.{ .riscv64, 8 },
|
||||
.{ .mips, 4 },
|
||||
.{ .mips64, 8 },
|
||||
.{ .x86, 4 },
|
||||
.{ .x86_64, 8 },
|
||||
.{ .powerpc, 4 },
|
||||
.{ .powerpc64, 8 },
|
||||
.{ .aarch64, 8 },
|
||||
.{ .loongarch64, 8 },
|
||||
};
|
||||
inline for (map) |item| {
|
||||
const arch = item[0];
|
||||
const size = item[1];
|
||||
fn isPtrSize(ms: MultiSym, mult: u16) bool {
|
||||
inline for (@typeInfo(Arch).@"enum".fields) |field| {
|
||||
const arch: Arch = @enumFromInt(field.value);
|
||||
const arch_index = archIndex(arch);
|
||||
if (ms.present[arch_index] and ms.size[arch_index] != size) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
fn isPtr2Size(ms: MultiSym) bool {
|
||||
const map = .{
|
||||
.{ .riscv32, 8 },
|
||||
.{ .riscv64, 16 },
|
||||
.{ .mips, 8 },
|
||||
.{ .mips64, 16 },
|
||||
.{ .x86, 8 },
|
||||
.{ .x86_64, 16 },
|
||||
.{ .powerpc, 8 },
|
||||
.{ .powerpc64, 16 },
|
||||
.{ .aarch64, 16 },
|
||||
.{ .loongarch64, 16 },
|
||||
};
|
||||
inline for (map) |item| {
|
||||
const arch = item[0];
|
||||
const size = item[1];
|
||||
const arch_index = archIndex(arch);
|
||||
if (ms.present[arch_index] and ms.size[arch_index] != size) {
|
||||
if (ms.present[arch_index] and ms.size[arch_index] != arch.ptrSize() * mult) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -161,22 +235,26 @@ const MultiSym = struct {
|
||||
}
|
||||
|
||||
fn isWeak64(ms: MultiSym) bool {
|
||||
const map = .{
|
||||
.{ .riscv32, 1 },
|
||||
.{ .riscv64, 2 },
|
||||
.{ .mips, 1 },
|
||||
.{ .mips64, 2 },
|
||||
.{ .x86, 1 },
|
||||
.{ .x86_64, 2 },
|
||||
.{ .powerpc, 1 },
|
||||
.{ .powerpc64, 2 },
|
||||
.{ .aarch64, 2 },
|
||||
.{ .loongarch64, 2 },
|
||||
};
|
||||
inline for (map) |item| {
|
||||
const arch = item[0];
|
||||
const binding = item[1];
|
||||
inline for (@typeInfo(Arch).@"enum".fields) |field| {
|
||||
const arch: Arch = @enumFromInt(field.value);
|
||||
const arch_index = archIndex(arch);
|
||||
const binding: u4 = switch (arch.ptrSize()) {
|
||||
4 => std.elf.STB_GLOBAL,
|
||||
8 => std.elf.STB_WEAK,
|
||||
else => unreachable,
|
||||
};
|
||||
if (ms.present[arch_index] and ms.binding[arch_index] != binding) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
fn isWeakTime64(ms: MultiSym) bool {
|
||||
inline for (@typeInfo(Arch).@"enum".fields) |field| {
|
||||
const arch: Arch = @enumFromInt(field.value);
|
||||
const arch_index = archIndex(arch);
|
||||
const binding: u4 = if (arch.isTime32()) std.elf.STB_GLOBAL else std.elf.STB_WEAK;
|
||||
if (ms.present[arch_index] and ms.binding[arch_index] != binding) {
|
||||
return false;
|
||||
}
|
||||
@@ -189,10 +267,9 @@ const Parse = struct {
|
||||
arena: mem.Allocator,
|
||||
sym_table: *std.StringArrayHashMap(MultiSym),
|
||||
sections: *std.StringArrayHashMap(void),
|
||||
blacklist: std.StringArrayHashMap(void),
|
||||
elf_bytes: []align(@alignOf(elf.Elf64_Ehdr)) u8,
|
||||
header: elf.Header,
|
||||
arch: std.Target.Cpu.Arch,
|
||||
arch: Arch,
|
||||
};
|
||||
|
||||
pub fn main() !void {
|
||||
@@ -207,16 +284,10 @@ pub fn main() !void {
|
||||
|
||||
var sym_table = std.StringArrayHashMap(MultiSym).init(arena);
|
||||
var sections = std.StringArrayHashMap(void).init(arena);
|
||||
var blacklist = std.StringArrayHashMap(void).init(arena);
|
||||
|
||||
try blacklist.ensureUnusedCapacity(blacklisted_symbols.len);
|
||||
for (blacklisted_symbols) |name| {
|
||||
blacklist.putAssumeCapacityNoClobber(name, {});
|
||||
}
|
||||
|
||||
for (arches) |arch| {
|
||||
const libc_so_path = try std.fmt.allocPrint(arena, "{s}/lib/libc.so", .{
|
||||
archMuslName(arch),
|
||||
@tagName(arch),
|
||||
});
|
||||
|
||||
// Read the ELF header.
|
||||
@@ -238,7 +309,6 @@ pub fn main() !void {
|
||||
.arena = arena,
|
||||
.sym_table = &sym_table,
|
||||
.sections = §ions,
|
||||
.blacklist = blacklist,
|
||||
.elf_bytes = elf_bytes,
|
||||
.header = header,
|
||||
.arch = arch,
|
||||
@@ -268,6 +338,13 @@ pub fn main() !void {
|
||||
\\#define PTR2_SIZE_BYTES 8
|
||||
\\#endif
|
||||
\\
|
||||
\\#ifdef TIME32
|
||||
\\#define WEAKTIME64 .globl
|
||||
\\#else
|
||||
\\#define WEAKTIME64 .weak
|
||||
\\#endif
|
||||
\\
|
||||
\\
|
||||
);
|
||||
|
||||
// Sort the symbols for deterministic output and cleaner vcs diffs.
|
||||
@@ -301,7 +378,7 @@ pub fn main() !void {
|
||||
sym_table.sort(SymTableSort{ .sym_table = &sym_table, .sections = §ions });
|
||||
|
||||
var prev_section: u16 = std.math.maxInt(u16);
|
||||
var prev_pp_state: enum { none, ptr32, special } = .none;
|
||||
var prev_pp_state: union(enum) { all, single: Arch, multi, family: Family, time32 } = .all;
|
||||
for (sym_table.values(), 0..) |multi_sym, sym_index| {
|
||||
const name = sym_table.keys()[sym_index];
|
||||
|
||||
@@ -313,32 +390,66 @@ pub fn main() !void {
|
||||
|
||||
if (multi_sym.allPresent()) {
|
||||
switch (prev_pp_state) {
|
||||
.none => {},
|
||||
.ptr32, .special => {
|
||||
.all => {},
|
||||
.single, .multi, .family, .time32 => {
|
||||
try stdout.writeAll("#endif\n");
|
||||
prev_pp_state = .none;
|
||||
prev_pp_state = .all;
|
||||
},
|
||||
}
|
||||
} else if (multi_sym.is32Only()) {
|
||||
} else if (multi_sym.isSingleArch()) |arch| {
|
||||
switch (prev_pp_state) {
|
||||
.none => {
|
||||
try stdout.writeAll("#ifdef PTR32\n");
|
||||
prev_pp_state = .ptr32;
|
||||
.all => {
|
||||
try stdout.print("#ifdef ARCH_{s}\n", .{@tagName(arch)});
|
||||
prev_pp_state = .{ .single = arch };
|
||||
},
|
||||
.special => {
|
||||
try stdout.writeAll("#endif\n#ifdef PTR32\n");
|
||||
prev_pp_state = .ptr32;
|
||||
.multi, .family, .time32 => {
|
||||
try stdout.print("#endif\n#ifdef ARCH_{s}\n", .{@tagName(arch)});
|
||||
prev_pp_state = .{ .single = arch };
|
||||
},
|
||||
.ptr32 => {},
|
||||
.single => |prev_arch| {
|
||||
if (arch != prev_arch) {
|
||||
try stdout.print("#endif\n#ifdef ARCH_{s}\n", .{@tagName(arch)});
|
||||
prev_pp_state = .{ .single = arch };
|
||||
}
|
||||
},
|
||||
}
|
||||
} else if (multi_sym.isFamily()) |family| {
|
||||
switch (prev_pp_state) {
|
||||
.all => {
|
||||
try stdout.print("#ifdef FAMILY_{s}\n", .{@tagName(family)});
|
||||
prev_pp_state = .{ .family = family };
|
||||
},
|
||||
.single, .multi, .time32 => {
|
||||
try stdout.print("#endif\n#ifdef FAMILY_{s}\n", .{@tagName(family)});
|
||||
prev_pp_state = .{ .family = family };
|
||||
},
|
||||
.family => |prev_family| {
|
||||
if (family != prev_family) {
|
||||
try stdout.print("#endif\n#ifdef FAMILY_{s}\n", .{@tagName(family)});
|
||||
prev_pp_state = .{ .family = family };
|
||||
}
|
||||
},
|
||||
}
|
||||
} else if (multi_sym.isTime32Only()) {
|
||||
switch (prev_pp_state) {
|
||||
.all => {
|
||||
try stdout.writeAll("#ifdef TIME32\n");
|
||||
prev_pp_state = .time32;
|
||||
},
|
||||
.single, .multi, .family => {
|
||||
try stdout.writeAll("#endif\n#ifdef TIME32\n");
|
||||
prev_pp_state = .time32;
|
||||
},
|
||||
.time32 => {},
|
||||
}
|
||||
} else {
|
||||
switch (prev_pp_state) {
|
||||
.none => {},
|
||||
.special, .ptr32 => {
|
||||
.all => {},
|
||||
.single, .multi, .family, .time32 => {
|
||||
try stdout.writeAll("#endif\n");
|
||||
},
|
||||
}
|
||||
prev_pp_state = .special;
|
||||
prev_pp_state = .multi;
|
||||
|
||||
var first = true;
|
||||
try stdout.writeAll("#if ");
|
||||
@@ -366,6 +477,8 @@ pub fn main() !void {
|
||||
}
|
||||
} else if (multi_sym.isWeak64()) {
|
||||
try stdout.print("WEAK64 {s}\n", .{name});
|
||||
} else if (multi_sym.isWeakTime64()) {
|
||||
try stdout.print("WEAKTIME64 {s}\n", .{name});
|
||||
} else {
|
||||
for (arches, 0..) |arch, i| {
|
||||
log.info("symbol '{s}' binding on {s}: {d}", .{
|
||||
@@ -384,9 +497,9 @@ pub fn main() !void {
|
||||
try stdout.print(".type {s}, %object;\n", .{name});
|
||||
if (multi_sym.commonSize()) |size| {
|
||||
try stdout.print(".size {s}, {d}\n", .{ name, size });
|
||||
} else if (multi_sym.isPtrSize()) {
|
||||
} else if (multi_sym.isPtrSize(1)) {
|
||||
try stdout.print(".size {s}, PTR_SIZE_BYTES\n", .{name});
|
||||
} else if (multi_sym.isPtr2Size()) {
|
||||
} else if (multi_sym.isPtrSize(2)) {
|
||||
try stdout.print(".size {s}, PTR2_SIZE_BYTES\n", .{name});
|
||||
} else {
|
||||
for (arches, 0..) |arch, i| {
|
||||
@@ -410,8 +523,8 @@ pub fn main() !void {
|
||||
}
|
||||
|
||||
switch (prev_pp_state) {
|
||||
.none => {},
|
||||
.ptr32, .special => try stdout.writeAll("#endif\n"),
|
||||
.all => {},
|
||||
.single, .multi, .family, .time32 => try stdout.writeAll("#endif\n"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,12 +600,17 @@ fn parseElf(parse: Parse, comptime is_64: bool, comptime endian: builtin.Endian)
|
||||
const visib = @as(elf.STV, @enumFromInt(@as(u2, @truncate(sym.st_other))));
|
||||
const size = s(sym.st_size);
|
||||
|
||||
if (parse.blacklist.contains(name)) continue;
|
||||
|
||||
if (size == 0) {
|
||||
log.warn("{s}: symbol '{s}' has size 0", .{ @tagName(parse.arch), name });
|
||||
}
|
||||
|
||||
if (sym.st_shndx == elf.SHN_UNDEF) {
|
||||
log.debug("{s}: skipping '{s}' due to it being undefined", .{
|
||||
@tagName(parse.arch), name,
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (binding) {
|
||||
elf.STB_GLOBAL, elf.STB_WEAK => {},
|
||||
else => {
|
||||
@@ -590,40 +708,8 @@ fn parseElf(parse: Parse, comptime is_64: bool, comptime endian: builtin.Endian)
|
||||
}
|
||||
}
|
||||
|
||||
fn archIndex(arch: std.Target.Cpu.Arch) u8 {
|
||||
return switch (arch) {
|
||||
// zig fmt: off
|
||||
.riscv64 => 0,
|
||||
.mips => 1,
|
||||
.mips64 => 2,
|
||||
.x86 => 3,
|
||||
.x86_64 => 4,
|
||||
.powerpc => 5,
|
||||
.powerpc64 => 6,
|
||||
.aarch64 => 7,
|
||||
.riscv32 => 8,
|
||||
.loongarch64 => 9,
|
||||
else => unreachable,
|
||||
// zig fmt: on
|
||||
};
|
||||
}
|
||||
|
||||
fn archMuslName(arch: std.Target.Cpu.Arch) []const u8 {
|
||||
return switch (arch) {
|
||||
// zig fmt: off
|
||||
.riscv64 => "riscv64",
|
||||
.mips => "mips",
|
||||
.mips64 => "mips64",
|
||||
.x86 => "i386",
|
||||
.x86_64 => "x86_64",
|
||||
.powerpc => "powerpc",
|
||||
.powerpc64 => "powerpc64",
|
||||
.aarch64 => "aarch64",
|
||||
.riscv32 => "riscv32",
|
||||
.loongarch64 => "loongarch64",
|
||||
else => unreachable,
|
||||
// zig fmt: on
|
||||
};
|
||||
fn archIndex(arch: Arch) u8 {
|
||||
return @intFromEnum(arch);
|
||||
}
|
||||
|
||||
fn archSetName(arch_set: [arches.len]bool) []const u8 {
|
||||
@@ -639,529 +725,3 @@ fn fatal(comptime format: []const u8, args: anytype) noreturn {
|
||||
log.err(format, args);
|
||||
std.process.exit(1);
|
||||
}
|
||||
|
||||
const blacklisted_symbols = [_][]const u8{
|
||||
"__absvdi2",
|
||||
"__absvsi2",
|
||||
"__absvti2",
|
||||
"__adddf3",
|
||||
"__addkf3",
|
||||
"__addodi4",
|
||||
"__addosi4",
|
||||
"__addoti4",
|
||||
"__addsf3",
|
||||
"__addtf3",
|
||||
"__addxf3",
|
||||
"__ashldi3",
|
||||
"__ashlsi3",
|
||||
"__ashlti3",
|
||||
"__ashrdi3",
|
||||
"__ashrsi3",
|
||||
"__ashrti3",
|
||||
"__atomic_compare_exchange",
|
||||
"__atomic_compare_exchange_1",
|
||||
"__atomic_compare_exchange_2",
|
||||
"__atomic_compare_exchange_4",
|
||||
"__atomic_compare_exchange_8",
|
||||
"__atomic_exchange",
|
||||
"__atomic_exchange_1",
|
||||
"__atomic_exchange_2",
|
||||
"__atomic_exchange_4",
|
||||
"__atomic_exchange_8",
|
||||
"__atomic_fetch_add_1",
|
||||
"__atomic_fetch_add_2",
|
||||
"__atomic_fetch_add_4",
|
||||
"__atomic_fetch_add_8",
|
||||
"__atomic_fetch_and_1",
|
||||
"__atomic_fetch_and_2",
|
||||
"__atomic_fetch_and_4",
|
||||
"__atomic_fetch_and_8",
|
||||
"__atomic_fetch_nand_1",
|
||||
"__atomic_fetch_nand_2",
|
||||
"__atomic_fetch_nand_4",
|
||||
"__atomic_fetch_nand_8",
|
||||
"__atomic_fetch_or_1",
|
||||
"__atomic_fetch_or_2",
|
||||
"__atomic_fetch_or_4",
|
||||
"__atomic_fetch_or_8",
|
||||
"__atomic_fetch_sub_1",
|
||||
"__atomic_fetch_sub_2",
|
||||
"__atomic_fetch_sub_4",
|
||||
"__atomic_fetch_sub_8",
|
||||
"__atomic_fetch_xor_1",
|
||||
"__atomic_fetch_xor_2",
|
||||
"__atomic_fetch_xor_4",
|
||||
"__atomic_fetch_xor_8",
|
||||
"__atomic_load",
|
||||
"__atomic_load_1",
|
||||
"__atomic_load_2",
|
||||
"__atomic_load_4",
|
||||
"__atomic_load_8",
|
||||
"__atomic_store",
|
||||
"__atomic_store_1",
|
||||
"__atomic_store_2",
|
||||
"__atomic_store_4",
|
||||
"__atomic_store_8",
|
||||
"__bswapdi2",
|
||||
"__bswapsi2",
|
||||
"__bswapti2",
|
||||
"__ceilh",
|
||||
"__ceilx",
|
||||
"__clear_cache",
|
||||
"__clzdi2",
|
||||
"__chk_fail",
|
||||
"__clzsi2",
|
||||
"__clzti2",
|
||||
"__cmpdf2",
|
||||
"__cmpdi2",
|
||||
"__cmpsf2",
|
||||
"__cmpsi2",
|
||||
"__cmptf2",
|
||||
"__cmpti2",
|
||||
"__cosh",
|
||||
"__cosx",
|
||||
"__ctzdi2",
|
||||
"__ctzsi2",
|
||||
"__ctzti2",
|
||||
"__divdf3",
|
||||
"__divdi3",
|
||||
"__divkf3",
|
||||
"__divmoddi4",
|
||||
"__divmodsi4",
|
||||
"__divmodti4",
|
||||
"__divsf3",
|
||||
"__divsi3",
|
||||
"__divtf3",
|
||||
"__divti3",
|
||||
"__divxf3",
|
||||
"__dlstart",
|
||||
"__eqdf2",
|
||||
"__eqkf2",
|
||||
"__eqsf2",
|
||||
"__eqtf2",
|
||||
"__eqxf2",
|
||||
"__exp2h",
|
||||
"__exp2x",
|
||||
"__exph",
|
||||
"__expx",
|
||||
"__extenddfkf2",
|
||||
"__extenddftf2",
|
||||
"__extenddfxf2",
|
||||
"__extendhfsf2",
|
||||
"__extendhftf2",
|
||||
"__extendhfxf2",
|
||||
"__extendsfdf2",
|
||||
"__extendsfkf2",
|
||||
"__extendsftf2",
|
||||
"__extendsfxf2",
|
||||
"__extendxftf2",
|
||||
"__fabsh",
|
||||
"__fabsx",
|
||||
"__ffsdi2",
|
||||
"__ffssi2",
|
||||
"__ffsti2",
|
||||
"__fixdfdi",
|
||||
"__fixdfsi",
|
||||
"__fixdfti",
|
||||
"__fixkfdi",
|
||||
"__fixkfsi",
|
||||
"__fixkfti",
|
||||
"__fixsfdi",
|
||||
"__fixsfsi",
|
||||
"__fixsfti",
|
||||
"__fixtfdi",
|
||||
"__fixtfsi",
|
||||
"__fixtfti",
|
||||
"__fixunsdfdi",
|
||||
"__fixunsdfsi",
|
||||
"__fixunsdfti",
|
||||
"__fixunskfdi",
|
||||
"__fixunskfsi",
|
||||
"__fixunskfti",
|
||||
"__fixunssfdi",
|
||||
"__fixunssfsi",
|
||||
"__fixunssfti",
|
||||
"__fixunstfdi",
|
||||
"__fixunstfsi",
|
||||
"__fixunstfti",
|
||||
"__fixunsxfdi",
|
||||
"__fixunsxfsi",
|
||||
"__fixunsxfti",
|
||||
"__fixxfdi",
|
||||
"__fixxfsi",
|
||||
"__fixxfti",
|
||||
"__floatdidf",
|
||||
"__floatdikf",
|
||||
"__floatdisf",
|
||||
"__floatditf",
|
||||
"__floatdixf",
|
||||
"__floatsidf",
|
||||
"__floatsikf",
|
||||
"__floatsisf",
|
||||
"__floatsitf",
|
||||
"__floatsixf",
|
||||
"__floattidf",
|
||||
"__floattikf",
|
||||
"__floattisf",
|
||||
"__floattitf",
|
||||
"__floattixf",
|
||||
"__floatundidf",
|
||||
"__floatundikf",
|
||||
"__floatundisf",
|
||||
"__floatunditf",
|
||||
"__floatundixf",
|
||||
"__floatunsidf",
|
||||
"__floatunsikf",
|
||||
"__floatunsisf",
|
||||
"__floatunsitf",
|
||||
"__floatunsixf",
|
||||
"__floatuntidf",
|
||||
"__floatuntikf",
|
||||
"__floatuntisf",
|
||||
"__floatuntitf",
|
||||
"__floatuntixf",
|
||||
"__floorh",
|
||||
"__floorx",
|
||||
"__fmah",
|
||||
"__fmax",
|
||||
"__fmaxh",
|
||||
"__fmaxx",
|
||||
"__fminh",
|
||||
"__fminx",
|
||||
"__fmodh",
|
||||
"__fmodx",
|
||||
"__gedf2",
|
||||
"__gekf2",
|
||||
"__gesf2",
|
||||
"__getf2",
|
||||
"__gexf2",
|
||||
"__gnu_f2h_ieee",
|
||||
"__gnu_h2f_ieee",
|
||||
"__gtdf2",
|
||||
"__gtkf2",
|
||||
"__gtsf2",
|
||||
"__gttf2",
|
||||
"__gtxf2",
|
||||
"__ledf2",
|
||||
"__lekf2",
|
||||
"__lesf2",
|
||||
"__letf2",
|
||||
"__lexf2",
|
||||
"__log10h",
|
||||
"__log10x",
|
||||
"__log2h",
|
||||
"__log2x",
|
||||
"__logh",
|
||||
"__logx",
|
||||
"__lshrdi3",
|
||||
"__lshrsi3",
|
||||
"__lshrti3",
|
||||
"__ltdf2",
|
||||
"__ltkf2",
|
||||
"__ltsf2",
|
||||
"__lttf2",
|
||||
"__ltxf2",
|
||||
"__memcpy_chk",
|
||||
"__memmove_chk",
|
||||
"__memset",
|
||||
"__memset_chk",
|
||||
"__moddi3",
|
||||
"__modsi3",
|
||||
"__modti3",
|
||||
"__muldc3",
|
||||
"__muldf3",
|
||||
"__muldi3",
|
||||
"__mulkc3",
|
||||
"__mulkf3",
|
||||
"__mulodi4",
|
||||
"__mulosi4",
|
||||
"__muloti4",
|
||||
"__mulsc3",
|
||||
"__mulsf3",
|
||||
"__mulsi3",
|
||||
"__multc3",
|
||||
"__multf3",
|
||||
"__multi3",
|
||||
"__mulxc3",
|
||||
"__mulxf3",
|
||||
"__nedf2",
|
||||
"__negdf2",
|
||||
"__negdi2",
|
||||
"__negsf2",
|
||||
"__negsi2",
|
||||
"__negti2",
|
||||
"__negvdi2",
|
||||
"__negvsi2",
|
||||
"__negvti2",
|
||||
"__nekf2",
|
||||
"__nesf2",
|
||||
"__netf2",
|
||||
"__nexf2",
|
||||
"__paritydi2",
|
||||
"__paritysi2",
|
||||
"__parityti2",
|
||||
"__popcountdi2",
|
||||
"__popcountsi2",
|
||||
"__popcountti2",
|
||||
"__powidf2",
|
||||
"__powihf2",
|
||||
"__powikf2",
|
||||
"__powisf2",
|
||||
"__powitf2",
|
||||
"__powixf2",
|
||||
"__roundh",
|
||||
"__roundx",
|
||||
"__sincosh",
|
||||
"__sincosx",
|
||||
"__sinh",
|
||||
"__sinx",
|
||||
"__sqrth",
|
||||
"__sqrtx",
|
||||
"__strcat_chk",
|
||||
"__strcpy_chk",
|
||||
"__strncat_chk",
|
||||
"__strncpy_chk",
|
||||
"__subdf3",
|
||||
"__subkf3",
|
||||
"__subodi4",
|
||||
"__subosi4",
|
||||
"__suboti4",
|
||||
"__subsf3",
|
||||
"__subtf3",
|
||||
"__subxf3",
|
||||
"__tanh",
|
||||
"__tanx",
|
||||
"__truncdfhf2",
|
||||
"__truncdfsf2",
|
||||
"__trunch",
|
||||
"__trunckfdf2",
|
||||
"__trunckfsf2",
|
||||
"__truncsfhf2",
|
||||
"__trunctfdf2",
|
||||
"__trunctfhf2",
|
||||
"__trunctfsf2",
|
||||
"__trunctfxf2",
|
||||
"__truncx",
|
||||
"__truncxfdf2",
|
||||
"__truncxfhf2",
|
||||
"__truncxfsf2",
|
||||
"__ucmpdi2",
|
||||
"__ucmpsi2",
|
||||
"__ucmpti2",
|
||||
"__udivdi3",
|
||||
"__udivei4",
|
||||
"__udivmoddi4",
|
||||
"__udivmodsi4",
|
||||
"__udivmodti4",
|
||||
"__udivsi3",
|
||||
"__udivti3",
|
||||
"__umoddi3",
|
||||
"__umodei4",
|
||||
"__umodsi3",
|
||||
"__umodti3",
|
||||
"__unorddf2",
|
||||
"__unordkf2",
|
||||
"__unordsf2",
|
||||
"__unordtf2",
|
||||
"__zig_probe_stack",
|
||||
"ceilf128",
|
||||
"ceilq",
|
||||
"cosf128",
|
||||
"cosq",
|
||||
"exp2f128",
|
||||
"exp2q",
|
||||
"expf128",
|
||||
"expq",
|
||||
"fabsf128",
|
||||
"fabsq",
|
||||
"fabsq.2",
|
||||
"fabsq.3",
|
||||
"floorf128",
|
||||
"floorq",
|
||||
"fmaf128",
|
||||
"fmaq",
|
||||
"fmaxf128",
|
||||
"fmaxq",
|
||||
"fmaxq.2",
|
||||
"fmaxq.3",
|
||||
"fminf128",
|
||||
"fminq",
|
||||
"fmodf128",
|
||||
"fmodq",
|
||||
"log10f128",
|
||||
"log10q",
|
||||
"log2f128",
|
||||
"log2q",
|
||||
"logf128",
|
||||
"logq",
|
||||
"roundf128",
|
||||
"roundq",
|
||||
"sincosf128",
|
||||
"sincosq",
|
||||
"sinf128",
|
||||
"sinq",
|
||||
"sqrtf128",
|
||||
"sqrtq",
|
||||
"tanf128",
|
||||
"tanq",
|
||||
"truncf128",
|
||||
"truncq",
|
||||
"__aarch64_cas16_acq",
|
||||
"__aarch64_cas16_acq_rel",
|
||||
"__aarch64_cas16_rel",
|
||||
"__aarch64_cas16_relax",
|
||||
"__aarch64_cas1_acq",
|
||||
"__aarch64_cas1_acq_rel",
|
||||
"__aarch64_cas1_rel",
|
||||
"__aarch64_cas1_relax",
|
||||
"__aarch64_cas2_acq",
|
||||
"__aarch64_cas2_acq_rel",
|
||||
"__aarch64_cas2_rel",
|
||||
"__aarch64_cas2_relax",
|
||||
"__aarch64_cas4_acq",
|
||||
"__aarch64_cas4_acq_rel",
|
||||
"__aarch64_cas4_rel",
|
||||
"__aarch64_cas4_relax",
|
||||
"__aarch64_cas8_acq",
|
||||
"__aarch64_cas8_acq_rel",
|
||||
"__aarch64_cas8_rel",
|
||||
"__aarch64_cas8_relax",
|
||||
"__aarch64_ldadd1_acq",
|
||||
"__aarch64_ldadd1_acq_rel",
|
||||
"__aarch64_ldadd1_rel",
|
||||
"__aarch64_ldadd1_relax",
|
||||
"__aarch64_ldadd2_acq",
|
||||
"__aarch64_ldadd2_acq_rel",
|
||||
"__aarch64_ldadd2_rel",
|
||||
"__aarch64_ldadd2_relax",
|
||||
"__aarch64_ldadd4_acq",
|
||||
"__aarch64_ldadd4_acq_rel",
|
||||
"__aarch64_ldadd4_rel",
|
||||
"__aarch64_ldadd4_relax",
|
||||
"__aarch64_ldadd8_acq",
|
||||
"__aarch64_ldadd8_acq_rel",
|
||||
"__aarch64_ldadd8_rel",
|
||||
"__aarch64_ldadd8_relax",
|
||||
"__aarch64_ldclr1_acq",
|
||||
"__aarch64_ldclr1_acq_rel",
|
||||
"__aarch64_ldclr1_rel",
|
||||
"__aarch64_ldclr1_relax",
|
||||
"__aarch64_ldclr2_acq",
|
||||
"__aarch64_ldclr2_acq_rel",
|
||||
"__aarch64_ldclr2_rel",
|
||||
"__aarch64_ldclr2_relax",
|
||||
"__aarch64_ldclr4_acq",
|
||||
"__aarch64_ldclr4_acq_rel",
|
||||
"__aarch64_ldclr4_rel",
|
||||
"__aarch64_ldclr4_relax",
|
||||
"__aarch64_ldclr8_acq",
|
||||
"__aarch64_ldclr8_acq_rel",
|
||||
"__aarch64_ldclr8_rel",
|
||||
"__aarch64_ldclr8_relax",
|
||||
"__aarch64_ldeor1_acq",
|
||||
"__aarch64_ldeor1_acq_rel",
|
||||
"__aarch64_ldeor1_rel",
|
||||
"__aarch64_ldeor1_relax",
|
||||
"__aarch64_ldeor2_acq",
|
||||
"__aarch64_ldeor2_acq_rel",
|
||||
"__aarch64_ldeor2_rel",
|
||||
"__aarch64_ldeor2_relax",
|
||||
"__aarch64_ldeor4_acq",
|
||||
"__aarch64_ldeor4_acq_rel",
|
||||
"__aarch64_ldeor4_rel",
|
||||
"__aarch64_ldeor4_relax",
|
||||
"__aarch64_ldeor8_acq",
|
||||
"__aarch64_ldeor8_acq_rel",
|
||||
"__aarch64_ldeor8_rel",
|
||||
"__aarch64_ldeor8_relax",
|
||||
"__aarch64_ldset1_acq",
|
||||
"__aarch64_ldset1_acq_rel",
|
||||
"__aarch64_ldset1_rel",
|
||||
"__aarch64_ldset1_relax",
|
||||
"__aarch64_ldset2_acq",
|
||||
"__aarch64_ldset2_acq_rel",
|
||||
"__aarch64_ldset2_rel",
|
||||
"__aarch64_ldset2_relax",
|
||||
"__aarch64_ldset4_acq",
|
||||
"__aarch64_ldset4_acq_rel",
|
||||
"__aarch64_ldset4_rel",
|
||||
"__aarch64_ldset4_relax",
|
||||
"__aarch64_ldset8_acq",
|
||||
"__aarch64_ldset8_acq_rel",
|
||||
"__aarch64_ldset8_rel",
|
||||
"__aarch64_ldset8_relax",
|
||||
"__aarch64_swp1_acq",
|
||||
"__aarch64_swp1_acq_rel",
|
||||
"__aarch64_swp1_rel",
|
||||
"__aarch64_swp1_relax",
|
||||
"__aarch64_swp2_acq",
|
||||
"__aarch64_swp2_acq_rel",
|
||||
"__aarch64_swp2_rel",
|
||||
"__aarch64_swp2_relax",
|
||||
"__aarch64_swp4_acq",
|
||||
"__aarch64_swp4_acq_rel",
|
||||
"__aarch64_swp4_rel",
|
||||
"__aarch64_swp4_relax",
|
||||
"__aarch64_swp8_acq",
|
||||
"__aarch64_swp8_acq_rel",
|
||||
"__aarch64_swp8_rel",
|
||||
"__aarch64_swp8_relax",
|
||||
"__addhf3",
|
||||
"__atomic_compare_exchange_16",
|
||||
"__atomic_exchange_16",
|
||||
"__atomic_fetch_add_16",
|
||||
"__atomic_fetch_and_16",
|
||||
"__atomic_fetch_nand_16",
|
||||
"__atomic_fetch_or_16",
|
||||
"__atomic_fetch_sub_16",
|
||||
"__atomic_fetch_umax_1",
|
||||
"__atomic_fetch_umax_16",
|
||||
"__atomic_fetch_umax_2",
|
||||
"__atomic_fetch_umax_4",
|
||||
"__atomic_fetch_umax_8",
|
||||
"__atomic_fetch_umin_1",
|
||||
"__atomic_fetch_umin_16",
|
||||
"__atomic_fetch_umin_2",
|
||||
"__atomic_fetch_umin_4",
|
||||
"__atomic_fetch_umin_8",
|
||||
"__atomic_fetch_xor_16",
|
||||
"__atomic_load_16",
|
||||
"__atomic_store_16",
|
||||
"__cmphf2",
|
||||
"__cmpxf2",
|
||||
"__divdc3",
|
||||
"__divhc3",
|
||||
"__divhf3",
|
||||
"__divkc3",
|
||||
"__divsc3",
|
||||
"__divtc3",
|
||||
"__divxc3",
|
||||
"__eqhf2",
|
||||
"__extendhfdf2",
|
||||
"__fixhfdi",
|
||||
"__fixhfsi",
|
||||
"__fixhfti",
|
||||
"__fixunshfdi",
|
||||
"__fixunshfsi",
|
||||
"__fixunshfti",
|
||||
"__floatdihf",
|
||||
"__floatsihf",
|
||||
"__floattihf",
|
||||
"__floatundihf",
|
||||
"__floatunsihf",
|
||||
"__floatuntihf",
|
||||
"__gehf2",
|
||||
"__gthf2",
|
||||
"__lehf2",
|
||||
"__lthf2",
|
||||
"__mulhc3",
|
||||
"__mulhf3",
|
||||
"__neghf2",
|
||||
"__negkf2",
|
||||
"__negtf2",
|
||||
"__negxf2",
|
||||
"__nehf2",
|
||||
"__subhf3",
|
||||
"__unordhf2",
|
||||
"__unordxf2",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user