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:
Andrew Kelley 2024-11-23 23:50:36 -05:00 committed by GitHub
commit ed8955cea6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 393 additions and 749 deletions

View File

@ -3,6 +3,7 @@ __asm__(
".weak _DYNAMIC \n" ".weak _DYNAMIC \n"
".hidden _DYNAMIC \n" ".hidden _DYNAMIC \n"
".global " START "\n" ".global " START "\n"
".type " START ",%function \n"
START ":\n" START ":\n"
" xor %ebp,%ebp \n" " xor %ebp,%ebp \n"
" mov %esp,%eax \n" " mov %esp,%eax \n"

View File

@ -1,6 +1,7 @@
__asm__( __asm__(
".text \n" ".text \n"
".global " START " \n" ".global " START " \n"
".type " START ",%function \n"
START ": \n" START ": \n"
" xor %rbp,%rbp \n" " xor %rbp,%rbp \n"
" mov %rsp,%rdi \n" " mov %rsp,%rdi \n"

160
lib/libc/musl/libc.S vendored
View File

@ -7,6 +7,13 @@
#define PTR_SIZE_BYTES 4 #define PTR_SIZE_BYTES 4
#define PTR2_SIZE_BYTES 8 #define PTR2_SIZE_BYTES 8
#endif #endif
#ifdef TIME32
#define WEAKTIME64 .globl
#else
#define WEAKTIME64 .weak
#endif
.bss .bss
.weak ___environ .weak ___environ
.type ___environ, %object; .type ___environ, %object;
@ -168,18 +175,64 @@ _IO_putc:
.weak _IO_putc_unlocked .weak _IO_putc_unlocked
.type _IO_putc_unlocked, %function; .type _IO_putc_unlocked, %function;
_IO_putc_unlocked: _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 .globl ___tls_get_addr
.type ___tls_get_addr, %function; .type ___tls_get_addr, %function;
___tls_get_addr: ___tls_get_addr:
#endif #endif
#ifdef PTR32 #ifdef TIME32
.globl __adjtime64 .globl __adjtime64
.type __adjtime64, %function; .type __adjtime64, %function;
__adjtime64: __adjtime64:
.globl __adjtimex_time64 .globl __adjtimex_time64
.type __adjtimex_time64, %function; .type __adjtimex_time64, %function;
__adjtimex_time64: __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 .globl __aio_suspend_time64
.type __aio_suspend_time64, %function; .type __aio_suspend_time64, %function;
__aio_suspend_time64: __aio_suspend_time64:
@ -187,12 +240,12 @@ __aio_suspend_time64:
.globl __assert_fail .globl __assert_fail
.type __assert_fail, %function; .type __assert_fail, %function;
__assert_fail: __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 .globl __cachectl
.type __cachectl, %function; .type __cachectl, %function;
__cachectl: __cachectl:
#endif #endif
#ifdef PTR32 #ifdef TIME32
.globl __clock_adjtime64 .globl __clock_adjtime64
.type __clock_adjtime64, %function; .type __clock_adjtime64, %function;
__clock_adjtime64: __clock_adjtime64:
@ -236,7 +289,7 @@ __cxa_atexit:
.globl __cxa_finalize .globl __cxa_finalize
.type __cxa_finalize, %function; .type __cxa_finalize, %function;
__cxa_finalize: __cxa_finalize:
#ifdef PTR32 #ifdef TIME32
.globl __difftime64 .globl __difftime64
.type __difftime64, %function; .type __difftime64, %function;
__difftime64: __difftime64:
@ -247,7 +300,12 @@ __dls2b:
.globl __dls3 .globl __dls3
.type __dls3, %function; .type __dls3, %function;
__dls3: __dls3:
#ifdef PTR32 #ifdef FAMILY_mips
.globl __dlstart
.type __dlstart, %function;
__dlstart:
#endif
#ifdef TIME32
.globl __dlsym_time64 .globl __dlsym_time64
.type __dlsym_time64, %function; .type __dlsym_time64, %function;
__dlsym_time64: __dlsym_time64:
@ -312,7 +370,7 @@ __fseterr:
.globl __fsetlocking .globl __fsetlocking
.type __fsetlocking, %function; .type __fsetlocking, %function;
__fsetlocking: __fsetlocking:
#ifdef PTR32 #ifdef TIME32
.weak __fstat_time64 .weak __fstat_time64
.type __fstat_time64, %function; .type __fstat_time64, %function;
__fstat_time64: __fstat_time64:
@ -347,7 +405,7 @@ __fxstatat:
.weak __getdelim .weak __getdelim
.type __getdelim, %function; .type __getdelim, %function;
__getdelim: __getdelim:
#ifdef PTR32 #ifdef TIME32
.globl __getitimer_time64 .globl __getitimer_time64
.type __getitimer_time64, %function; .type __getitimer_time64, %function;
__getitimer_time64: __getitimer_time64:
@ -364,6 +422,11 @@ __gmtime64:
.type __gmtime64_r, %function; .type __gmtime64_r, %function;
__gmtime64_r: __gmtime64_r:
#endif #endif
#ifdef ARCH_arm
.globl __gnu_Unwind_Find_exidx
.type __gnu_Unwind_Find_exidx, %function;
__gnu_Unwind_Find_exidx:
#endif
.globl __h_errno_location .globl __h_errno_location
.type __h_errno_location, %function; .type __h_errno_location, %function;
__h_errno_location: __h_errno_location:
@ -490,7 +553,7 @@ __libc_current_sigrtmin:
.globl __libc_start_main .globl __libc_start_main
.type __libc_start_main, %function; .type __libc_start_main, %function;
__libc_start_main: __libc_start_main:
#ifdef PTR32 #ifdef TIME32
.globl __localtime64 .globl __localtime64
.type __localtime64, %function; .type __localtime64, %function;
__localtime64: __localtime64:
@ -498,12 +561,12 @@ __localtime64:
.type __localtime64_r, %function; .type __localtime64_r, %function;
__localtime64_r: __localtime64_r:
#endif #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 .globl __longjmp
.type __longjmp, %function; .type __longjmp, %function;
__longjmp: __longjmp:
#endif #endif
#ifdef PTR32 #ifdef TIME32
.globl __lstat_time64 .globl __lstat_time64
.type __lstat_time64, %function; .type __lstat_time64, %function;
__lstat_time64: __lstat_time64:
@ -514,7 +577,7 @@ __lutimes_time64:
.globl __lxstat .globl __lxstat
.type __lxstat, %function; .type __lxstat, %function;
__lxstat: __lxstat:
#ifdef PTR32 #ifdef TIME32
.globl __mktime64 .globl __mktime64
.type __mktime64, %function; .type __mktime64, %function;
__mktime64: __mktime64:
@ -547,7 +610,7 @@ __overflow:
.weak __posix_getopt .weak __posix_getopt
.type __posix_getopt, %function; .type __posix_getopt, %function;
__posix_getopt: __posix_getopt:
#ifdef PTR32 #ifdef TIME32
.globl __ppoll_time64 .globl __ppoll_time64
.type __ppoll_time64, %function; .type __ppoll_time64, %function;
__ppoll_time64: __ppoll_time64:
@ -576,17 +639,7 @@ __recvmmsg_time64:
.globl __res_state .globl __res_state
.type __res_state, %function; .type __res_state, %function;
__res_state: __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) #ifdef FAMILY_riscv
.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)
.globl __riscv_flush_icache .globl __riscv_flush_icache
.type __riscv_flush_icache, %function; .type __riscv_flush_icache, %function;
__riscv_flush_icache: __riscv_flush_icache:
@ -594,7 +647,7 @@ __riscv_flush_icache:
.globl __sched_cpucount .globl __sched_cpucount
.type __sched_cpucount, %function; .type __sched_cpucount, %function;
__sched_cpucount: __sched_cpucount:
#ifdef PTR32 #ifdef TIME32
.globl __sched_rr_get_interval_time64 .globl __sched_rr_get_interval_time64
.type __sched_rr_get_interval_time64, %function; .type __sched_rr_get_interval_time64, %function;
__sched_rr_get_interval_time64: __sched_rr_get_interval_time64:
@ -614,7 +667,7 @@ __setitimer_time64:
.globl __setjmp .globl __setjmp
.type __setjmp, %function; .type __setjmp, %function;
__setjmp: __setjmp:
#ifdef PTR32 #ifdef TIME32
.globl __settimeofday_time64 .globl __settimeofday_time64
.type __settimeofday_time64, %function; .type __settimeofday_time64, %function;
__settimeofday_time64: __settimeofday_time64:
@ -631,7 +684,7 @@ __signbitl:
.globl __sigsetjmp .globl __sigsetjmp
.type __sigsetjmp, %function; .type __sigsetjmp, %function;
__sigsetjmp: __sigsetjmp:
#ifdef PTR32 #ifdef TIME32
.globl __sigtimedwait_time64 .globl __sigtimedwait_time64
.type __sigtimedwait_time64, %function; .type __sigtimedwait_time64, %function;
__sigtimedwait_time64: __sigtimedwait_time64:
@ -639,7 +692,7 @@ __sigtimedwait_time64:
.globl __stack_chk_fail .globl __stack_chk_fail
.type __stack_chk_fail, %function; .type __stack_chk_fail, %function;
__stack_chk_fail: __stack_chk_fail:
#ifdef PTR32 #ifdef TIME32
.globl __stat_time64 .globl __stat_time64
.type __stat_time64, %function; .type __stat_time64, %function;
__stat_time64: __stat_time64:
@ -692,7 +745,7 @@ __strxfrm_l:
.weak __sysv_signal .weak __sysv_signal
.type __sysv_signal, %function; .type __sysv_signal, %function;
__sysv_signal: __sysv_signal:
#ifdef PTR32 #ifdef TIME32
.globl __thrd_sleep_time64 .globl __thrd_sleep_time64
.type __thrd_sleep_time64, %function; .type __thrd_sleep_time64, %function;
__thrd_sleep_time64: __thrd_sleep_time64:
@ -718,9 +771,16 @@ __timerfd_settime64:
.type __timespec_get_time64, %function; .type __timespec_get_time64, %function;
__timespec_get_time64: __timespec_get_time64:
#endif #endif
#if !defined(ARCH_s390x)
.globl __tls_get_addr .globl __tls_get_addr
.type __tls_get_addr, %function; .type __tls_get_addr, %function;
__tls_get_addr: __tls_get_addr:
#endif
#ifdef ARCH_s390x
.globl __tls_get_offset
.type __tls_get_offset, %function;
__tls_get_offset:
#endif
.globl __tolower_l .globl __tolower_l
.type __tolower_l, %function; .type __tolower_l, %function;
__tolower_l: __tolower_l:
@ -743,7 +803,7 @@ __uflow:
.globl __uselocale .globl __uselocale
.type __uselocale, %function; .type __uselocale, %function;
__uselocale: __uselocale:
#ifdef PTR32 #ifdef TIME32
.globl __utime64 .globl __utime64
.type __utime64, %function; .type __utime64, %function;
__utime64: __utime64:
@ -796,7 +856,7 @@ _dl_debug_state:
.globl _dlstart .globl _dlstart
.type _dlstart, %function; .type _dlstart, %function;
_dlstart: _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 .globl _dlstart_data
.type _dlstart_data, %function; .type _dlstart_data, %function;
_dlstart_data: _dlstart_data:
@ -807,7 +867,7 @@ _exit:
.weak _fini .weak _fini
.type _fini, %function; .type _fini, %function;
_fini: _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 .globl _flush_cache
.type _flush_cache, %function; .type _flush_cache, %function;
_flush_cache: _flush_cache:
@ -908,7 +968,7 @@ aligned_alloc:
.globl alphasort .globl alphasort
.type alphasort, %function; .type alphasort, %function;
alphasort: 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 .globl arch_prctl
.type arch_prctl, %function; .type arch_prctl, %function;
arch_prctl: arch_prctl:
@ -1033,12 +1093,10 @@ cabsf:
.globl cabsl .globl cabsl
.type cabsl, %function; .type cabsl, %function;
cabsl: 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 .weak cachectl
.type cachectl, %function; .type cachectl, %function;
cachectl: 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 .weak cacheflush
.type cacheflush, %function; .type cacheflush, %function;
cacheflush: cacheflush:
@ -1232,10 +1290,10 @@ clock_getcpuclockid:
.globl clock_getres .globl clock_getres
.type clock_getres, %function; .type clock_getres, %function;
clock_getres: clock_getres:
WEAK64 clock_gettime WEAKTIME64 clock_gettime
.type clock_gettime, %function; .type clock_gettime, %function;
clock_gettime: clock_gettime:
WEAK64 clock_nanosleep WEAKTIME64 clock_nanosleep
.type clock_nanosleep, %function; .type clock_nanosleep, %function;
clock_nanosleep: clock_nanosleep:
.globl clock_settime .globl clock_settime
@ -2018,10 +2076,10 @@ fsetpos:
.globl fsetxattr .globl fsetxattr
.type fsetxattr, %function; .type fsetxattr, %function;
fsetxattr: fsetxattr:
WEAK64 fstat WEAKTIME64 fstat
.type fstat, %function; .type fstat, %function;
fstat: fstat:
WEAK64 fstatat WEAKTIME64 fstatat
.type fstatat, %function; .type fstatat, %function;
fstatat: fstatat:
.weak fstatfs .weak fstatfs
@ -2063,7 +2121,7 @@ futimens:
.globl futimes .globl futimes
.type futimes, %function; .type futimes, %function;
futimes: futimes:
WEAK64 futimesat WEAKTIME64 futimesat
.type futimesat, %function; .type futimesat, %function;
futimesat: futimesat:
.globl fwide .globl fwide
@ -2408,7 +2466,7 @@ globfree:
.globl gmtime .globl gmtime
.type gmtime, %function; .type gmtime, %function;
gmtime: gmtime:
WEAK64 gmtime_r WEAKTIME64 gmtime_r
.type gmtime_r, %function; .type gmtime_r, %function;
gmtime_r: gmtime_r:
.globl grantpt .globl grantpt
@ -2549,12 +2607,12 @@ insque:
.globl ioctl .globl ioctl
.type ioctl, %function; .type ioctl, %function;
ioctl: 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 .globl ioperm
.type ioperm, %function; .type ioperm, %function;
ioperm: ioperm:
#endif #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 .globl iopl
.type iopl, %function; .type iopl, %function;
iopl: iopl:
@ -2853,7 +2911,7 @@ localeconv:
.globl localtime .globl localtime
.type localtime, %function; .type localtime, %function;
localtime: localtime:
WEAK64 localtime_r WEAKTIME64 localtime_r
.type localtime_r, %function; .type localtime_r, %function;
localtime_r: localtime_r:
.globl lockf .globl lockf
@ -3552,7 +3610,7 @@ pthread_cond_init:
.globl pthread_cond_signal .globl pthread_cond_signal
.type pthread_cond_signal, %function; .type pthread_cond_signal, %function;
pthread_cond_signal: pthread_cond_signal:
WEAK64 pthread_cond_timedwait WEAKTIME64 pthread_cond_timedwait
.type pthread_cond_timedwait, %function; .type pthread_cond_timedwait, %function;
pthread_cond_timedwait: pthread_cond_timedwait:
.globl pthread_cond_wait .globl pthread_cond_wait
@ -3642,7 +3700,7 @@ pthread_mutex_lock:
.globl pthread_mutex_setprioceiling .globl pthread_mutex_setprioceiling
.type pthread_mutex_setprioceiling, %function; .type pthread_mutex_setprioceiling, %function;
pthread_mutex_setprioceiling: pthread_mutex_setprioceiling:
WEAK64 pthread_mutex_timedlock WEAKTIME64 pthread_mutex_timedlock
.type pthread_mutex_timedlock, %function; .type pthread_mutex_timedlock, %function;
pthread_mutex_timedlock: pthread_mutex_timedlock:
.weak pthread_mutex_trylock .weak pthread_mutex_trylock
@ -3693,10 +3751,10 @@ pthread_rwlock_init:
.weak pthread_rwlock_rdlock .weak pthread_rwlock_rdlock
.type pthread_rwlock_rdlock, %function; .type pthread_rwlock_rdlock, %function;
pthread_rwlock_rdlock: pthread_rwlock_rdlock:
WEAK64 pthread_rwlock_timedrdlock WEAKTIME64 pthread_rwlock_timedrdlock
.type pthread_rwlock_timedrdlock, %function; .type pthread_rwlock_timedrdlock, %function;
pthread_rwlock_timedrdlock: pthread_rwlock_timedrdlock:
WEAK64 pthread_rwlock_timedwrlock WEAKTIME64 pthread_rwlock_timedwrlock
.type pthread_rwlock_timedwrlock, %function; .type pthread_rwlock_timedwrlock, %function;
pthread_rwlock_timedwrlock: pthread_rwlock_timedwrlock:
.weak pthread_rwlock_tryrdlock .weak pthread_rwlock_tryrdlock
@ -3774,7 +3832,7 @@ pthread_spin_unlock:
.weak pthread_testcancel .weak pthread_testcancel
.type pthread_testcancel, %function; .type pthread_testcancel, %function;
pthread_testcancel: pthread_testcancel:
WEAK64 pthread_timedjoin_np WEAKTIME64 pthread_timedjoin_np
.type pthread_timedjoin_np, %function; .type pthread_timedjoin_np, %function;
pthread_timedjoin_np: pthread_timedjoin_np:
.weak pthread_tryjoin_np .weak pthread_tryjoin_np
@ -3999,7 +4057,7 @@ rintf:
.globl rintl .globl rintl
.type rintl, %function; .type rintl, %function;
rintl: 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 .weak riscv_flush_icache
.type riscv_flush_icache, %function; .type riscv_flush_icache, %function;
riscv_flush_icache: riscv_flush_icache:

View File

@ -1,7 +1,9 @@
.global __restore .global __restore
.hidden __restore
.type __restore, %function .type __restore, %function
__restore: __restore:
.global __restore_rt .global __restore_rt
.hidden __restore_rt
.type __restore_rt, %function .type __restore_rt, %function
__restore_rt: __restore_rt:
li a7, 139 # SYS_rt_sigreturn li a7, 139 # SYS_rt_sigreturn

View File

@ -1,7 +1,9 @@
.global __restore .global __restore
.hidden __restore
.type __restore, %function .type __restore, %function
__restore: __restore:
.global __restore_rt .global __restore_rt
.hidden __restore_rt
.type __restore_rt, %function .type __restore_rt, %function
__restore_rt: __restore_rt:
li a7, 139 # SYS_rt_sigreturn li a7, 139 # SYS_rt_sigreturn

View File

@ -5,6 +5,7 @@ __tls_get_offset:
aghi %r15, -160 aghi %r15, -160
la %r2, 0(%r2, %r12) la %r2, 0(%r2, %r12)
.hidden __tls_get_addr
brasl %r14, __tls_get_addr brasl %r14, __tls_get_addr
ear %r1, %a0 ear %r1, %a0

View File

@ -5884,7 +5884,9 @@ pub const FileExt = enum {
}; };
pub fn hasObjectExt(filename: []const u8) bool { 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 { pub fn hasStaticLibraryExt(filename: []const u8) bool {

View File

@ -138,17 +138,6 @@ pub fn buildCrtFile(comp: *Compilation, in_crt_file: CrtFile, prog_node: std.Pro
try addSrcFile(arena, &source_table, src_file); 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| { for (time32_compat_arch_list) |time32_compat_arch| {
if (mem.eql(u8, arch_name, time32_compat_arch)) { if (mem.eql(u8, arch_name, time32_compat_arch)) {
for (compat_time32_files) |compat_time32_file| { 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 target = comp.root_mod.resolved_target.result;
const arch_define = try std.fmt.allocPrint(arena, "-DARCH_{s}", .{ const arch_name = std.zig.target.muslArchName(target.cpu.arch, target.abi);
@tagName(target.cpu.arch), 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) 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 else
&.{arch_define}; &.{ arch_define, family_define };
const root_mod = try Module.create(arena, .{ const root_mod = try Module.create(arena, .{
.global_cache_directory = comp.global_cache_directory, .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 { fn isArchName(name: []const u8) bool {
const musl_arch_names = [_][]const u8{ const musl_arch_names = [_][]const u8{
"aarch64", "aarch64",

File diff suppressed because it is too large Load Diff