authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-19 17:06:39-07:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2023-06-20 12:55:38-04:00
log09c7f1bd7c4410948a984f2f155a6e36ff6279fd
tree1089c9df54d3d6d9563c2871f6cd808d57b570b4
parentb20ccff515364cdb8f3e733cc950e53ab77656db

musl: update libc.S to v1.2.4


2 files changed, 248 insertions(+), 218 deletions(-)

lib/libc/musl/libc.S+30-203
......@@ -168,7 +168,7 @@ _IO_putc:
168168.weak _IO_putc_unlocked
169169.type _IO_putc_unlocked, %function;
170170_IO_putc_unlocked:
171#if !defined(ARCH_riscv64) && !defined(ARCH_mips) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
171#if !defined(ARCH_riscv64) && !defined(ARCH_mips) && !defined(ARCH_mips64) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
172172.globl ___tls_get_addr
173173.type ___tls_get_addr, %function;
174174___tls_get_addr:
......@@ -187,7 +187,7 @@ __aio_suspend_time64:
187187.globl __assert_fail
188188.type __assert_fail, %function;
189189__assert_fail:
190#if !defined(ARCH_riscv64) && !defined(ARCH_i386) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
190#if !defined(ARCH_riscv64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
191191.globl __cachectl
192192.type __cachectl, %function;
193193__cachectl:
......@@ -313,10 +313,10 @@ __fseterr:
313313.type __fsetlocking, %function;
314314__fsetlocking:
315315#ifdef PTR32
316.globl __fstat_time64
316.weak __fstat_time64
317317.type __fstat_time64, %function;
318318__fstat_time64:
319.globl __fstatat_time64
319.weak __fstatat_time64
320320.type __fstatat_time64, %function;
321321__fstatat_time64:
322322.globl __ftime64
......@@ -338,22 +338,12 @@ __fwritable:
338338.globl __fwriting
339339.type __fwriting, %function;
340340__fwriting:
341#if !defined(ARCH_mips) && !defined(ARCH_i386) && !defined(ARCH_powerpc)
342341.globl __fxstat
343342.type __fxstat, %function;
344343__fxstat:
345#endif
346WEAK64 __fxstat64
347.type __fxstat64, %function;
348__fxstat64:
349#if !defined(ARCH_mips) && !defined(ARCH_i386) && !defined(ARCH_powerpc)
350344.globl __fxstatat
351345.type __fxstatat, %function;
352346__fxstatat:
353#endif
354WEAK64 __fxstatat64
355.type __fxstatat64, %function;
356__fxstatat64:
357347.weak __getdelim
358348.type __getdelim, %function;
359349__getdelim:
......@@ -508,7 +498,7 @@ __localtime64:
508498.type __localtime64_r, %function;
509499__localtime64_r:
510500#endif
511#if !defined(ARCH_mips) && !defined(ARCH_i386) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
501#if !defined(ARCH_mips) && !defined(ARCH_mips64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
512502.globl __longjmp
513503.type __longjmp, %function;
514504__longjmp:
......@@ -521,14 +511,9 @@ __lstat_time64:
521511.type __lutimes_time64, %function;
522512__lutimes_time64:
523513#endif
524#if !defined(ARCH_mips) && !defined(ARCH_i386) && !defined(ARCH_powerpc)
525514.globl __lxstat
526515.type __lxstat, %function;
527516__lxstat:
528#endif
529WEAK64 __lxstat64
530.type __lxstat64, %function;
531__lxstat64:
532517#ifdef PTR32
533518.globl __mktime64
534519.type __mktime64, %function;
......@@ -591,7 +576,17 @@ __recvmmsg_time64:
591576.globl __res_state
592577.type __res_state, %function;
593578__res_state:
594#if !defined(ARCH_mips) && !defined(ARCH_i386) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
579#if !defined(ARCH_mips) && !defined(ARCH_mips64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
580.globl __restore
581.type __restore, %function;
582__restore:
583#endif
584#if !defined(ARCH_mips) && !defined(ARCH_mips64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
585.globl __restore_rt
586.type __restore_rt, %function;
587__restore_rt:
588#endif
589#if !defined(ARCH_mips) && !defined(ARCH_mips64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
595590.globl __riscv_flush_icache
596591.type __riscv_flush_icache, %function;
597592__riscv_flush_icache:
......@@ -792,27 +787,27 @@ __xpg_basename:
792787.weak __xpg_strerror_r
793788.type __xpg_strerror_r, %function;
794789__xpg_strerror_r:
795#if !defined(ARCH_mips) && !defined(ARCH_i386) && !defined(ARCH_powerpc)
796790.globl __xstat
797791.type __xstat, %function;
798792__xstat:
799#endif
800WEAK64 __xstat64
801.type __xstat64, %function;
802__xstat64:
803793.weak _dl_debug_state
804794.type _dl_debug_state, %function;
805795_dl_debug_state:
806796.globl _dlstart
807797.type _dlstart, %function;
808798_dlstart:
799#if !defined(ARCH_riscv64) && !defined(ARCH_mips) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
800.globl _dlstart_data
801.type _dlstart_data, %function;
802_dlstart_data:
803#endif
809804.globl _exit
810805.type _exit, %function;
811806_exit:
812807.weak _fini
813808.type _fini, %function;
814809_fini:
815#if !defined(ARCH_riscv64) && !defined(ARCH_i386) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
810#if !defined(ARCH_riscv64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
816811.globl _flush_cache
817812.type _flush_cache, %function;
818813_flush_cache:
......@@ -886,45 +881,24 @@ adjtimex:
886881.globl aio_cancel
887882.type aio_cancel, %function;
888883aio_cancel:
889.weak aio_cancel64
890.type aio_cancel64, %function;
891aio_cancel64:
892884.globl aio_error
893885.type aio_error, %function;
894886aio_error:
895.weak aio_error64
896.type aio_error64, %function;
897aio_error64:
898887.globl aio_fsync
899888.type aio_fsync, %function;
900889aio_fsync:
901.weak aio_fsync64
902.type aio_fsync64, %function;
903aio_fsync64:
904890.globl aio_read
905891.type aio_read, %function;
906892aio_read:
907.weak aio_read64
908.type aio_read64, %function;
909aio_read64:
910893.globl aio_return
911894.type aio_return, %function;
912895aio_return:
913.weak aio_return64
914.type aio_return64, %function;
915aio_return64:
916896.globl aio_suspend
917897.type aio_suspend, %function;
918898aio_suspend:
919.weak aio_suspend64
920.type aio_suspend64, %function;
921aio_suspend64:
922899.globl aio_write
923900.type aio_write, %function;
924901aio_write:
925.weak aio_write64
926.type aio_write64, %function;
927aio_write64:
928902.globl alarm
929903.type alarm, %function;
930904alarm:
......@@ -934,10 +908,7 @@ aligned_alloc:
934908.globl alphasort
935909.type alphasort, %function;
936910alphasort:
937.weak alphasort64
938.type alphasort64, %function;
939alphasort64:
940#if !defined(ARCH_riscv64) && !defined(ARCH_mips) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
911#if !defined(ARCH_riscv64) && !defined(ARCH_mips) && !defined(ARCH_mips64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
941912.globl arch_prctl
942913.type arch_prctl, %function;
943914arch_prctl:
......@@ -1062,12 +1033,12 @@ cabsf:
10621033.globl cabsl
10631034.type cabsl, %function;
10641035cabsl:
1065#if !defined(ARCH_riscv64) && !defined(ARCH_i386) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
1036#if !defined(ARCH_riscv64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
10661037.weak cachectl
10671038.type cachectl, %function;
10681039cachectl:
10691040#endif
1070#if !defined(ARCH_riscv64) && !defined(ARCH_i386) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
1041#if !defined(ARCH_riscv64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
10711042.weak cacheflush
10721043.type cacheflush, %function;
10731044cacheflush:
......@@ -1384,9 +1355,6 @@ creall:
13841355.globl creat
13851356.type creat, %function;
13861357creat:
1387.weak creat64
1388.type creat64, %function;
1389creat64:
13901358.globl crypt
13911359.type crypt, %function;
13921360crypt:
......@@ -1729,9 +1697,6 @@ faccessat:
17291697.globl fallocate
17301698.type fallocate, %function;
17311699fallocate:
1732.weak fallocate64
1733.type fallocate64, %function;
1734fallocate64:
17351700.globl fanotify_init
17361701.type fanotify_init, %function;
17371702fanotify_init:
......@@ -1858,9 +1823,6 @@ fgetln:
18581823.globl fgetpos
18591824.type fgetpos, %function;
18601825fgetpos:
1861.weak fgetpos64
1862.type fgetpos64, %function;
1863fgetpos64:
18641826.globl fgetpwent
18651827.type fgetpwent, %function;
18661828fgetpwent:
......@@ -1966,9 +1928,6 @@ fnmatch:
19661928.globl fopen
19671929.type fopen, %function;
19681930fopen:
1969.weak fopen64
1970.type fopen64, %function;
1971fopen64:
19721931.globl fopencookie
19731932.type fopencookie, %function;
19741933fopencookie:
......@@ -2035,9 +1994,6 @@ fremovexattr:
20351994.globl freopen
20361995.type freopen, %function;
20371996freopen:
2038.weak freopen64
2039.type freopen64, %function;
2040freopen64:
20411997.globl frexp
20421998.type frexp, %function;
20431999frexp:
......@@ -2056,42 +2012,24 @@ fseek:
20562012.weak fseeko
20572013.type fseeko, %function;
20582014fseeko:
2059.weak fseeko64
2060.type fseeko64, %function;
2061fseeko64:
20622015.globl fsetpos
20632016.type fsetpos, %function;
20642017fsetpos:
2065.weak fsetpos64
2066.type fsetpos64, %function;
2067fsetpos64:
20682018.globl fsetxattr
20692019.type fsetxattr, %function;
20702020fsetxattr:
2071.globl fstat
2021WEAK64 fstat
20722022.type fstat, %function;
20732023fstat:
2074.weak fstat64
2075.type fstat64, %function;
2076fstat64:
2077.globl fstatat
2024WEAK64 fstatat
20782025.type fstatat, %function;
20792026fstatat:
2080.weak fstatat64
2081.type fstatat64, %function;
2082fstatat64:
20832027.weak fstatfs
20842028.type fstatfs, %function;
20852029fstatfs:
2086.weak fstatfs64
2087.type fstatfs64, %function;
2088fstatfs64:
20892030.globl fstatvfs
20902031.type fstatvfs, %function;
20912032fstatvfs:
2092.weak fstatvfs64
2093.type fstatvfs64, %function;
2094fstatvfs64:
20952033.globl fsync
20962034.type fsync, %function;
20972035fsync:
......@@ -2101,9 +2039,6 @@ ftell:
21012039.weak ftello
21022040.type ftello, %function;
21032041ftello:
2104.weak ftello64
2105.type ftello64, %function;
2106ftello64:
21072042.globl ftime
21082043.type ftime, %function;
21092044ftime:
......@@ -2113,18 +2048,12 @@ ftok:
21132048.globl ftruncate
21142049.type ftruncate, %function;
21152050ftruncate:
2116.weak ftruncate64
2117.type ftruncate64, %function;
2118ftruncate64:
21192051.globl ftrylockfile
21202052.type ftrylockfile, %function;
21212053ftrylockfile:
21222054.globl ftw
21232055.type ftw, %function;
21242056ftw:
2125.weak ftw64
2126.type ftw64, %function;
2127ftw64:
21282057.globl funlockfile
21292058.type funlockfile, %function;
21302059funlockfile:
......@@ -2203,9 +2132,6 @@ getdelim:
22032132.globl getdents
22042133.type getdents, %function;
22052134getdents:
2206.weak getdents64
2207.type getdents64, %function;
2208getdents64:
22092135.globl getdomainname
22102136.type getdomainname, %function;
22112137getdomainname:
......@@ -2380,9 +2306,6 @@ getresuid:
23802306.globl getrlimit
23812307.type getrlimit, %function;
23822308getrlimit:
2383.weak getrlimit64
2384.type getrlimit64, %function;
2385getrlimit64:
23862309.globl getrusage
23872310.type getrusage, %function;
23882311getrusage:
......@@ -2479,15 +2402,9 @@ getxattr:
24792402.globl glob
24802403.type glob, %function;
24812404glob:
2482.weak glob64
2483.type glob64, %function;
2484glob64:
24852405.globl globfree
24862406.type globfree, %function;
24872407globfree:
2488.weak globfree64
2489.type globfree64, %function;
2490globfree64:
24912408.globl gmtime
24922409.type gmtime, %function;
24932410gmtime:
......@@ -2632,12 +2549,12 @@ insque:
26322549.globl ioctl
26332550.type ioctl, %function;
26342551ioctl:
2635#if !defined(ARCH_riscv64) && !defined(ARCH_aarch64)
2552#if !defined(ARCH_riscv64) && !defined(ARCH_mips64) && !defined(ARCH_aarch64)
26362553.globl ioperm
26372554.type ioperm, %function;
26382555ioperm:
26392556#endif
2640#if !defined(ARCH_riscv64) && !defined(ARCH_aarch64)
2557#if !defined(ARCH_riscv64) && !defined(ARCH_mips64) && !defined(ARCH_aarch64)
26412558.globl iopl
26422559.type iopl, %function;
26432560iopl:
......@@ -2897,9 +2814,6 @@ linkat:
28972814.globl lio_listio
28982815.type lio_listio, %function;
28992816lio_listio:
2900.weak lio_listio64
2901.type lio_listio64, %function;
2902lio_listio64:
29032817.globl listen
29042818.type listen, %function;
29052819listen:
......@@ -2945,9 +2859,6 @@ localtime_r:
29452859.globl lockf
29462860.type lockf, %function;
29472861lockf:
2948.weak lockf64
2949.type lockf64, %function;
2950lockf64:
29512862.globl log
29522863.type log, %function;
29532864log:
......@@ -3029,18 +2940,12 @@ lsearch:
30292940.weak lseek
30302941.type lseek, %function;
30312942lseek:
3032.weak lseek64
3033.type lseek64, %function;
3034lseek64:
30352943.globl lsetxattr
30362944.type lsetxattr, %function;
30372945lsetxattr:
30382946.globl lstat
30392947.type lstat, %function;
30402948lstat:
3041.weak lstat64
3042.type lstat64, %function;
3043lstat64:
30442949.globl lutimes
30452950.type lutimes, %function;
30462951lutimes:
......@@ -3146,27 +3051,15 @@ mknodat:
31463051.globl mkostemp
31473052.type mkostemp, %function;
31483053mkostemp:
3149.weak mkostemp64
3150.type mkostemp64, %function;
3151mkostemp64:
31523054.weak mkostemps
31533055.type mkostemps, %function;
31543056mkostemps:
3155.weak mkostemps64
3156.type mkostemps64, %function;
3157mkostemps64:
31583057.globl mkstemp
31593058.type mkstemp, %function;
31603059mkstemp:
3161.weak mkstemp64
3162.type mkstemp64, %function;
3163mkstemp64:
31643060.globl mkstemps
31653061.type mkstemps, %function;
31663062mkstemps:
3167.weak mkstemps64
3168.type mkstemps64, %function;
3169mkstemps64:
31703063.globl mktemp
31713064.type mktemp, %function;
31723065mktemp:
......@@ -3185,9 +3078,6 @@ mlockall:
31853078.weak mmap
31863079.type mmap, %function;
31873080mmap:
3188.weak mmap64
3189.type mmap64, %function;
3190mmap64:
31913081.globl modf
31923082.type modf, %function;
31933083modf:
......@@ -3329,9 +3219,6 @@ nexttowardl:
33293219.globl nftw
33303220.type nftw, %function;
33313221nftw:
3332.weak nftw64
3333.type nftw64, %function;
3334nftw64:
33353222.globl ngettext
33363223.type ngettext, %function;
33373224ngettext:
......@@ -3380,9 +3267,6 @@ ntohs:
33803267.globl open
33813268.type open, %function;
33823269open:
3383.weak open64
3384.type open64, %function;
3385open64:
33863270.globl open_by_handle_at
33873271.type open_by_handle_at, %function;
33883272open_by_handle_at:
......@@ -3395,9 +3279,6 @@ open_wmemstream:
33953279.globl openat
33963280.type openat, %function;
33973281openat:
3398.weak openat64
3399.type openat64, %function;
3400openat64:
34013282.globl opendir
34023283.type opendir, %function;
34033284opendir:
......@@ -3443,15 +3324,9 @@ posix_close:
34433324.globl posix_fadvise
34443325.type posix_fadvise, %function;
34453326posix_fadvise:
3446.weak posix_fadvise64
3447.type posix_fadvise64, %function;
3448posix_fadvise64:
34493327.globl posix_fallocate
34503328.type posix_fallocate, %function;
34513329posix_fallocate:
3452.weak posix_fallocate64
3453.type posix_fallocate64, %function;
3454posix_fallocate64:
34553330.globl posix_madvise
34563331.type posix_madvise, %function;
34573332posix_madvise:
......@@ -3557,24 +3432,15 @@ prctl:
35573432.globl pread
35583433.type pread, %function;
35593434pread:
3560.weak pread64
3561.type pread64, %function;
3562pread64:
35633435.globl preadv
35643436.type preadv, %function;
35653437preadv:
3566.weak preadv64
3567.type preadv64, %function;
3568preadv64:
35693438.globl printf
35703439.type printf, %function;
35713440printf:
35723441.globl prlimit
35733442.type prlimit, %function;
35743443prlimit:
3575.weak prlimit64
3576.type prlimit64, %function;
3577prlimit64:
35783444.globl process_vm_readv
35793445.type process_vm_readv, %function;
35803446process_vm_readv:
......@@ -3971,15 +3837,9 @@ putwchar_unlocked:
39713837.globl pwrite
39723838.type pwrite, %function;
39733839pwrite:
3974.weak pwrite64
3975.type pwrite64, %function;
3976pwrite64:
39773840.globl pwritev
39783841.type pwritev, %function;
39793842pwritev:
3980.weak pwritev64
3981.type pwritev64, %function;
3982pwritev64:
39833843.globl qsort
39843844.type qsort, %function;
39853845qsort:
......@@ -4013,12 +3873,6 @@ readahead:
40133873.globl readdir
40143874.type readdir, %function;
40153875readdir:
4016.weak readdir64
4017.type readdir64, %function;
4018readdir64:
4019.weak readdir64_r
4020.type readdir64_r, %function;
4021readdir64_r:
40223876.globl readdir_r
40233877.type readdir_r, %function;
40243878readdir_r:
......@@ -4139,7 +3993,7 @@ rintf:
41393993.globl rintl
41403994.type rintl, %function;
41413995rintl:
4142#if !defined(ARCH_mips) && !defined(ARCH_i386) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
3996#if !defined(ARCH_mips) && !defined(ARCH_mips64) && !defined(ARCH_x86) && !defined(ARCH_x86_64) && !defined(ARCH_powerpc) && !defined(ARCH_powerpc64) && !defined(ARCH_aarch64)
41433997.weak riscv_flush_icache
41443998.type riscv_flush_icache, %function;
41453999riscv_flush_icache:
......@@ -4186,9 +4040,6 @@ scalbnl:
41864040.globl scandir
41874041.type scandir, %function;
41884042scandir:
4189.weak scandir64
4190.type scandir64, %function;
4191scandir64:
41924043.globl scanf
41934044.type scanf, %function;
41944045scanf:
......@@ -4285,9 +4136,6 @@ send:
42854136.globl sendfile
42864137.type sendfile, %function;
42874138sendfile:
4288.weak sendfile64
4289.type sendfile64, %function;
4290sendfile64:
42914139.globl sendmmsg
42924140.type sendmmsg, %function;
42934141sendmmsg:
......@@ -4393,9 +4241,6 @@ setreuid:
43934241.globl setrlimit
43944242.type setrlimit, %function;
43954243setrlimit:
4396.weak setrlimit64
4397.type setrlimit64, %function;
4398setrlimit64:
43994244.globl setservent
44004245.type setservent, %function;
44014246setservent:
......@@ -4612,21 +4457,12 @@ sscanf:
46124457.globl stat
46134458.type stat, %function;
46144459stat:
4615.weak stat64
4616.type stat64, %function;
4617stat64:
46184460.weak statfs
46194461.type statfs, %function;
46204462statfs:
4621.weak statfs64
4622.type statfs64, %function;
4623statfs64:
46244463.globl statvfs
46254464.type statvfs, %function;
46264465statvfs:
4627.weak statvfs64
4628.type statvfs64, %function;
4629statvfs64:
46304466.globl stime
46314467.type stime, %function;
46324468stime:
......@@ -4984,9 +4820,6 @@ timespec_get:
49844820.globl tmpfile
49854821.type tmpfile, %function;
49864822tmpfile:
4987.weak tmpfile64
4988.type tmpfile64, %function;
4989tmpfile64:
49904823.globl tmpnam
49914824.type tmpnam, %function;
49924825tmpnam:
......@@ -5029,9 +4862,6 @@ trunc:
50294862.globl truncate
50304863.type truncate, %function;
50314864truncate:
5032.weak truncate64
5033.type truncate64, %function;
5034truncate64:
50354865.globl truncf
50364866.type truncf, %function;
50374867truncf:
......@@ -5152,9 +4982,6 @@ verrx:
51524982.globl versionsort
51534983.type versionsort, %function;
51544984versionsort:
5155.weak versionsort64
5156.type versionsort64, %function;
5157versionsort64:
51584985.globl vfork
51594986.type vfork, %function;
51604987vfork:
tools/gen_stubs.zig+218-15
......@@ -11,6 +11,7 @@
1111//! * One of the following, corresponding to the CPU architecture:
1212//! - `-DARCH_riscv64`
1313//! - `-DARCH_mips`
14//! - `-DARCH_mips64`
1415//! - `-DARCH_i386`
1516//! - `-DARCH_x86_64`
1617//! - `-DARCH_powerpc`
......@@ -28,9 +29,20 @@ const log = std.log;
2829const elf = std.elf;
2930const native_endian = @import("builtin").target.cpu.arch.endian();
3031
31const arches: [7]std.Target.Cpu.Arch = blk: {
32 var result: [7]std.Target.Cpu.Arch = undefined;
33 for (.{ .riscv64, .mips, .x86, .x86_64, .powerpc, .powerpc64, .aarch64 }) |arch| {
32const inputs = .{
33 .riscv64,
34 .mips,
35 .mips64,
36 .x86,
37 .x86_64,
38 .powerpc,
39 .powerpc64,
40 .aarch64,
41};
42
43const arches: [inputs.len]std.Target.Cpu.Arch = blk: {
44 var result: [inputs.len]std.Target.Cpu.Arch = undefined;
45 for (inputs) |arch| {
3446 result[archIndex(arch)] = arch;
3547 }
3648 break :blk result;
......@@ -56,6 +68,7 @@ const MultiSym = struct {
5668 fn is32Only(ms: MultiSym) bool {
5769 return ms.present[archIndex(.riscv64)] == false and
5870 ms.present[archIndex(.mips)] == true and
71 ms.present[archIndex(.mips64)] == false and
5972 ms.present[archIndex(.x86)] == true and
6073 ms.present[archIndex(.x86_64)] == false and
6174 ms.present[archIndex(.powerpc)] == true and
......@@ -97,6 +110,7 @@ const MultiSym = struct {
97110 const map = .{
98111 .{ .riscv64, 8 },
99112 .{ .mips, 4 },
113 .{ .mips64, 8 },
100114 .{ .x86, 4 },
101115 .{ .x86_64, 8 },
102116 .{ .powerpc, 4 },
......@@ -118,6 +132,7 @@ const MultiSym = struct {
118132 const map = .{
119133 .{ .riscv64, 16 },
120134 .{ .mips, 8 },
135 .{ .mips64, 16 },
121136 .{ .x86, 8 },
122137 .{ .x86_64, 16 },
123138 .{ .powerpc, 8 },
......@@ -139,6 +154,7 @@ const MultiSym = struct {
139154 const map = .{
140155 .{ .riscv64, 2 },
141156 .{ .mips, 1 },
157 .{ .mips64, 2 },
142158 .{ .x86, 1 },
143159 .{ .x86_64, 2 },
144160 .{ .powerpc, 1 },
......@@ -187,17 +203,23 @@ pub fn main() !void {
187203 }
188204
189205 for (arches) |arch| {
190 const libc_so_path = try std.fmt.allocPrint(arena, "{s}/lib/libc.so", .{@tagName(arch)});
206 const libc_so_path = try std.fmt.allocPrint(arena, "{s}/lib/libc.so", .{
207 archMuslName(arch),
208 });
191209
192210 // Read the ELF header.
193 const elf_bytes = try build_all_dir.readFileAllocOptions(
211 const elf_bytes = build_all_dir.readFileAllocOptions(
194212 arena,
195213 libc_so_path,
196214 100 * 1024 * 1024,
197215 1 * 1024 * 1024,
198216 @alignOf(elf.Elf64_Ehdr),
199217 null,
200 );
218 ) catch |err| {
219 std.debug.panic("unable to read '{s}/{s}': {s}", .{
220 build_all_path, libc_so_path, @errorName(err),
221 });
222 };
201223 const header = try elf.Header.parse(elf_bytes[0..@sizeOf(elf.Elf64_Ehdr)]);
202224
203225 const parse: Parse = .{
......@@ -437,9 +459,15 @@ fn parseElf(parse: Parse, comptime is_64: bool, comptime endian: builtin.Endian)
437459 const dynstr = elf_bytes[dynstr_offset..];
438460
439461 // Sort the list by address, ascending.
440 mem.sort(Sym, @alignCast(8, dyn_syms), {}, S.symbolAddrLessThan);
462 // We need a copy to fix alignment.
463 const copied_dyn_syms = copy: {
464 const ptr = try arena.alloc(Sym, dyn_syms.len);
465 @memcpy(ptr, dyn_syms);
466 break :copy ptr;
467 };
468 mem.sort(Sym, copied_dyn_syms, {}, S.symbolAddrLessThan);
441469
442 for (dyn_syms) |sym| {
470 for (copied_dyn_syms) |sym| {
443471 const this_section = s(sym.st_shndx);
444472 const name = try arena.dupe(u8, mem.sliceTo(dynstr[s(sym.st_name)..], 0));
445473 const ty = @truncate(u4, sym.st_info);
......@@ -555,19 +583,36 @@ fn archIndex(arch: std.Target.Cpu.Arch) u8 {
555583 // zig fmt: off
556584 .riscv64 => 0,
557585 .mips => 1,
558 .x86 => 2,
559 .x86_64 => 3,
560 .powerpc => 4,
561 .powerpc64 => 5,
562 .aarch64 => 6,
586 .mips64 => 2,
587 .x86 => 3,
588 .x86_64 => 4,
589 .powerpc => 5,
590 .powerpc64 => 6,
591 .aarch64 => 7,
592 else => unreachable,
593 // zig fmt: on
594 };
595}
596
597fn archMuslName(arch: std.Target.Cpu.Arch) []const u8 {
598 return switch (arch) {
599 // zig fmt: off
600 .riscv64 => "riscv64",
601 .mips => "mips",
602 .mips64 => "mips64",
603 .x86 => "i386",
604 .x86_64 => "x86_64",
605 .powerpc => "powerpc",
606 .powerpc64 => "powerpc64",
607 .aarch64 => "aarch64",
563608 else => unreachable,
564609 // zig fmt: on
565610 };
566611}
567612
568613fn archSetName(arch_set: [arches.len]bool) []const u8 {
569 for (arches, 0..) |arch, i| {
570 if (arch_set[i]) {
614 for (arches, arch_set) |arch, set_item| {
615 if (set_item) {
571616 return @tagName(arch);
572617 }
573618 }
......@@ -913,4 +958,162 @@ const blacklisted_symbols = [_][]const u8{
913958 "sinf128",
914959 "sqrtf128",
915960 "truncf128",
961 "__aarch64_cas16_acq",
962 "__aarch64_cas16_acq_rel",
963 "__aarch64_cas16_rel",
964 "__aarch64_cas16_relax",
965 "__aarch64_cas1_acq",
966 "__aarch64_cas1_acq_rel",
967 "__aarch64_cas1_rel",
968 "__aarch64_cas1_relax",
969 "__aarch64_cas2_acq",
970 "__aarch64_cas2_acq_rel",
971 "__aarch64_cas2_rel",
972 "__aarch64_cas2_relax",
973 "__aarch64_cas4_acq",
974 "__aarch64_cas4_acq_rel",
975 "__aarch64_cas4_rel",
976 "__aarch64_cas4_relax",
977 "__aarch64_cas8_acq",
978 "__aarch64_cas8_acq_rel",
979 "__aarch64_cas8_rel",
980 "__aarch64_cas8_relax",
981 "__aarch64_ldadd1_acq",
982 "__aarch64_ldadd1_acq_rel",
983 "__aarch64_ldadd1_rel",
984 "__aarch64_ldadd1_relax",
985 "__aarch64_ldadd2_acq",
986 "__aarch64_ldadd2_acq_rel",
987 "__aarch64_ldadd2_rel",
988 "__aarch64_ldadd2_relax",
989 "__aarch64_ldadd4_acq",
990 "__aarch64_ldadd4_acq_rel",
991 "__aarch64_ldadd4_rel",
992 "__aarch64_ldadd4_relax",
993 "__aarch64_ldadd8_acq",
994 "__aarch64_ldadd8_acq_rel",
995 "__aarch64_ldadd8_rel",
996 "__aarch64_ldadd8_relax",
997 "__aarch64_ldclr1_acq",
998 "__aarch64_ldclr1_acq_rel",
999 "__aarch64_ldclr1_rel",
1000 "__aarch64_ldclr1_relax",
1001 "__aarch64_ldclr2_acq",
1002 "__aarch64_ldclr2_acq_rel",
1003 "__aarch64_ldclr2_rel",
1004 "__aarch64_ldclr2_relax",
1005 "__aarch64_ldclr4_acq",
1006 "__aarch64_ldclr4_acq_rel",
1007 "__aarch64_ldclr4_rel",
1008 "__aarch64_ldclr4_relax",
1009 "__aarch64_ldclr8_acq",
1010 "__aarch64_ldclr8_acq_rel",
1011 "__aarch64_ldclr8_rel",
1012 "__aarch64_ldclr8_relax",
1013 "__aarch64_ldeor1_acq",
1014 "__aarch64_ldeor1_acq_rel",
1015 "__aarch64_ldeor1_rel",
1016 "__aarch64_ldeor1_relax",
1017 "__aarch64_ldeor2_acq",
1018 "__aarch64_ldeor2_acq_rel",
1019 "__aarch64_ldeor2_rel",
1020 "__aarch64_ldeor2_relax",
1021 "__aarch64_ldeor4_acq",
1022 "__aarch64_ldeor4_acq_rel",
1023 "__aarch64_ldeor4_rel",
1024 "__aarch64_ldeor4_relax",
1025 "__aarch64_ldeor8_acq",
1026 "__aarch64_ldeor8_acq_rel",
1027 "__aarch64_ldeor8_rel",
1028 "__aarch64_ldeor8_relax",
1029 "__aarch64_ldset1_acq",
1030 "__aarch64_ldset1_acq_rel",
1031 "__aarch64_ldset1_rel",
1032 "__aarch64_ldset1_relax",
1033 "__aarch64_ldset2_acq",
1034 "__aarch64_ldset2_acq_rel",
1035 "__aarch64_ldset2_rel",
1036 "__aarch64_ldset2_relax",
1037 "__aarch64_ldset4_acq",
1038 "__aarch64_ldset4_acq_rel",
1039 "__aarch64_ldset4_rel",
1040 "__aarch64_ldset4_relax",
1041 "__aarch64_ldset8_acq",
1042 "__aarch64_ldset8_acq_rel",
1043 "__aarch64_ldset8_rel",
1044 "__aarch64_ldset8_relax",
1045 "__aarch64_swp1_acq",
1046 "__aarch64_swp1_acq_rel",
1047 "__aarch64_swp1_rel",
1048 "__aarch64_swp1_relax",
1049 "__aarch64_swp2_acq",
1050 "__aarch64_swp2_acq_rel",
1051 "__aarch64_swp2_rel",
1052 "__aarch64_swp2_relax",
1053 "__aarch64_swp4_acq",
1054 "__aarch64_swp4_acq_rel",
1055 "__aarch64_swp4_rel",
1056 "__aarch64_swp4_relax",
1057 "__aarch64_swp8_acq",
1058 "__aarch64_swp8_acq_rel",
1059 "__aarch64_swp8_rel",
1060 "__aarch64_swp8_relax",
1061 "__addhf3",
1062 "__atomic_compare_exchange_16",
1063 "__atomic_exchange_16",
1064 "__atomic_fetch_add_16",
1065 "__atomic_fetch_and_16",
1066 "__atomic_fetch_nand_16",
1067 "__atomic_fetch_or_16",
1068 "__atomic_fetch_sub_16",
1069 "__atomic_fetch_umax_1",
1070 "__atomic_fetch_umax_16",
1071 "__atomic_fetch_umax_2",
1072 "__atomic_fetch_umax_4",
1073 "__atomic_fetch_umax_8",
1074 "__atomic_fetch_umin_1",
1075 "__atomic_fetch_umin_16",
1076 "__atomic_fetch_umin_2",
1077 "__atomic_fetch_umin_4",
1078 "__atomic_fetch_umin_8",
1079 "__atomic_fetch_xor_16",
1080 "__atomic_load_16",
1081 "__atomic_store_16",
1082 "__cmphf2",
1083 "__cmpxf2",
1084 "__divdc3",
1085 "__divhc3",
1086 "__divhf3",
1087 "__divkc3",
1088 "__divsc3",
1089 "__divtc3",
1090 "__divxc3",
1091 "__eqhf2",
1092 "__extendhfdf2",
1093 "__fixhfdi",
1094 "__fixhfsi",
1095 "__fixhfti",
1096 "__fixunshfdi",
1097 "__fixunshfsi",
1098 "__fixunshfti",
1099 "__floatdihf",
1100 "__floatsihf",
1101 "__floattihf",
1102 "__floatundihf",
1103 "__floatunsihf",
1104 "__floatuntihf",
1105 "__gehf2",
1106 "__gthf2",
1107 "__lehf2",
1108 "__lthf2",
1109 "__mulhc3",
1110 "__mulhf3",
1111 "__neghf2",
1112 "__negkf2",
1113 "__negtf2",
1114 "__negxf2",
1115 "__nehf2",
1116 "__subhf3",
1117 "__unordhf2",
1118 "__unordxf2",
9161119};