Repository: hajimehoshi/hitsumabushi Branch: main Commit: 2d81b070ae19 Files: 694 Total size: 826.3 KB Directory structure: gitextract_v2i9lf6x/ ├── .github/ │ └── workflows/ │ └── test.yml ├── .gitignore ├── 1.19_linux/ │ ├── internal/ │ │ ├── reflectlite/ │ │ │ └── reflect_mirror_test.go.patch │ │ └── testenv/ │ │ ├── testenv.go.patch │ │ ├── testenv_notunix.go.patch │ │ └── testenv_unix.go.patch │ ├── math/ │ │ └── big/ │ │ └── link_test.go.patch │ ├── runtime/ │ │ ├── align_test.go.patch │ │ ├── callers_test.go.patch │ │ ├── cgo/ │ │ │ ├── cgo.go.patch │ │ │ ├── gcc_linux_arm64.c.patch │ │ │ ├── hitsumabushi_clock_linux.c │ │ │ ├── hitsumabushi_cpu_linux.c │ │ │ ├── hitsumabushi_filesystem_linux.c │ │ │ ├── hitsumabushi_futex_linux.c │ │ │ ├── hitsumabushi_mem_linux.c │ │ │ ├── hitsumabushi_syscalls_linux.c │ │ │ └── hitsumabushi_thread_linux.c │ │ ├── crash_test.go.patch │ │ ├── crash_unix_test.go.patch │ │ ├── debug/ │ │ │ ├── heapdump_test.go.patch │ │ │ └── panic_test.go.patch │ │ ├── debug_test.go.patch │ │ ├── export_linux_test.go.patch │ │ ├── export_unix_test.go.patch │ │ ├── internal/ │ │ │ └── syscall/ │ │ │ ├── asm_linux_amd64.s.patch │ │ │ ├── asm_linux_arm64.s.patch │ │ │ └── syscall_linux.go.patch │ │ ├── mem_linux.go │ │ ├── memmove_linux_amd64_test.go.patch │ │ ├── nbpipe_pipe2.go.patch │ │ ├── nbpipe_test.go.patch │ │ ├── netpoll_epoll.go.patch │ │ ├── netpoll_fake.go.patch │ │ ├── norace_linux_test.go.patch │ │ ├── os_linux.go.patch │ │ ├── proc_test.go.patch │ │ ├── runtime1.go.patch │ │ ├── runtime_linux_test.go.patch │ │ ├── runtime_mmap_test.go.patch │ │ ├── runtime_test.go.patch │ │ ├── runtime_unix_test.go.patch │ │ ├── stack_test.go.patch │ │ ├── stubs2.go.patch │ │ ├── stubs3.go.patch │ │ ├── sys_libc.go.patch │ │ ├── sys_linux_amd64.s.patch │ │ ├── sys_linux_arm64.s.patch │ │ ├── time_linux_amd64.s.patch │ │ ├── timeasm.go.patch │ │ ├── timestub.go.patch │ │ └── timestub2.go.patch │ ├── strconv/ │ │ └── fp_test.go.patch │ ├── sync/ │ │ └── atomic/ │ │ └── atomic_test.go.patch │ ├── syscall/ │ │ ├── hitsumabushi_stubs_linux_amd64.go │ │ ├── hitsumabushi_stubs_linux_arm64.go │ │ ├── rlimit.go.patch │ │ └── syscall_linux.go.patch │ ├── testing/ │ │ └── run_example.go │ └── time/ │ ├── format_test.go.patch │ ├── internal_test.go.patch │ ├── sleep_test.go.patch │ ├── time_test.go.patch │ ├── tzdata_test.go.patch │ ├── zoneinfo_test.go.patch │ ├── zoneinfo_unix.go.patch │ └── zoneinfo_unix_test.go.patch ├── 1.19_windows/ │ ├── runtime/ │ │ ├── abi_test.go.patch │ │ ├── cgo/ │ │ │ ├── gcc_fatalf.c.patch │ │ │ ├── gcc_libinit.c.patch │ │ │ ├── gcc_libinit_windows.c.patch │ │ │ ├── gcc_windows_amd64.c.patch │ │ │ └── libcgo.h.patch │ │ ├── crash_test.go.patch │ │ ├── malloc_test.go.patch │ │ ├── os_windows.go.patch │ │ ├── syscall_windows.go.patch │ │ └── syscall_windows_test.go.patch │ └── sync/ │ └── mutex_test.go.patch ├── 1.20_linux/ │ ├── internal/ │ │ ├── reflectlite/ │ │ │ └── reflect_mirror_test.go.patch │ │ └── testenv/ │ │ ├── exec.go.patch │ │ ├── testenv.go.patch │ │ ├── testenv_notunix.go.patch │ │ └── testenv_unix.go.patch │ ├── math/ │ │ └── big/ │ │ └── link_test.go.patch │ ├── runtime/ │ │ ├── align_test.go.patch │ │ ├── callers_test.go.patch │ │ ├── cgo/ │ │ │ ├── cgo.go.patch │ │ │ ├── gcc_linux_amd64.c.patch │ │ │ ├── gcc_linux_arm64.c.patch │ │ │ ├── gcc_setenv.c.patch │ │ │ ├── gcc_sigaction.c.patch │ │ │ ├── hitsumabushi_clock_linux.c │ │ │ ├── hitsumabushi_cpu_linux.c │ │ │ ├── hitsumabushi_filesystem_linux.c │ │ │ ├── hitsumabushi_futex_linux.c │ │ │ ├── hitsumabushi_mem_linux.c │ │ │ ├── hitsumabushi_syscalls_linux.c │ │ │ ├── hitsumabushi_thread_linux.c │ │ │ ├── linux_syscall.c.patch │ │ │ └── sigaction.go.patch │ │ ├── crash_test.go.patch │ │ ├── crash_unix_test.go.patch │ │ ├── debug/ │ │ │ ├── heapdump_test.go.patch │ │ │ └── panic_test.go.patch │ │ ├── debug_test.go.patch │ │ ├── export_unix_test.go │ │ ├── internal/ │ │ │ └── syscall/ │ │ │ ├── asm_linux_amd64.s.patch │ │ │ ├── asm_linux_arm64.s.patch │ │ │ ├── syscall_linux.go.patch │ │ │ └── syscall_linux_test.go.patch │ │ ├── mem_linux.go │ │ ├── memmove_linux_amd64_test.go.patch │ │ ├── nbpipe_pipe2.go.patch │ │ ├── nbpipe_test.go.patch │ │ ├── netpoll_epoll.go.patch │ │ ├── netpoll_fake.go.patch │ │ ├── norace_linux_test.go.patch │ │ ├── os_linux.go.patch │ │ ├── proc_test.go.patch │ │ ├── runtime1.go.patch │ │ ├── runtime_linux_test.go.patch │ │ ├── runtime_mmap_test.go.patch │ │ ├── runtime_test.go.patch │ │ ├── runtime_unix_test.go.patch │ │ ├── stack_test.go.patch │ │ ├── stubs2.go.patch │ │ ├── stubs3.go.patch │ │ ├── sys_libc.go.patch │ │ ├── sys_linux_amd64.s.patch │ │ ├── sys_linux_arm64.s.patch │ │ ├── time_linux_amd64.s.patch │ │ ├── timeasm.go.patch │ │ ├── timestub.go.patch │ │ └── timestub2.go.patch │ ├── strconv/ │ │ └── fp_test.go.patch │ ├── sync/ │ │ └── atomic/ │ │ └── atomic_test.go.patch │ ├── syscall/ │ │ ├── hitsumabushi_stubs_linux_amd64.go │ │ ├── hitsumabushi_stubs_linux_arm64.go │ │ ├── rlimit.go.patch │ │ └── syscall_linux.go.patch │ ├── testing/ │ │ └── run_example.go │ └── time/ │ ├── format_test.go.patch │ ├── internal_test.go.patch │ ├── sleep_test.go.patch │ ├── time_test.go.patch │ ├── tzdata_test.go.patch │ ├── zoneinfo_test.go.patch │ ├── zoneinfo_unix.go.patch │ └── zoneinfo_unix_test.go.patch ├── 1.20_windows/ │ ├── runtime/ │ │ ├── abi_test.go.patch │ │ ├── cgo/ │ │ │ └── gcc_windows_amd64.c.patch │ │ ├── crash_test.go.patch │ │ ├── malloc_test.go.patch │ │ ├── os_windows.go.patch │ │ ├── syscall_windows.go.patch │ │ └── syscall_windows_test.go.patch │ └── sync/ │ └── mutex_test.go.patch ├── 1.21_linux/ │ ├── internal/ │ │ ├── reflectlite/ │ │ │ └── reflect_mirror_test.go.patch │ │ ├── syscall/ │ │ │ └── unix/ │ │ │ └── fcntl_unix.go.patch │ │ └── testenv/ │ │ ├── exec.go.patch │ │ ├── testenv.go.patch │ │ ├── testenv_notunix.go.patch │ │ └── testenv_unix.go.patch │ ├── math/ │ │ ├── big/ │ │ │ └── link_test.go.patch │ │ └── rand/ │ │ └── default_test.go.patch │ ├── runtime/ │ │ ├── align_test.go.patch │ │ ├── callers_test.go.patch │ │ ├── cgo/ │ │ │ ├── cgo.go.patch │ │ │ ├── gcc_linux_amd64.c.patch │ │ │ ├── gcc_linux_arm64.c.patch │ │ │ ├── gcc_setenv.c.patch │ │ │ ├── gcc_sigaction.c.patch │ │ │ ├── hitsumabushi_clock_linux.c │ │ │ ├── hitsumabushi_cpu_linux.c │ │ │ ├── hitsumabushi_filesystem_linux.c │ │ │ ├── hitsumabushi_futex_linux.c │ │ │ ├── hitsumabushi_mem_linux.c │ │ │ ├── hitsumabushi_syscalls_linux.c │ │ │ ├── hitsumabushi_thread_linux.c │ │ │ ├── linux_syscall.c.patch │ │ │ └── sigaction.go.patch │ │ ├── crash_test.go.patch │ │ ├── crash_unix_test.go.patch │ │ ├── debug/ │ │ │ ├── heapdump_test.go.patch │ │ │ └── panic_test.go.patch │ │ ├── debug_test.go.patch │ │ ├── export_unix_test.go │ │ ├── internal/ │ │ │ └── syscall/ │ │ │ ├── asm_linux_amd64.s.patch │ │ │ ├── asm_linux_arm64.s.patch │ │ │ ├── syscall_linux.go.patch │ │ │ └── syscall_linux_test.go.patch │ │ ├── mem_linux.go │ │ ├── memmove_linux_amd64_test.go.patch │ │ ├── nbpipe_pipe2.go.patch │ │ ├── nbpipe_test.go.patch │ │ ├── netpoll_epoll.go.patch │ │ ├── netpoll_fake.go.patch │ │ ├── norace_linux_test.go.patch │ │ ├── os_linux.go.patch │ │ ├── panicnil_test.go.patch │ │ ├── proc_test.go.patch │ │ ├── runtime1.go.patch │ │ ├── runtime_linux_test.go.patch │ │ ├── runtime_mmap_test.go.patch │ │ ├── runtime_test.go.patch │ │ ├── runtime_unix_test.go.patch │ │ ├── stack_test.go.patch │ │ ├── stubs2.go.patch │ │ ├── stubs3.go.patch │ │ ├── sys_libc.go.patch │ │ ├── sys_linux_amd64.s.patch │ │ ├── sys_linux_arm64.s.patch │ │ ├── time_linux_amd64.s.patch │ │ ├── timeasm.go.patch │ │ ├── timestub.go.patch │ │ ├── timestub2.go.patch │ │ └── traceback_test.go.patch │ ├── strconv/ │ │ └── fp_test.go.patch │ ├── sync/ │ │ └── atomic/ │ │ └── atomic_test.go.patch │ ├── syscall/ │ │ ├── hitsumabushi_stubs_linux_amd64.go │ │ ├── hitsumabushi_stubs_linux_arm64.go │ │ ├── rlimit.go.patch │ │ └── syscall_linux.go.patch │ ├── testing/ │ │ └── run_example.go │ └── time/ │ ├── format_test.go.patch │ ├── internal_test.go.patch │ ├── sleep_test.go.patch │ ├── time_test.go.patch │ ├── tzdata_test.go.patch │ ├── zoneinfo_test.go.patch │ ├── zoneinfo_unix.go.patch │ └── zoneinfo_unix_test.go.patch ├── 1.21_windows/ │ ├── runtime/ │ │ ├── abi_test.go.patch │ │ ├── cgo/ │ │ │ └── gcc_windows_amd64.c.patch │ │ ├── crash_test.go.patch │ │ ├── malloc_test.go.patch │ │ ├── os_windows.go.patch │ │ ├── runtime-gdb_test.go.patch │ │ ├── syscall_windows.go.patch │ │ └── syscall_windows_test.go.patch │ └── sync/ │ └── mutex_test.go.patch ├── 1.22_linux/ │ ├── internal/ │ │ ├── reflectlite/ │ │ │ └── reflect_mirror_test.go.patch │ │ ├── syscall/ │ │ │ └── unix/ │ │ │ └── fcntl_unix.go.patch │ │ └── testenv/ │ │ ├── exec.go.patch │ │ ├── testenv.go.patch │ │ ├── testenv_notunix.go.patch │ │ └── testenv_unix.go.patch │ ├── math/ │ │ ├── big/ │ │ │ └── link_test.go.patch │ │ └── rand/ │ │ └── default_test.go.patch │ ├── runtime/ │ │ ├── align_test.go.patch │ │ ├── callers_test.go.patch │ │ ├── cgo/ │ │ │ ├── cgo.go.patch │ │ │ ├── gcc_linux_amd64.c.patch │ │ │ ├── gcc_linux_arm64.c.patch │ │ │ ├── gcc_setenv.c.patch │ │ │ ├── gcc_sigaction.c.patch │ │ │ ├── hitsumabushi_clock_linux.c │ │ │ ├── hitsumabushi_cpu_linux.c │ │ │ ├── hitsumabushi_filesystem_linux.c │ │ │ ├── hitsumabushi_futex_linux.c │ │ │ ├── hitsumabushi_mem_linux.c │ │ │ ├── hitsumabushi_syscalls_linux.c │ │ │ ├── hitsumabushi_thread_linux.c │ │ │ ├── linux_syscall.c.patch │ │ │ └── sigaction.go.patch │ │ ├── crash_test.go.patch │ │ ├── crash_unix_test.go.patch │ │ ├── debug/ │ │ │ ├── heapdump_test.go.patch │ │ │ └── panic_test.go.patch │ │ ├── debug_test.go.patch │ │ ├── export_unix_test.go │ │ ├── fds_unix.go.patch │ │ ├── internal/ │ │ │ └── syscall/ │ │ │ ├── asm_linux_amd64.s.patch │ │ │ ├── asm_linux_arm64.s.patch │ │ │ ├── syscall_linux.go.patch │ │ │ └── syscall_linux_test.go.patch │ │ ├── mem_linux.go │ │ ├── memmove_linux_amd64_test.go.patch │ │ ├── metrics_test.go.patch │ │ ├── nbpipe_pipe2.go.patch │ │ ├── nbpipe_test.go.patch │ │ ├── netpoll_epoll.go.patch │ │ ├── netpoll_fake.go.patch │ │ ├── norace_linux_test.go.patch │ │ ├── os_linux.go.patch │ │ ├── panicnil_test.go.patch │ │ ├── proc_test.go.patch │ │ ├── rand_test.go.patch │ │ ├── runtime1.go.patch │ │ ├── runtime_linux_test.go.patch │ │ ├── runtime_mmap_test.go.patch │ │ ├── runtime_test.go.patch │ │ ├── runtime_unix_test.go.patch │ │ ├── stack_test.go.patch │ │ ├── stubs2.go.patch │ │ ├── stubs3.go.patch │ │ ├── sys_libc.go.patch │ │ ├── sys_linux_amd64.s.patch │ │ ├── sys_linux_arm64.s.patch │ │ ├── time_linux_amd64.s.patch │ │ ├── timeasm.go.patch │ │ ├── timestub.go.patch │ │ ├── timestub2.go.patch │ │ └── traceback_test.go.patch │ ├── strconv/ │ │ └── fp_test.go.patch │ ├── sync/ │ │ └── atomic/ │ │ └── atomic_test.go.patch │ ├── syscall/ │ │ ├── hitsumabushi_stubs_linux_amd64.go │ │ ├── hitsumabushi_stubs_linux_arm64.go │ │ ├── rlimit.go.patch │ │ └── syscall_linux.go.patch │ ├── testing/ │ │ └── run_example.go │ └── time/ │ ├── format_test.go.patch │ ├── internal_test.go.patch │ ├── sleep_test.go.patch │ ├── time_test.go.patch │ ├── tzdata_test.go.patch │ ├── zoneinfo_test.go.patch │ ├── zoneinfo_unix.go.patch │ └── zoneinfo_unix_test.go.patch ├── 1.22_windows/ │ ├── internal/ │ │ └── testenv/ │ │ ├── exec.go.patch │ │ └── testenv.go.patch │ └── runtime/ │ ├── cgo/ │ │ ├── gcc_windows_amd64.c.patch │ │ └── libcgo.h.patch │ ├── os_windows.go.patch │ ├── signal_windows.go.patch │ ├── syscall_windows.go.patch │ └── syscall_windows_test.go.patch ├── 1.23_linux/ │ ├── internal/ │ │ ├── reflectlite/ │ │ │ └── reflect_mirror_test.go.patch │ │ ├── runtime/ │ │ │ └── syscall/ │ │ │ ├── asm_linux_amd64.s.patch │ │ │ ├── asm_linux_arm64.s.patch │ │ │ ├── syscall_linux.go.patch │ │ │ └── syscall_linux_test.go.patch │ │ ├── syscall/ │ │ │ └── unix/ │ │ │ └── fcntl_unix.go.patch │ │ └── testenv/ │ │ ├── exec.go.patch │ │ ├── testenv.go.patch │ │ ├── testenv_notunix.go.patch │ │ └── testenv_unix.go.patch │ ├── math/ │ │ ├── big/ │ │ │ └── link_test.go.patch │ │ └── rand/ │ │ └── default_test.go.patch │ ├── runtime/ │ │ ├── align_test.go.patch │ │ ├── callers_test.go.patch │ │ ├── cgo/ │ │ │ ├── cgo.go.patch │ │ │ ├── gcc_linux_amd64.c.patch │ │ │ ├── gcc_linux_arm64.c.patch │ │ │ ├── gcc_setenv.c.patch │ │ │ ├── gcc_sigaction.c.patch │ │ │ ├── hitsumabushi_clock_linux.c │ │ │ ├── hitsumabushi_cpu_linux.c │ │ │ ├── hitsumabushi_filesystem_linux.c │ │ │ ├── hitsumabushi_futex_linux.c │ │ │ ├── hitsumabushi_mem_linux.c │ │ │ ├── hitsumabushi_syscalls_linux.c │ │ │ ├── hitsumabushi_thread_linux.c │ │ │ ├── linux_syscall.c.patch │ │ │ └── sigaction.go.patch │ │ ├── crash_test.go.patch │ │ ├── crash_unix_test.go.patch │ │ ├── debug/ │ │ │ ├── heapdump_test.go.patch │ │ │ └── panic_test.go.patch │ │ ├── debug_test.go.patch │ │ ├── export_unix_test.go │ │ ├── fds_unix.go.patch │ │ ├── mem_linux.go │ │ ├── memmove_linux_amd64_test.go.patch │ │ ├── metrics_test.go.patch │ │ ├── nbpipe_pipe2.go.patch │ │ ├── nbpipe_test.go.patch │ │ ├── netpoll_epoll.go.patch │ │ ├── netpoll_fake.go.patch │ │ ├── norace_linux_test.go.patch │ │ ├── os_linux.go.patch │ │ ├── panicnil_test.go.patch │ │ ├── proc_test.go.patch │ │ ├── rand_test.go.patch │ │ ├── runtime1.go.patch │ │ ├── runtime_linux_test.go.patch │ │ ├── runtime_mmap_test.go.patch │ │ ├── runtime_test.go.patch │ │ ├── runtime_unix_test.go.patch │ │ ├── stack_test.go.patch │ │ ├── stubs2.go.patch │ │ ├── stubs3.go.patch │ │ ├── sys_libc.go.patch │ │ ├── sys_linux_amd64.s.patch │ │ ├── sys_linux_arm64.s.patch │ │ ├── time_linux_amd64.s.patch │ │ ├── timeasm.go.patch │ │ ├── timestub.go.patch │ │ ├── timestub2.go.patch │ │ └── traceback_test.go.patch │ ├── strconv/ │ │ └── fp_test.go.patch │ ├── sync/ │ │ └── atomic/ │ │ └── atomic_test.go.patch │ ├── syscall/ │ │ ├── hitsumabushi_stubs_linux_amd64.go │ │ ├── hitsumabushi_stubs_linux_arm64.go │ │ ├── rlimit.go.patch │ │ └── syscall_linux.go.patch │ ├── testing/ │ │ └── run_example.go │ └── time/ │ ├── format_test.go.patch │ ├── internal_test.go.patch │ ├── sleep_test.go.patch │ ├── time_test.go.patch │ ├── tzdata_test.go.patch │ ├── zoneinfo_test.go.patch │ ├── zoneinfo_unix.go.patch │ └── zoneinfo_unix_test.go.patch ├── 1.23_windows/ │ ├── internal/ │ │ └── testenv/ │ │ ├── exec.go.patch │ │ └── testenv.go.patch │ └── runtime/ │ ├── cgo/ │ │ ├── gcc_windows_amd64.c.patch │ │ └── libcgo.h.patch │ ├── os_windows.go.patch │ ├── signal_windows.go.patch │ ├── syscall_windows.go.patch │ └── syscall_windows_test.go.patch ├── 1.24_linux/ │ ├── internal/ │ │ ├── reflectlite/ │ │ │ └── reflect_mirror_test.go.patch │ │ ├── runtime/ │ │ │ └── syscall/ │ │ │ ├── asm_linux_amd64.s.patch │ │ │ ├── asm_linux_arm64.s.patch │ │ │ ├── syscall_linux.go.patch │ │ │ └── syscall_linux_test.go.patch │ │ ├── syscall/ │ │ │ └── unix/ │ │ │ └── fcntl_unix.go.patch │ │ └── testenv/ │ │ ├── exec.go.patch │ │ ├── testenv.go.patch │ │ ├── testenv_notunix.go.patch │ │ └── testenv_unix.go.patch │ ├── math/ │ │ ├── big/ │ │ │ └── link_test.go.patch │ │ └── rand/ │ │ └── default_test.go.patch │ ├── runtime/ │ │ ├── align_test.go.patch │ │ ├── callers_test.go.patch │ │ ├── cgo/ │ │ │ ├── cgo.go.patch │ │ │ ├── gcc_linux_amd64.c.patch │ │ │ ├── gcc_linux_arm64.c.patch │ │ │ ├── gcc_setenv.c.patch │ │ │ ├── gcc_sigaction.c.patch │ │ │ ├── hitsumabushi_clock_linux.c │ │ │ ├── hitsumabushi_cpu_linux.c │ │ │ ├── hitsumabushi_filesystem_linux.c │ │ │ ├── hitsumabushi_futex_linux.c │ │ │ ├── hitsumabushi_mem_linux.c │ │ │ ├── hitsumabushi_syscalls_linux.c │ │ │ ├── hitsumabushi_thread_linux.c │ │ │ ├── linux_syscall.c.patch │ │ │ └── sigaction.go.patch │ │ ├── crash_test.go.patch │ │ ├── crash_unix_test.go.patch │ │ ├── debug/ │ │ │ ├── heapdump_test.go.patch │ │ │ └── panic_test.go.patch │ │ ├── debug_test.go.patch │ │ ├── export_unix_test.go │ │ ├── fds_unix.go.patch │ │ ├── mem_linux.go │ │ ├── memmove_linux_amd64_test.go.patch │ │ ├── metrics_test.go.patch │ │ ├── nbpipe_pipe2.go.patch │ │ ├── nbpipe_test.go.patch │ │ ├── netpoll_epoll.go.patch │ │ ├── netpoll_fake.go.patch │ │ ├── nosan_linux_test.go.patch │ │ ├── os_linux.go.patch │ │ ├── panicnil_test.go.patch │ │ ├── proc_test.go.patch │ │ ├── rand_test.go.patch │ │ ├── runtime1.go.patch │ │ ├── runtime_linux_test.go.patch │ │ ├── runtime_mmap_test.go.patch │ │ ├── runtime_test.go.patch │ │ ├── runtime_unix_test.go.patch │ │ ├── stack_test.go.patch │ │ ├── stubs2.go.patch │ │ ├── stubs3.go.patch │ │ ├── sys_libc.go.patch │ │ ├── sys_linux_amd64.s.patch │ │ ├── sys_linux_arm64.s.patch │ │ ├── time_linux_amd64.s.patch │ │ ├── timeasm.go.patch │ │ ├── timestub.go.patch │ │ ├── timestub2.go.patch │ │ └── traceback_test.go.patch │ ├── strconv/ │ │ └── fp_test.go.patch │ ├── sync/ │ │ └── atomic/ │ │ └── atomic_test.go.patch │ ├── syscall/ │ │ ├── hitsumabushi_stubs_linux_amd64.go │ │ ├── hitsumabushi_stubs_linux_arm64.go │ │ ├── rlimit.go.patch │ │ └── syscall_linux.go.patch │ ├── testing/ │ │ └── run_example.go │ └── time/ │ ├── format_test.go.patch │ ├── internal_test.go.patch │ ├── sleep_test.go.patch │ ├── time_test.go.patch │ ├── tzdata_test.go.patch │ ├── zoneinfo_test.go.patch │ ├── zoneinfo_unix.go.patch │ └── zoneinfo_unix_test.go.patch ├── 1.24_windows/ │ ├── internal/ │ │ └── testenv/ │ │ ├── exec.go.patch │ │ └── testenv.go.patch │ └── runtime/ │ ├── cgo/ │ │ ├── gcc_windows_amd64.c.patch │ │ └── libcgo.h.patch │ ├── os_windows.go.patch │ ├── signal_windows.go.patch │ ├── syscall_windows.go.patch │ └── syscall_windows_test.go.patch ├── 1.25_linux/ │ ├── internal/ │ │ ├── reflectlite/ │ │ │ └── reflect_mirror_test.go.patch │ │ ├── runtime/ │ │ │ ├── cgroup/ │ │ │ │ └── cgroup_linux.go.patch │ │ │ └── syscall/ │ │ │ ├── asm_linux_amd64.s.patch │ │ │ ├── asm_linux_arm64.s.patch │ │ │ ├── syscall_linux.go.patch │ │ │ └── syscall_linux_test.go.patch │ │ ├── syscall/ │ │ │ └── unix/ │ │ │ └── fcntl_unix.go.patch │ │ └── testenv/ │ │ ├── exec.go.patch │ │ ├── testenv.go.patch │ │ ├── testenv_notunix.go.patch │ │ └── testenv_unix.go.patch │ ├── math/ │ │ ├── big/ │ │ │ └── link_test.go.patch │ │ └── rand/ │ │ └── default_test.go.patch │ ├── runtime/ │ │ ├── align_test.go.patch │ │ ├── callers_test.go.patch │ │ ├── cgo/ │ │ │ ├── cgo.go.patch │ │ │ ├── gcc_linux_amd64.c.patch │ │ │ ├── gcc_linux_arm64.c.patch │ │ │ ├── gcc_setenv.c.patch │ │ │ ├── gcc_sigaction.c.patch │ │ │ ├── hitsumabushi_clock_linux.c │ │ │ ├── hitsumabushi_cpu_linux.c │ │ │ ├── hitsumabushi_filesystem_linux.c │ │ │ ├── hitsumabushi_futex_linux.c │ │ │ ├── hitsumabushi_mem_linux.c │ │ │ ├── hitsumabushi_syscalls_linux.c │ │ │ ├── hitsumabushi_thread_linux.c │ │ │ ├── linux_syscall.c.patch │ │ │ └── sigaction.go.patch │ │ ├── crash_test.go.patch │ │ ├── crash_unix_test.go.patch │ │ ├── debug/ │ │ │ ├── heapdump_test.go.patch │ │ │ ├── panic_test.go.patch │ │ │ └── stack_test.go.patch │ │ ├── debug_test.go.patch │ │ ├── decoratemappings_test.go.patch │ │ ├── export_unix_test.go │ │ ├── fds_unix.go.patch │ │ ├── mem_linux.go │ │ ├── memmove_linux_amd64_test.go.patch │ │ ├── metrics_test.go.patch │ │ ├── nbpipe_pipe2.go.patch │ │ ├── nbpipe_test.go.patch │ │ ├── netpoll_epoll.go.patch │ │ ├── netpoll_fake.go.patch │ │ ├── nosan_linux_test.go.patch │ │ ├── os_linux.go.patch │ │ ├── panicnil_test.go.patch │ │ ├── proc_test.go.patch │ │ ├── rand_test.go.patch │ │ ├── runtime1.go.patch │ │ ├── runtime_linux_test.go.patch │ │ ├── runtime_mmap_test.go.patch │ │ ├── runtime_test.go.patch │ │ ├── runtime_unix_test.go.patch │ │ ├── stack_test.go.patch │ │ ├── stubs2.go.patch │ │ ├── stubs3.go.patch │ │ ├── sys_libc.go.patch │ │ ├── sys_linux_amd64.s.patch │ │ ├── sys_linux_arm64.s.patch │ │ ├── time_linux_amd64.s.patch │ │ ├── timeasm.go.patch │ │ ├── timestub.go.patch │ │ ├── timestub2.go.patch │ │ └── traceback_test.go.patch │ ├── strconv/ │ │ └── fp_test.go.patch │ ├── sync/ │ │ └── atomic/ │ │ └── atomic_test.go.patch │ ├── syscall/ │ │ ├── hitsumabushi_stubs_linux_amd64.go │ │ ├── hitsumabushi_stubs_linux_arm64.go │ │ ├── rlimit.go.patch │ │ └── syscall_linux.go.patch │ ├── testing/ │ │ └── run_example.go │ └── time/ │ ├── format_test.go.patch │ ├── internal_test.go.patch │ ├── sleep_test.go.patch │ ├── time_test.go.patch │ ├── tzdata_test.go.patch │ ├── zoneinfo_test.go.patch │ ├── zoneinfo_unix.go.patch │ └── zoneinfo_unix_test.go.patch ├── 1.25_windows/ │ ├── internal/ │ │ └── testenv/ │ │ ├── exec.go.patch │ │ └── testenv.go.patch │ └── runtime/ │ ├── cgo/ │ │ ├── gcc_windows_amd64.c.patch │ │ └── libcgo.h.patch │ ├── os_windows.go.patch │ ├── signal_windows.go.patch │ ├── syscall_windows.go.patch │ └── syscall_windows_test.go.patch ├── 1.26_linux/ │ ├── internal/ │ │ ├── reflectlite/ │ │ │ └── reflect_mirror_test.go.patch │ │ ├── runtime/ │ │ │ ├── cgroup/ │ │ │ │ └── cgroup_linux.go.patch │ │ │ └── syscall/ │ │ │ └── linux/ │ │ │ ├── asm_linux_amd64.s.patch │ │ │ ├── asm_linux_arm64.s.patch │ │ │ ├── syscall_linux.go.patch │ │ │ └── syscall_linux_test.go.patch │ │ ├── strconv/ │ │ │ └── fp_test.go.patch │ │ ├── syscall/ │ │ │ └── unix/ │ │ │ └── fcntl_unix.go.patch │ │ └── testenv/ │ │ ├── exec.go.patch │ │ ├── testenv.go.patch │ │ ├── testenv_notunix.go.patch │ │ └── testenv_unix.go.patch │ ├── math/ │ │ ├── big/ │ │ │ └── link_test.go.patch │ │ └── rand/ │ │ └── default_test.go.patch │ ├── runtime/ │ │ ├── align_test.go.patch │ │ ├── asm_arm64.s.patch │ │ ├── callers_test.go.patch │ │ ├── cgo/ │ │ │ ├── cgo.go.patch │ │ │ ├── gcc_clearenv.c.patch │ │ │ ├── gcc_linux_amd64.c.patch │ │ │ ├── gcc_linux_arm64.c.patch │ │ │ ├── gcc_setenv.c.patch │ │ │ ├── gcc_sigaction.c.patch │ │ │ ├── hitsumabushi_clock_linux.c │ │ │ ├── hitsumabushi_cpu_linux.c │ │ │ ├── hitsumabushi_filesystem_linux.c │ │ │ ├── hitsumabushi_futex_linux.c │ │ │ ├── hitsumabushi_mem_linux.c │ │ │ ├── hitsumabushi_syscalls_linux.c │ │ │ ├── hitsumabushi_thread_linux.c │ │ │ ├── linux_syscall.c.patch │ │ │ └── sigaction.go.patch │ │ ├── crash_test.go.patch │ │ ├── crash_unix_test.go.patch │ │ ├── debug/ │ │ │ ├── heapdump_test.go.patch │ │ │ ├── panic_test.go.patch │ │ │ └── stack_test.go.patch │ │ ├── debug_test.go.patch │ │ ├── decoratemappings_test.go.patch │ │ ├── export_unix_test.go │ │ ├── fds_unix.go.patch │ │ ├── mem_linux.go │ │ ├── memmove_linux_amd64_test.go.patch │ │ ├── metrics_test.go.patch │ │ ├── nbpipe_pipe2.go.patch │ │ ├── nbpipe_test.go.patch │ │ ├── netpoll_epoll.go.patch │ │ ├── netpoll_fake.go.patch │ │ ├── nosan_linux_test.go.patch │ │ ├── os_linux.go.patch │ │ ├── os_linux64.go.patch │ │ ├── panicnil_test.go.patch │ │ ├── proc_test.go.patch │ │ ├── rand_test.go.patch │ │ ├── runtime1.go.patch │ │ ├── runtime_linux_test.go.patch │ │ ├── runtime_mmap_test.go.patch │ │ ├── runtime_test.go.patch │ │ ├── runtime_unix_test.go.patch │ │ ├── stack_test.go.patch │ │ ├── stubs2.go.patch │ │ ├── stubs3.go.patch │ │ ├── sys_libc.go.patch │ │ ├── sys_linux_amd64.s.patch │ │ ├── sys_linux_arm64.s.patch │ │ ├── time_linux_amd64.s.patch │ │ ├── timeasm.go.patch │ │ ├── timestub.go.patch │ │ ├── timestub2.go.patch │ │ └── traceback_test.go.patch │ ├── sync/ │ │ └── atomic/ │ │ └── atomic_test.go.patch │ ├── syscall/ │ │ ├── hitsumabushi_stubs_linux_amd64.go │ │ ├── hitsumabushi_stubs_linux_arm64.go │ │ ├── rlimit.go.patch │ │ └── syscall_linux.go.patch │ ├── testing/ │ │ └── run_example.go │ └── time/ │ ├── format_test.go.patch │ ├── internal_test.go.patch │ ├── sleep_test.go.patch │ ├── time_test.go.patch │ ├── tzdata_test.go.patch │ ├── zoneinfo_test.go.patch │ ├── zoneinfo_unix.go.patch │ └── zoneinfo_unix_test.go.patch ├── 1.26_windows/ │ ├── internal/ │ │ └── testenv/ │ │ ├── exec.go.patch │ │ └── testenv.go.patch │ └── runtime/ │ ├── cgo/ │ │ ├── gcc_windows_amd64.c.patch │ │ └── libcgo.h.patch │ ├── os_windows.go.patch │ ├── signal_windows.go.patch │ ├── syscall_windows.go.patch │ └── syscall_windows_test.go.patch ├── LICENSE ├── README.md ├── doc.go ├── example/ │ └── helloworld/ │ ├── .gitignore │ ├── genoverlayjson.go │ ├── main.c │ ├── main.go │ ├── run.sh │ └── run_cross.sh ├── go.mod ├── overlay.go ├── patch.go └── test.go ================================================ FILE CONTENTS ================================================ ================================================ FILE: .github/workflows/test.yml ================================================ name: Test on: [push, pull_request] jobs: test: strategy: matrix: os: [ubuntu-latest, windows-latest] go: ['1.19.13', '1.20.14', '1.21.13', '1.22.12', '1.23.12', '1.24.13', '1.25.9', '1.26.2'] name: Test with Go ${{ matrix.go }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} defaults: run: shell: bash steps: - name: Checkout uses: actions/checkout@v4 - name: Set up the prerequisites if: runner.os == 'Linux' run: | sudo apt-get update sudo apt-get install -y gcc-aarch64-linux-gnu qemu-user - name: Set up Go uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} - name: Test (Linux, arm64) if: runner.os == 'Linux' run: | GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v fmt" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/abi" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/cpu" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/fmtsort" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/reflectlite" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/unsafeheader" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v math" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v math/big" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v math/bits" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v math/cmplx" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v math/rand" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v -test.short runtime" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v runtime/debug" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v strconv" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v strings" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v sort" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v sync" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v sync/atomic" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v time" - name: Test (Linux, arm64, Go <= 1.22) if: runner.os == 'Linux' && (startsWith(matrix.go, '1.19.') || startsWith(matrix.go, '1.20.') || startsWith(matrix.go, '1.21.') || startsWith(matrix.go, '1.22.')) run: | GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/itoa" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v runtime/internal/atomic" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v runtime/internal/math" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v runtime/internal/sys" - name: Test (Linux, arm64, Go == 1.23) if: runner.os == 'Linux' && startsWith(matrix.go, '1.23.') run: | GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/itoa" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/runtime/atomic" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v runtime/internal/math" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v runtime/internal/sys" - name: Test (Linux, arm64, Go >= 1.24 && <= 1.25) if: runner.os == 'Linux' && (startsWith(matrix.go, '1.24.') || startsWith(matrix.go, '1.25.')) run: | GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/itoa" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/runtime/atomic" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/runtime/math" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/runtime/sys" - name: Test (Linux, arm64, Go == 1.26) if: runner.os == 'Linux' && startsWith(matrix.go, '1.26.') run: | GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/strconv" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/runtime/atomic" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/runtime/math" GOARCH=arm64 go run test.go -qemu -args="-test.run=^Test -test.v internal/runtime/sys" - name: Test (amd64) run: | go run test.go -args="-test.run=^Test -test.v fmt" go run test.go -args="-test.run=^Test -test.v internal/abi" go run test.go -args="-test.run=^Test -test.v internal/cpu" go run test.go -args="-test.run=^Test -test.v internal/fmtsort" go run test.go -args="-test.run=^Test -test.v internal/reflectlite" go run test.go -args="-test.run=^Test -test.v internal/unsafeheader" go run test.go -args="-test.run=^Test -test.v math" go run test.go -args="-test.run=^Test -test.v math/big" go run test.go -args="-test.run=^Test -test.v math/bits" go run test.go -args="-test.run=^Test -test.v math/cmplx" # math/rand's TestDefaultRace doesn't work well by default. # Set an environment to do the default tests. GO_RAND_TEST_HELPER_CODE=1 go run test.go -args="-test.run=^Test -test.v math/rand" go run test.go -args="-test.run=^Test -test.v runtime/debug" go run test.go -args="-test.run=^Test -test.v strconv" go run test.go -args="-test.run=^Test -test.v strings" go run test.go -args="-test.run=^Test -test.v sort" go run test.go -args="-test.run=^Test -test.v sync" go run test.go -args="-test.run=^Test -test.v sync/atomic" go run test.go -args="-test.run=^Test -test.v time" - name: Test (amd64, Go <= 1.22) if: startsWith(matrix.go, '1.19.') || startsWith(matrix.go, '1.20.') || startsWith(matrix.go, '1.21.') || startsWith(matrix.go, '1.22.') run: | go run test.go -args="-test.run=^Test -test.v internal/itoa" go run test.go -args="-test.run=^Test -test.v runtime/internal/atomic" go run test.go -args="-test.run=^Test -test.v runtime/internal/math" go run test.go -args="-test.run=^Test -test.v runtime/internal/sys" - name: Test (amd64, Go == 1.23) if: startsWith(matrix.go, '1.23.') run: | go run test.go -args="-test.run=^Test -test.v internal/itoa" go run test.go -args="-test.run=^Test -test.v internal/runtime/atomic" go run test.go -args="-test.run=^Test -test.v runtime/internal/math" go run test.go -args="-test.run=^Test -test.v runtime/internal/sys" - name: Test (amd64, Go >= 1.24 && <= 1.25) if: startsWith(matrix.go, '1.24.') || startsWith(matrix.go, '1.25.') run: | go run test.go -args="-test.run=^Test -test.v internal/itoa" go run test.go -args="-test.run=^Test -test.v internal/runtime/atomic" go run test.go -args="-test.run=^Test -test.v internal/runtime/math" go run test.go -args="-test.run=^Test -test.v internal/runtime/sys" - name: Test (amd64, Go >= 1.26) # strconv/ftoa.go is missing in 1.26. if: startsWith(matrix.go, '1.26.') run: | go run test.go -args="-test.run=^Test -test.v internal/strconv" go run test.go -args="-test.run=^Test -test.v internal/runtime/atomic" go run test.go -args="-test.run=^Test -test.v internal/runtime/math" go run test.go -args="-test.run=^Test -test.v internal/runtime/sys" - name: Test (amd64, runtime) # Skip runtime tests with Go 1.19 and Windows, as there is an issue (probably golang/go#51007 and golang/go#57455). if: runner.os == 'Linux' || !startsWith(matrix.go, '1.19.') run: | go run test.go -args="-test.run=^Test -test.v -test.short runtime" ================================================ FILE: .gitignore ================================================ *~ .DS_Store *.a ================================================ FILE: 1.19_linux/internal/reflectlite/reflect_mirror_test.go.patch ================================================ //--from func TestMirrorWithReflect(t *testing.T) { //--to func TestMirrorWithReflect(t *testing.T) { t.Skip("file is not supported in this environment") return ================================================ FILE: 1.19_linux/internal/testenv/testenv.go.patch ================================================ //--from func HasGoBuild() bool { if os.Getenv("GO_GCFLAGS") != "" { // It's too much work to require every caller of the go command // to pass along "-gcflags="+os.Getenv("GO_GCFLAGS"). // For now, if $GO_GCFLAGS is set, report that we simply can't // run go build. return false } switch runtime.GOOS { case "android", "js", "ios": return false } return true } //--to func HasGoBuild() bool { return false } //--from func HasExec() bool { switch runtime.GOOS { case "js", "ios": return false } return true } //--to func HasExec() bool { return false } ================================================ FILE: 1.19_linux/internal/testenv/testenv_notunix.go.patch ================================================ //--from //go:build windows || plan9 || (js && wasm) //--to //go:build windows || plan9 || (js && wasm) || linux ================================================ FILE: 1.19_linux/internal/testenv/testenv_unix.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.19_linux/math/big/link_test.go.patch ================================================ //--from import ( "bytes" "internal/testenv" "os" "os/exec" "path/filepath" "testing" ) //--to import ( "testing" ) //--from func TestLinkerGC(t *testing.T) { if testing.Short() { t.Skip("skipping in short mode") } t.Parallel() tmp := t.TempDir() goBin := testenv.GoToolPath(t) goFile := filepath.Join(tmp, "x.go") file := []byte(`package main import _ "math/big" func main() {} `) if err := os.WriteFile(goFile, file, 0644); err != nil { t.Fatal(err) } cmd := exec.Command(goBin, "build", "-o", "x.exe", "x.go") cmd.Dir = tmp if out, err := cmd.CombinedOutput(); err != nil { t.Fatalf("compile: %v, %s", err, out) } cmd = exec.Command(goBin, "tool", "nm", "x.exe") cmd.Dir = tmp nm, err := cmd.CombinedOutput() if err != nil { t.Fatalf("nm: %v, %s", err, nm) } const want = "runtime.main" if !bytes.Contains(nm, []byte(want)) { // Test the test. t.Errorf("expected symbol %q not found", want) } bad := []string{ "math/big.(*Float)", "math/big.(*Rat)", "math/big.(*Int)", } for _, sym := range bad { if bytes.Contains(nm, []byte(sym)) { t.Errorf("unexpected symbol %q found", sym) } } if t.Failed() { t.Logf("Got: %s", nm) } } //--to func TestLinkerGC(t *testing.T) { t.Skip("go tools are not supported in this environment") } ================================================ FILE: 1.19_linux/runtime/align_test.go.patch ================================================ //--from import ( "bytes" "go/ast" "go/build" "go/importer" "go/parser" "go/printer" "go/token" "go/types" "os" "regexp" "runtime" "strings" "testing" ) //--to import ( "bytes" "go/ast" "go/build" "go/printer" "go/token" "go/types" "strings" "testing" ) //--from func TestAtomicAlignment(t *testing.T) { // Read the code making the tables above, to see which fields and // variables we are currently checking. checked := map[string]bool{} x, err := os.ReadFile("./align_runtime_test.go") if err != nil { t.Fatalf("read failed: %v", err) } fieldDesc := map[int]string{} r := regexp.MustCompile(`unsafe[.]Offsetof[(](\w+){}[.](\w+)[)]`) matches := r.FindAllStringSubmatch(string(x), -1) for i, v := range matches { checked["field runtime."+v[1]+"."+v[2]] = true fieldDesc[i] = v[1] + "." + v[2] } varDesc := map[int]string{} r = regexp.MustCompile(`unsafe[.]Pointer[(]&(\w+)[)]`) matches = r.FindAllStringSubmatch(string(x), -1) for i, v := range matches { checked["var "+v[1]] = true varDesc[i] = v[1] } // Check all of our alignemnts. This is the actual core of the test. for i, d := range runtime.AtomicFields { if d%8 != 0 { t.Errorf("field alignment of %s failed: offset is %d", fieldDesc[i], d) } } for i, p := range runtime.AtomicVariables { if uintptr(p)%8 != 0 { t.Errorf("variable alignment of %s failed: address is %x", varDesc[i], p) } } // The code above is the actual test. The code below attempts to check // that the tables used by the code above are exhaustive. // Parse the whole runtime package, checking that arguments of // appropriate atomic operations are in the list above. fset := token.NewFileSet() m, err := parser.ParseDir(fset, ".", nil, 0) if err != nil { t.Fatalf("parsing runtime failed: %v", err) } pkg := m["runtime"] // Note: ignore runtime_test and main packages // Filter files by those for the current architecture/os being tested. fileMap := map[string]bool{} for _, f := range buildableFiles(t, ".") { fileMap[f] = true } var files []*ast.File for fname, f := range pkg.Files { if fileMap[fname] { files = append(files, f) } } // Call go/types to analyze the runtime package. var info types.Info info.Types = map[ast.Expr]types.TypeAndValue{} conf := types.Config{Importer: importer.Default()} _, err = conf.Check("runtime", fset, files, &info) if err != nil { t.Fatalf("typechecking runtime failed: %v", err) } // Analyze all atomic.*64 callsites. v := Visitor{t: t, fset: fset, types: info.Types, checked: checked} ast.Walk(&v, pkg) } //--to func TestAtomicAlignment(t *testing.T) { t.Skip("file is not supported in this environment") } ================================================ FILE: 1.19_linux/runtime/callers_test.go.patch ================================================ //--from func TestCallersNilPointerPanic(t *testing.T) { // Make sure we don't have any extra frames on the stack (due to // open-coded defer processing) want := []string{"runtime.Callers", "runtime_test.TestCallersNilPointerPanic.func1", "runtime.gopanic", "runtime.panicmem", "runtime.sigpanic", "runtime_test.TestCallersNilPointerPanic"} defer func() { if r := recover(); r == nil { t.Fatal("did not panic") } pcs := make([]uintptr, 20) pcs = pcs[:runtime.Callers(0, pcs)] testCallersEqual(t, pcs, want) }() var p *int if *p == 3 { t.Fatal("did not see nil pointer panic") } } //--to func TestCallersNilPointerPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } //--from func TestCallersDeferNilFuncPanic(t *testing.T) { // Make sure we don't have any extra frames on the stack. We cut off the check // at runtime.sigpanic, because non-open-coded defers (which may be used in // non-opt or race checker mode) include an extra 'deferreturn' frame (which is // where the nil pointer deref happens). state := 1 want := []string{"runtime.Callers", "runtime_test.TestCallersDeferNilFuncPanic.func1", "runtime.gopanic", "runtime.panicmem", "runtime.sigpanic"} defer func() { if r := recover(); r == nil { t.Fatal("did not panic") } pcs := make([]uintptr, 20) pcs = pcs[:runtime.Callers(0, pcs)] testCallersEqual(t, pcs, want) if state == 1 { t.Fatal("nil defer func panicked at defer time rather than function exit time") } }() var f func() defer f() // Use the value of 'state' to make sure nil defer func f causes panic at // function exit, rather than at the defer statement. state = 2 } //--to func TestCallersDeferNilFuncPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } //--from func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { state := 1 want := []string{"runtime.Callers", "runtime_test.TestCallersDeferNilFuncPanicWithLoop.func1", "runtime.gopanic", "runtime.panicmem", "runtime.sigpanic", "runtime.deferreturn", "runtime_test.TestCallersDeferNilFuncPanicWithLoop"} defer func() { if r := recover(); r == nil { t.Fatal("did not panic") } pcs := make([]uintptr, 20) pcs = pcs[:runtime.Callers(0, pcs)] testCallersEqual(t, pcs, want) if state == 1 { t.Fatal("nil defer func panicked at defer time rather than function exit time") } }() for i := 0; i < 1; i++ { var f func() defer f() } // Use the value of 'state' to make sure nil defer func f causes panic at // function exit, rather than at the defer statement. state = 2 } //--to func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } ================================================ FILE: 1.19_linux/runtime/cgo/cgo.go.patch ================================================ //--from */ import "C" //--to #cgo !darwin LDFLAGS: -Wl,-unresolved-symbols=ignore-all #cgo darwin LDFLAGS: -Wl,-undefined,dynamic_lookup */ import "C" ================================================ FILE: 1.19_linux/runtime/cgo/gcc_linux_arm64.c.patch ================================================ //--from void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--to void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 16 * 4096); // Hack for some special environments pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--from void x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase) { pthread_attr_t *attr; size_t size; /* The memory sanitizer distributed with versions of clang before 3.8 has a bug: if you call mmap before malloc, mmap may return an address that is later overwritten by the msan library. Avoid this problem by forcing a call to malloc here, before we ever call malloc. This is only required for the memory sanitizer, so it's unfortunate that we always run it. It should be possible to remove this when we no longer care about versions of clang before 3.8. The test for this is misc/cgo/testsanitizers. GCC works hard to eliminate a seemingly unnecessary call to malloc, so we actually use the memory we allocate. */ setg_gcc = setg; attr = (pthread_attr_t*)malloc(sizeof *attr); if (attr == NULL) { fatalf("malloc failed: %s", strerror(errno)); } pthread_attr_init(attr); pthread_attr_getstacksize(attr, &size); g->stacklo = (uintptr)&size - size + 4096; pthread_attr_destroy(attr); free(attr); if (x_cgo_inittls) { x_cgo_inittls(tlsg, tlsbase); } } //--to void x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase) { pthread_attr_t *attr; size_t size; /* The memory sanitizer distributed with versions of clang before 3.8 has a bug: if you call mmap before malloc, mmap may return an address that is later overwritten by the msan library. Avoid this problem by forcing a call to malloc here, before we ever call malloc. This is only required for the memory sanitizer, so it's unfortunate that we always run it. It should be possible to remove this when we no longer care about versions of clang before 3.8. The test for this is misc/cgo/testsanitizers. GCC works hard to eliminate a seemingly unnecessary call to malloc, so we actually use the memory we allocate. */ setg_gcc = setg; attr = (pthread_attr_t*)malloc(sizeof *attr); if (attr == NULL) { fatalf("malloc failed: %s", strerror(errno)); } pthread_attr_init(attr); pthread_attr_setstacksize(attr, 16 * 4096); // Hack for some special environments pthread_attr_getstacksize(attr, &size); g->stacklo = (uintptr)&size - size + 4096; pthread_attr_destroy(attr); free(attr); if (x_cgo_inittls) { x_cgo_inittls(tlsg, tlsbase); } } //--from static void* threadentry(void *v) { //--to static void* threadentry(void *v) { extern void hitsumabushi_initializeThread(void); hitsumabushi_initializeThread(); ================================================ FILE: 1.19_linux/runtime/cgo/hitsumabushi_clock_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp) { return clock_gettime(clk_id, tp); } ================================================ FILE: 1.19_linux/runtime/cgo/hitsumabushi_cpu_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int32_t hitsumabushi_getproccount() { return 1; } ================================================ FILE: 1.19_linux/runtime/cgo/hitsumabushi_filesystem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include #include #include "libcgo.h" #include "libcgo_unix.h" static const int kFDOffset = 100; typedef struct { const void* content; size_t content_size; size_t current; int32_t fd; } pseudo_file; // TODO: Do we need to protect this by mutex? static pseudo_file pseudo_files[100]; static pthread_mutex_t* pseudo_file_mutex() { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; return &mutex; } static int32_t open_pseudo_file(const void* content, size_t content_size) { pthread_mutex_lock(pseudo_file_mutex()); int index = 0; int found = 0; for (int i = 0; i < sizeof(pseudo_files) / sizeof(pseudo_file); i++) { if (pseudo_files[i].fd == 0) { index = i; found = 1; break; } } if (!found) { // Too many pseudo files are opened. pthread_mutex_unlock(pseudo_file_mutex()); return -1; } int32_t fd = index + kFDOffset; pseudo_files[index].content = content; pseudo_files[index].content_size = content_size; pseudo_files[index].current = 0; pseudo_files[index].fd = fd; pthread_mutex_unlock(pseudo_file_mutex()); return fd; } static size_t read_pseudo_file(int32_t fd, void *p, int32_t n) { pthread_mutex_lock(pseudo_file_mutex()); int32_t index = fd - kFDOffset; pseudo_file *file = &pseudo_files[index]; size_t rest = file->content_size - file->current; if (rest < n) { n = rest; } memcpy(p, file->content + file->current, n); pseudo_files[index].current += n; pthread_mutex_unlock(pseudo_file_mutex()); return n; } static void close_pseudo_file(int32_t fd) { pthread_mutex_lock(pseudo_file_mutex()); int32_t index = fd - kFDOffset; pseudo_files[index].content = NULL; pseudo_files[index].content_size = 0; pseudo_files[index].current = 0; pseudo_files[index].fd = 0; pthread_mutex_unlock(pseudo_file_mutex()); } int32_t hitsumabushi_closefd(int32_t fd) { if (fd >= kFDOffset) { close_pseudo_file(fd); return 0; } fprintf(stderr, "syscall close(%d) is not implemented\n", fd); return 0; } int32_t hitsumabushi_open(char *name, int32_t mode, int32_t perm) { if (strcmp(name, "/proc/self/auxv") == 0) { static const char auxv[] = "\x06\x00\x00\x00\x00\x00\x00\x00" // _AT_PAGESZ tag (6) "\x00\x10\x00\x00\x00\x00\x00\x00" // 4096 bytes per page "\x00\x00\x00\x00\x00\x00\x00\x00" // Dummy bytes "\x00\x00\x00\x00\x00\x00\x00\x00"; // Dummy bytes return open_pseudo_file(auxv, sizeof(auxv) / sizeof(char)); } if (strcmp(name, "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size") == 0) { static const char hpage_pmd_size[] = "\x30\x5c"; // '0', '\n' return open_pseudo_file(hpage_pmd_size, sizeof(hpage_pmd_size) / sizeof(char)); } fprintf(stderr, "syscall open(%s, %d, %d) is not implemented\n", name, mode, perm); const static int kENOENT = 0x2; return kENOENT; } int32_t hitsumabushi_read(int32_t fd, void *p, int32_t n) { if (fd >= kFDOffset) { return read_pseudo_file(fd, p, n); } fprintf(stderr, "syscall read(%d, %p, %d) is not implemented\n", fd, p, n); const static int kEBADF = 0x9; return kEBADF; } int32_t hitsumabushi_write1(uintptr_t fd, void *p, int32_t n) { static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; int32_t ret = 0; pthread_mutex_lock(&m); switch (fd) { case 1: ret = fwrite(p, 1, n, stdout); fflush(stdout); break; case 2: ret = fwrite(p, 1, n, stderr); fflush(stderr); break; default: fprintf(stderr, "syscall write(%lu, %p, %d) is not implemented\n", fd, p, n); ret = -EBADF; break; } pthread_mutex_unlock(&m); return ret; } int32_t hitsumabushi_lseek(uintptr_t fd, off_t offset, int32_t whence) { fprintf(stderr, "syscall lseek(%lu, %lu, %d) is not implemented\n", fd, offset, whence); return -ENOSYS; } int32_t hitsumabushi_fcntl(int32_t fd, int32_t cmd, int32_t arg) { if (fd == 0 || fd == 1 || fd == 2) { if (cmd == F_GETFL) { return 0; } } fprintf(stderr, "syscall fcntl(%d, %d, %d) is not implemented\n", fd, cmd, arg); return -EBADF; } int32_t hitsumabushi_fstat(int32_t fd, struct stat *stat) { fprintf(stderr, "syscall fstat(%d, %p) is not implemented\n", fd, stat); return -ENOSYS; } int32_t hitsumabushi_renameat(int32_t fd1, char* name1, int32_t fd2, char* name2) { fprintf(stderr, "syscall renameat(%d, %s, %d, %s) is not implemented\n", fd1, name1, fd2, name2); return -ENOSYS; } int32_t hitsumabushi_fstatat(int32_t fd, char* name, struct stat* p, int32_t flags) { fprintf(stderr, "syscall fstatat(%d, %s, %p, %d) is not implemented\n", fd, name, p, flags); return -ENOSYS; } ================================================ FILE: 1.19_linux/runtime/cgo/hitsumabushi_futex_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include #include #include #include static const int kPseudoFutexWait = 0; static const int kPseudoFutexWake = 1; static void pseudo_futex(uint32_t *uaddr, int mode, uint32_t val, const struct timespec *reltime) { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; struct timespec abstime; if (reltime) { // We are not sure CLOCK_REALTIME is correct or not here. // However, this time limit is actually not used as the condition variable is shared by // all the threads. Before the time limit reaches, the thread wakes up in 99.9999...% cases. clock_gettime(CLOCK_REALTIME, &abstime); abstime.tv_sec += reltime->tv_sec; abstime.tv_nsec += reltime->tv_nsec; if (1000000000 <= abstime.tv_nsec) { abstime.tv_sec += 1; abstime.tv_nsec -= 1000000000; } } int ret = pthread_mutex_lock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_lock failed: %d\n", ret); abort(); } switch (mode) { case kPseudoFutexWait: if (reltime) { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_timedwait(&cond, &mutex, &abstime); if (ret && ret != ETIMEDOUT) { fprintf(stderr, "pthread_cond_timedwait failed: %d\n", ret); abort(); } } } else { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_wait(&cond, &mutex); if (ret) { fprintf(stderr, "pthread_cond_wait failed: %d\n", ret); abort(); } } } break; case kPseudoFutexWake: if (val != 1) { fprintf(stderr, "val for waking must be 1 but %d\n", val); abort(); } // TODO: broadcasting is not efficient. Use a mutex for each uaddr. int ret = pthread_cond_broadcast(&cond); if (ret) { fprintf(stderr, "pthread_cond_broadcast failed: %d\n", ret); abort(); } break; } ret = pthread_mutex_unlock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_unlock failed: %d\n", ret); abort(); } } int32_t hitsumabushi_futex(uint32_t *uaddr, int32_t futex_op, uint32_t val, const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3) { enum { kFutexWaitPrivate = 128, kFutexWakePrivate = 129, }; switch (futex_op) { case kFutexWaitPrivate: pseudo_futex(uaddr, kPseudoFutexWait, val, timeout); break; case kFutexWakePrivate: pseudo_futex(uaddr, kPseudoFutexWake, val, NULL); break; } // This function should return the number of awaken threads, but now it is impossible. // Just return 0. return 0; } ================================================ FILE: 1.19_linux/runtime/cgo/hitsumabushi_mem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include void* hitsumabushi_sysReserveOS(void* v, uintptr_t n); void* hitsumabushi_sysAllocOS(uintptr_t n) { return hitsumabushi_sysReserveOS(NULL, n); } void hitsumabushi_sysUnusedOS(void* v, uintptr_t n) { } void hitsumabushi_sysUsedOS(void* v, uintptr_t n) { } void hitsumabushi_sysHugePageOS(void* v, uintptr_t n) { } void hitsumabushi_sysFreeOS(void* v, uintptr_t n) { } void hitsumabushi_sysFaultOS(void* v, uintptr_t n) { } void* hitsumabushi_sysReserveOS(void* v, uintptr_t n) { if (v) { return NULL; } return calloc(n, 1); } void hitsumabushi_sysMapOS(void* v, uintptr_t n) { } ================================================ FILE: 1.19_linux/runtime/cgo/hitsumabushi_syscalls_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include #include // for usleep #include // for size_t #include // for sigset_t and struct sigaction #include "libcgo.h" #include "libcgo_unix.h" typedef unsigned int gid_t; extern int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp); extern int32_t hitsumabushi_getproccount(); void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { abort(); return NULL; } int munmap(void *addr, size_t length) { abort(); return 0; } int pthread_sigmask(int how, const sigset_t *set, sigset_t *oldset) { // Do nothing. return 0; } int setegid(gid_t gid) { // Do nothing. return 0; } int seteuid(uid_t gid) { // Do nothing. return 0; } int setgid(gid_t gid) { // Do nothing. return 0; } int setgroups(size_t size, const gid_t *list) { // Do nothing. return 0; } int setregid(gid_t rgid, gid_t egid) { // Do nothing. return 0; } int setreuid(uid_t ruid, uid_t euid) { // Do nothing. return 0; } int setresgid(gid_t rgid, gid_t egid, gid_t sgid) { // Do nothing. return 0; } int setresuid(uid_t ruid, uid_t euid, uid_t suid) { // Do nothing. return 0; } int setuid(uid_t gid) { // Do nothing. return 0; } int sigaction(int signum, const struct sigaction *act, struct sigaction *oldact) { // Do nothing. return 0; } int sigaddset(sigset_t *set, int signum) { // Do nothing. return 0; } int sigemptyset(sigset_t *set) { // Do nothing. return 0; } int sigfillset(sigset_t *set) { // Do nothing. return 0; } int sigismember(const sigset_t *set, int signum) { // Do nothing. return 0; } uint32_t hitsumabushi_gettid() { uint64_t tid64 = (uint64_t)(pthread_self()); uint32_t tid = (uint32_t)(tid64 >> 32) ^ (uint32_t)(tid64); return tid; } int64_t hitsumabushi_nanotime1() { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_MONOTONIC, &tp); return (int64_t)(tp.tv_sec) * 1000000000ll + (int64_t)tp.tv_nsec; } int32_t hitsumabushi_osyield() { return sched_yield(); } int32_t hitsumabushi_sched_getaffinity(pid_t pid, size_t cpusetsize, void *mask) { int32_t numcpu = hitsumabushi_getproccount(); for (int32_t i = 0; i < numcpu; i += 8) ((unsigned char*)mask)[i / 8] = (unsigned char)((1u << (numcpu - i)) - 1); // https://man7.org/linux/man-pages/man2/sched_setaffinity.2.html // > On success, the raw sched_getaffinity() system call returns the // > number of bytes placed copied into the mask buffer; return (numcpu + 7) / 8; } void hitsumabushi_usleep(useconds_t usec) { usleep(usec); } void hitsumabushi_walltime1(int64_t* sec, int32_t* nsec) { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_REALTIME, &tp); *sec = tp.tv_sec; *nsec = tp.tv_nsec; } void hitsumabushi_exit(int32_t code) { exit(code); } ================================================ FILE: 1.19_linux/runtime/cgo/hitsumabushi_thread_linux.c ================================================ void hitsumabushi_initializeThread(void) { } ================================================ FILE: 1.19_linux/runtime/crash_test.go.patch ================================================ //--from import ( "bytes" "errors" "flag" "fmt" "internal/testenv" "os" "os/exec" "path/filepath" "regexp" "runtime" "strings" "sync" "testing" ) //--to import ( "bytes" "flag" "internal/testenv" "os" "os/exec" "regexp" "runtime" "strings" "sync" "testing" ) //--from func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { if *flagQuick { t.Skip("-quick") } testenv.MustHaveGoBuild(t) testprog.Lock() if testprog.dir == "" { dir, err := os.MkdirTemp("", "go-build") if err != nil { t.Fatalf("failed to create temp directory: %v", err) } testprog.dir = dir toRemove = append(toRemove, dir) } if testprog.target == nil { testprog.target = make(map[string]*buildexe) } name := binary if len(flags) > 0 { name += "_" + strings.Join(flags, "_") } target, ok := testprog.target[name] if !ok { target = &buildexe{} testprog.target[name] = target } dir := testprog.dir // Unlock testprog while actually building, so that other // tests can look up executables that were already built. testprog.Unlock() target.once.Do(func() { // Only do two "go build"'s at a time, // to keep load from getting too high. serializeBuild <- true defer func() { <-serializeBuild }() // Don't get confused if testenv.GoToolPath calls t.Skip. target.err = errors.New("building test called t.Skip") exe := filepath.Join(dir, name+".exe") t.Logf("running go build -o %s %s", exe, strings.Join(flags, " ")) cmd := exec.Command(testenv.GoToolPath(t), append([]string{"build", "-o", exe}, flags...)...) cmd.Dir = "testdata/" + binary out, err := testenv.CleanCmdEnv(cmd).CombinedOutput() if err != nil { target.err = fmt.Errorf("building %s %v: %v\n%s", binary, flags, err, out) } else { target.exe = exe target.err = nil } }) return target.exe, target.err } //--to func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { t.Skip("buildTestProg is not supported in this environment") return "", nil } //--from func TestPanicInlined(t *testing.T) { defer func() { r := recover() if r == nil { t.Fatalf("recover failed") } buf := make([]byte, 2048) n := runtime.Stack(buf, false) buf = buf[:n] if !bytes.Contains(buf, []byte("(*point).negate(")) { t.Fatalf("expecting stack trace to contain call to (*point).negate()") } }() pt := new(point) pt.negate() } //--to func TestPanicInlined(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") defer func() { r := recover() if r == nil { t.Fatalf("recover failed") } buf := make([]byte, 2048) n := runtime.Stack(buf, false) buf = buf[:n] if !bytes.Contains(buf, []byte("(*point).negate(")) { t.Fatalf("expecting stack trace to contain call to (*point).negate()") } }() pt := new(point) pt.negate() } ================================================ FILE: 1.19_linux/runtime/crash_unix_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.19_linux/runtime/debug/heapdump_test.go.patch ================================================ //--from import ( "os" "runtime" . "runtime/debug" "testing" ) //--to import ( "testing" ) //--from func TestWriteHeapDumpNonempty(t *testing.T) { if runtime.GOOS == "js" { t.Skipf("WriteHeapDump is not available on %s.", runtime.GOOS) } f, err := os.CreateTemp("", "heapdumptest") if err != nil { t.Fatalf("TempFile failed: %v", err) } defer os.Remove(f.Name()) defer f.Close() WriteHeapDump(f.Fd()) fi, err := f.Stat() if err != nil { t.Fatalf("Stat failed: %v", err) } const minSize = 1 if size := fi.Size(); size < minSize { t.Fatalf("Heap dump size %d bytes, expected at least %d bytes", size, minSize) } } //--to func TestWriteHeapDumpNonempty(t *testing.T) { t.Skip("file is not supported in this environment") } //--from func TestWriteHeapDumpFinalizers(t *testing.T) { if runtime.GOOS == "js" { t.Skipf("WriteHeapDump is not available on %s.", runtime.GOOS) } f, err := os.CreateTemp("", "heapdumptest") if err != nil { t.Fatalf("TempFile failed: %v", err) } defer os.Remove(f.Name()) defer f.Close() // bug 9172: WriteHeapDump couldn't handle more than one finalizer println("allocating objects") x := &Obj{} runtime.SetFinalizer(x, objfin) y := &Obj{} runtime.SetFinalizer(y, objfin) // Trigger collection of x and y, queueing of their finalizers. println("starting gc") runtime.GC() // Make sure WriteHeapDump doesn't fail with multiple queued finalizers. println("starting dump") WriteHeapDump(f.Fd()) println("done dump") } //--to func TestWriteHeapDumpFinalizers(t *testing.T) { t.Skip("file is not supported in this environment") } //--from func TestWriteHeapDumpTypeName(t *testing.T) { if runtime.GOOS == "js" { t.Skipf("WriteHeapDump is not available on %s.", runtime.GOOS) } f, err := os.CreateTemp("", "heapdumptest") if err != nil { t.Fatalf("TempFile failed: %v", err) } defer os.Remove(f.Name()) defer f.Close() WriteHeapDump(f.Fd()) dummy.M() dummy2.M() } //--to func TestWriteHeapDumpTypeName(t *testing.T) { t.Skip("file is not supported in this environment") } ================================================ FILE: 1.19_linux/runtime/debug/panic_test.go.patch ================================================ //--from import ( "runtime" "runtime/debug" "syscall" "testing" "unsafe" ) //--to import ( "testing" ) //--from func TestPanicOnFault(t *testing.T) { if runtime.GOARCH == "s390x" { t.Skip("s390x fault addresses are missing the low order bits") } if runtime.GOOS == "ios" { t.Skip("iOS doesn't provide fault addresses") } if runtime.GOOS == "netbsd" && runtime.GOARCH == "arm" { t.Skip("netbsd-arm doesn't provide fault address (golang.org/issue/45026)") } m, err := syscall.Mmap(-1, 0, 0x1000, syscall.PROT_READ /* Note: no PROT_WRITE */, syscall.MAP_SHARED|syscall.MAP_ANON) if err != nil { t.Fatalf("can't map anonymous memory: %s", err) } defer syscall.Munmap(m) old := debug.SetPanicOnFault(true) defer debug.SetPanicOnFault(old) const lowBits = 0x3e7 defer func() { r := recover() if r == nil { t.Fatalf("write did not fault") } type addressable interface { Addr() uintptr } a, ok := r.(addressable) if !ok { t.Fatalf("fault does not contain address") } want := uintptr(unsafe.Pointer(&m[lowBits])) got := a.Addr() if got != want { t.Fatalf("fault address %x, want %x", got, want) } }() m[lowBits] = 1 // will fault } //--to func TestPanicOnFault(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } ================================================ FILE: 1.19_linux/runtime/debug_test.go.patch ================================================ //--from //go:build (amd64 || arm64) && linux && !race //--to //go:build ignore ================================================ FILE: 1.19_linux/runtime/export_linux_test.go.patch ================================================ //--from import "unsafe" //--to //--from func Epollctl(epfd, op, fd int32, ev unsafe.Pointer) int32 { return epollctl(epfd, op, fd, (*epollevent)(ev)) } //--to ================================================ FILE: 1.19_linux/runtime/export_unix_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.19_linux/runtime/internal/syscall/asm_linux_amd64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0 // a6 already in R9. // a5 already in R8. MOVQ SI, R10 // a4 MOVQ DI, DX // a3 MOVQ CX, SI // a2 MOVQ BX, DI // a1 // num already in AX. SYSCALL CMPQ AX, $0xfffffffffffff001 JLS ok NEGQ AX MOVQ AX, CX // errno MOVQ $-1, AX // r1 MOVQ $0, BX // r2 RET ok: // r1 already in AX. MOVQ DX, BX // r2 MOVQ $0, CX // errno RET //--to ================================================ FILE: 1.19_linux/runtime/internal/syscall/asm_linux_arm64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0-80 MOVD num+0(FP), R8 // syscall entry MOVD a1+8(FP), R0 MOVD a2+16(FP), R1 MOVD a3+24(FP), R2 MOVD a4+32(FP), R3 MOVD a5+40(FP), R4 MOVD a6+48(FP), R5 SVC CMN $4095, R0 BCC ok MOVD $-1, R4 MOVD R4, r1+56(FP) MOVD ZR, r2+64(FP) NEG R0, R0 MOVD R0, errno+72(FP) RET ok: MOVD R0, r1+56(FP) MOVD R1, r2+64(FP) MOVD ZR, errno+72(FP) RET //--to ================================================ FILE: 1.19_linux/runtime/internal/syscall/syscall_linux.go.patch ================================================ //--from func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) //--to func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { println("not implemented syscall at Syscall6", num) panic("syscall.Syscall6") return 0, 0, 0x26 // ENOSYS } //--from func syscall_RawSyscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { return Syscall6(num, a1, a2, a3, a4, a5, a6) } //--to func syscall_RawSyscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { println("not implemented syscall at RawSyscall6", num) panic("syscall.RawSyscall6") return 0, 0, 0x26 // ENOSYS } ================================================ FILE: 1.19_linux/runtime/mem_linux.go ================================================ // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This implementation is the most fundamental and minimal allocations like Wasm. // Malloced memory regions are never freed. package runtime import ( "internal/abi" "unsafe" ) // Don't split the stack as this method may be invoked without a valid G, which // prevents us from allocating more stack. // //go:nosplit //go:cgo_unsafe_args func sysAllocOS(n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysAllocOS_trampoline)), unsafe.Pointer(&n)) return } func sysAllocOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit //go:cgo_unsafe_args func sysUnusedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUnusedOS_trampoline)), unsafe.Pointer(&v)) } func sysUnusedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysUsedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUsedOS_trampoline)), unsafe.Pointer(&v)) } func sysUsedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysHugePageOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysHugePageOS_trampoline)), unsafe.Pointer(&v)) } func sysHugePageOS_trampoline(n uintptr, size uintptr) // Don't split the stack as this function may be invoked without a valid G, // which prevents us from allocating more stack. // //go:nosplit //go:cgo_unsafe_args func sysFreeOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFreeOS_trampoline)), unsafe.Pointer(&v)) } func sysFreeOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysFaultOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFaultOS_trampoline)), unsafe.Pointer(&v)) } func sysFaultOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysReserveOS(v unsafe.Pointer, n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysReserveOS_trampoline)), unsafe.Pointer(&v)) return } func sysReserveOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit //go:cgo_unsafe_args func sysMapOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysMapOS_trampoline)), unsafe.Pointer(&v)) } func sysMapOS_trampoline(n uintptr, size uintptr) ================================================ FILE: 1.19_linux/runtime/memmove_linux_amd64_test.go.patch ================================================ //--from func TestMemmoveOverflow(t *testing.T) { //--to func TestMemmoveOverflow(t *testing.T) { t.Skip("file is not supported in this environment") return ================================================ FILE: 1.19_linux/runtime/nbpipe_pipe2.go.patch ================================================ //--from //go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris //--to //go:build dragonfly || freebsd || netbsd || openbsd || solaris ================================================ FILE: 1.19_linux/runtime/nbpipe_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.19_linux/runtime/netpoll_epoll.go.patch ================================================ //--from //go:build linux //--to //go:build ignore ================================================ FILE: 1.19_linux/runtime/netpoll_fake.go.patch ================================================ //--from //go:build js && wasm //--to //go:build linux ================================================ FILE: 1.19_linux/runtime/norace_linux_test.go.patch ================================================ //--from import ( "internal/abi" "runtime" "testing" "time" "unsafe" ) //--to import ( "testing" ) //--from func TestNewOSProc0(t *testing.T) { runtime.NewOSProc0(0x800000, unsafe.Pointer(abi.FuncPCABIInternal(newOSProcCreated))) check := time.NewTicker(100 * time.Millisecond) defer check.Stop() end := time.After(5 * time.Second) for { select { case <-check.C: if newOSProcDone { return } case <-end: t.Fatalf("couldn't create new OS process") } } } //--to func TestNewOSProc0(t *testing.T) { t.Skip("newosproc0 is not supported in this environment") } ================================================ FILE: 1.19_linux/runtime/os_linux.go.patch ================================================ //--from import ( "internal/abi" "internal/goarch" "runtime/internal/atomic" "runtime/internal/syscall" "unsafe" ) //--to import ( "internal/abi" "runtime/internal/atomic" "runtime/internal/syscall" "unsafe" ) //--from //go:noescape func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 //--to //go:nosplit //go:cgo_unsafe_args func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 { ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(futex_trampoline)), unsafe.Pointer(&addr)) return ret } func futex_trampoline(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 //--from func sysargs(argc int32, argv **byte) { n := argc + 1 // skip over argv, envp to get to auxv for argv_index(argv, n) != nil { n++ } // skip NULL separator n++ // now argv+n is auxv auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*goarch.PtrSize)) if sysauxv(auxv[:]) != 0 { return } // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } var buf [128]uintptr n = read(fd, noescape(unsafe.Pointer(&buf[0])), int32(unsafe.Sizeof(buf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. buf[len(buf)-2] = _AT_NULL sysauxv(buf[:]) } //--to func sysargs(argc int32, argv **byte) { // argc/argv is not reliable on some machines. // Skip analysing them. // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } var buf [128]uintptr n := read(fd, noescape(unsafe.Pointer(&buf[0])), int32(unsafe.Sizeof(buf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. buf[len(buf)-2] = _AT_NULL sysauxv(buf[:]) } //--from func getRandomData(r []byte) { if startupRandomData != nil { n := copy(r, startupRandomData) extendRandom(r, n) return } fd := open(&urandom_dev[0], 0 /* O_RDONLY */, 0) n := read(fd, unsafe.Pointer(&r[0]), int32(len(r))) closefd(fd) extendRandom(r, int(n)) } //--to // Use getRandomData in os_plan9.go. //go:nosplit func getRandomData(r []byte) { // inspired by wyrand see hash32.go for detail t := nanotime() v := getg().m.procid ^ uint64(t) for len(r) > 0 { v ^= 0xa0761d6478bd642f v *= 0xe7037ed1a0b428db size := 8 if len(r) < 8 { size = len(r) } for i := 0; i < size; i++ { r[i] = byte(v >> (8 * i)) } r = r[size:] v = v>>32 | v<<32 } } //--from func gettid() uint32 //--to //go:nosplit //go:cgo_unsafe_args func gettid() (tid uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(gettid_trampoline)), unsafe.Pointer(&tid)) return } func gettid_trampoline() uint32 //--from //go:noescape func sigaltstack(new, old *stackt) //--to func sigaltstack(new, old *stackt) { // Do nothing. } //--from func sigprocmask(how int32, new, old *sigset) { rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--to func sigprocmask(how int32, new, old *sigset) { // Do nothing. // rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--from func raise(sig uint32) //--to func raise(sig uint32) { // Do nothing } //--from func raiseproc(sig uint32) //--to func raiseproc(sig uint32) { // Do nothing } //--from //go:noescape func sched_getaffinity(pid, len uintptr, buf *byte) int32 //--to //go:nosplit //go:cgo_unsafe_args func sched_getaffinity(pid, len uintptr, buf *byte) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(sched_getaffinity_trampoline)), unsafe.Pointer(&pid)) } func sched_getaffinity_trampoline(pid, len uintptr, buf *byte) int32 //--from func osyield() //--to //go:nosplit //go:cgo_unsafe_args func osyield() { libcCall(unsafe.Pointer(abi.FuncPCABI0(osyield_trampoline)), nil) } func osyield_trampoline() //--from func signalM(mp *m, sig int) { tgkill(getpid(), int(mp.procid), sig) } //--to func signalM(mp *m, sig int) { // Do nothiing. } //--from func runPerThreadSyscall() { gp := getg() if gp.m.needPerThreadSyscall.Load() == 0 { return } args := perThreadSyscall r1, r2, errno := syscall.Syscall6(args.trap, args.a1, args.a2, args.a3, args.a4, args.a5, args.a6) if GOARCH == "ppc64" || GOARCH == "ppc64le" { // TODO(https://go.dev/issue/51192 ): ppc64 doesn't use r2. r2 = 0 } if errno != 0 || r1 != args.r1 || r2 != args.r2 { print("trap:", args.trap, ", a123456=[", args.a1, ",", args.a2, ",", args.a3, ",", args.a4, ",", args.a5, ",", args.a6, "]\n") print("results: got {r1=", r1, ",r2=", r2, ",errno=", errno, "}, want {r1=", args.r1, ",r2=", args.r2, ",errno=0\n") fatal("AllThreadsSyscall6 results differ between threads; runtime corrupted") } gp.m.needPerThreadSyscall.Store(0) } //--to func runPerThreadSyscall() { // Do nothing. // needPerThreadSyscall should never be 1 as syscall_runtime_doAllThreadsSyscall is not available with Cgo. } //--append //go:linkname hitsumabushi_closefd hitsumabushi_closefd //go:cgo_import_static hitsumabushi_closefd var hitsumabushi_closefd byte //go:linkname hitsumabushi_exit hitsumabushi_exit //go:cgo_import_static hitsumabushi_exit var hitsumabushi_exit byte //go:linkname hitsumabushi_gettid hitsumabushi_gettid //go:cgo_import_static hitsumabushi_gettid var hitsumabushi_gettid byte //go:linkname hitsumabushi_nanotime1 hitsumabushi_nanotime1 //go:cgo_import_static hitsumabushi_nanotime1 var hitsumabushi_nanotime1 byte //go:linkname hitsumabushi_open hitsumabushi_open //go:cgo_import_static hitsumabushi_open var hitsumabushi_open byte //go:linkname hitsumabushi_osyield hitsumabushi_osyield //go:cgo_import_static hitsumabushi_osyield var hitsumabushi_osyield byte //go:linkname hitsumabushi_read hitsumabushi_read //go:cgo_import_static hitsumabushi_read var hitsumabushi_read byte //go:linkname hitsumabushi_sched_getaffinity hitsumabushi_sched_getaffinity //go:cgo_import_static hitsumabushi_sched_getaffinity var hitsumabushi_sched_getaffinity byte //go:linkname hitsumabushi_usleep hitsumabushi_usleep //go:cgo_import_static hitsumabushi_usleep var hitsumabushi_usleep byte //go:linkname hitsumabushi_walltime1 hitsumabushi_walltime1 //go:cgo_import_static hitsumabushi_walltime1 var hitsumabushi_walltime1 byte //go:linkname hitsumabushi_write1 hitsumabushi_write1 //go:cgo_import_static hitsumabushi_write1 var hitsumabushi_write1 byte //go:nosplit //go:cgo_unsafe_args func fcntl1(fd, cmd, arg int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fcntl_trampoline)), unsafe.Pointer(&fd)) } func fcntl_trampoline() //go:nosplit //go:cgo_unsafe_args func fstat1(fd int, stat unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstat_trampoline)), unsafe.Pointer(&fd)) } func fstat_trampoline(fd int, stat unsafe.Pointer) int32 //go:nosplit //go:cgo_unsafe_args func lseek1(fd int, offset int64, whence int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(lseek_trampoline)), unsafe.Pointer(&fd)) } func lseek_trampoline() //go:nosplit //go:cgo_unsafe_args func renameat(fd1 int, name1 unsafe.Pointer, fd2 int, name2 unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(renameat_trampoline)), unsafe.Pointer(&fd1)) } func renameat_trampoline() //go:nosplit //go:cgo_unsafe_args func fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstatat_trampoline)), unsafe.Pointer(&fd)) } func fstatat_trampoline() ================================================ FILE: 1.19_linux/runtime/proc_test.go.patch ================================================ //--from func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) testGoroutineParallelism2(t, false, true) testGoroutineParallelism2(t, true, true) } //--to func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) //testGoroutineParallelism2(t, false, true) //testGoroutineParallelism2(t, true, true) } ================================================ FILE: 1.19_linux/runtime/runtime1.go.patch ================================================ //--from func argv_index(argv **byte, i int32) *byte { return *(**byte)(add(unsafe.Pointer(argv), uintptr(i)*goarch.PtrSize)) } //--to func argv_index(argv **byte, i int32) *byte { return nil } //--from func args(c int32, v **byte) { argc = c argv = v sysargs(c, v) } //--to func args(c int32, v **byte) { // In the original code, physPageSize is determined at sysargs. // Hitsumabushi gives an initial value for physPageSize at its declaration, so sysargs doesn't have to be called. } ================================================ FILE: 1.19_linux/runtime/runtime_linux_test.go.patch ================================================ //--from func TestMincoreErrorSign(t *testing.T) { var dst byte v := Mincore(Add(unsafe.Pointer(new(int32)), 1), 1, &dst) const EINVAL = 0x16 if v != -EINVAL { t.Errorf("mincore = %v, want %v", v, -EINVAL) } } //--to func TestMincoreErrorSign(t *testing.T) { t.Skip("mincore is not supported in this environment") } //--from func TestEpollctlErrorSign(t *testing.T) { v := Epollctl(-1, 1, -1, unsafe.Pointer(&EpollEvent{})) const EBADF = 0x09 if v != -EBADF { t.Errorf("epollctl = %v, want %v", v, -EBADF) } } //--to func TestEpollctlErrorSign(t *testing.T) { t.Skip("Epollctl is not supported in this environment") } ================================================ FILE: 1.19_linux/runtime/runtime_mmap_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.19_linux/runtime/runtime_test.go.patch ================================================ //--from func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { if GOOS == "js" { t.Skip("js does not support catching faults") } defer func() { if err := recover(); err != nil { *nfault++ } }() // The read should fault, except that sometimes we hit // addresses that have had C or kernel pages mapped there // readable by user code. So just log the content. // If no addresses fault, we'll fail the test. v := *(*byte)(unsafe.Pointer(addr)) t.Logf("addr %#x: %#x\n", addr, v) } //--to func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { t.Skip("catching faults is not supported in this environment") } ================================================ FILE: 1.19_linux/runtime/runtime_unix_test.go.patch ================================================ //--from //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || plan9 //--to //go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || plan9 ================================================ FILE: 1.19_linux/runtime/stack_test.go.patch ================================================ //--from func TestDeferLeafSigpanic(t *testing.T) { // Push a defer that will walk the stack. defer func() { if err := recover(); err == nil { t.Fatal("expected panic from nil pointer") } GC() }() // Call a leaf function. We must set up the exact call stack: // // defering function -> leaf function -> sigpanic // // On LR machines, the leaf function will have the same SP as // the SP pushed for the defer frame. testDeferLeafSigpanic1() } //--to func TestDeferLeafSigpanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } //--from func TestStackWrapperStackPanic(t *testing.T) { t.Run("sigpanic", func(t *testing.T) { // nil calls to interface methods cause a sigpanic. testStackWrapperPanic(t, func() { I.M(nil) }, "runtime_test.I.M") }) t.Run("panicwrap", func(t *testing.T) { // Nil calls to value method wrappers call panicwrap. wrapper := (*structWithMethod).nop testStackWrapperPanic(t, func() { wrapper(nil) }, "runtime_test.(*structWithMethod).nop") }) } //--to func TestStackWrapperStackPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } //--from func TestTracebackInlineExcluded(t *testing.T) { defer func() { recover() buf := make([]byte, 4<<10) stk := string(buf[:Stack(buf, false)]) t.Log(stk) if not := "tracebackExcluded"; strings.Contains(stk, not) { t.Errorf("found but did not expect %q", not) } if want := "tracebackNotExcluded"; !strings.Contains(stk, want) { t.Errorf("expected %q in stack", want) } }() tracebackExcluded() } //--to func TestTracebackInlineExcluded(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } ================================================ FILE: 1.19_linux/runtime/stubs2.go.patch ================================================ //--from import ( "runtime/internal/atomic" "unsafe" ) //--to import ( "internal/abi" "runtime/internal/atomic" "unsafe" ) //--from func read(fd int32, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func read(fd int32, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(read_trampoline)), unsafe.Pointer(&fd)) } func read_trampoline(fd int32, p unsafe.Pointer, n int32) int32 //--from func closefd(fd int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func closefd(fd int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(closefd_trampoline)), unsafe.Pointer(&fd)) } func closefd_trampoline(fd int32) int32 //--from func exit(code int32) //--to //go:nosplit //go:cgo_unsafe_args func exit(code int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(exit_trampoline)), unsafe.Pointer(&code)) } func exit_trampoline(code int32) //--from func usleep(usec uint32) //--to //go:nosplit //go:cgo_unsafe_args func usleep(usec uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } func usleep_trampoline(usec uint32) //--from //go:nosplit func usleep_no_g(usec uint32) { usleep(usec) } //--to //go:nosplit //go:cgo_unsafe_args func usleep_no_g(usec uint32) { asmcgocall_no_g(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } //--from //go:noescape func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func write1(fd uintptr, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(write1_trampoline)), unsafe.Pointer(&fd)) } func write1_trampoline(fd uintptr, p unsafe.Pointer, n int32) int32 //--from //go:noescape func open(name *byte, mode, perm int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func open(name *byte, mode, perm int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(open_trampoline)), unsafe.Pointer(&name)) } func open_trampoline(name *byte, mode, perm int32) int32 ================================================ FILE: 1.19_linux/runtime/stubs3.go.patch ================================================ //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func nanotime1() int64 //--to //go:nosplit //go:cgo_unsafe_args func nanotime1() (now int64) { libcCall(unsafe.Pointer(abi.FuncPCABI0(nanotime1_trampoline)), unsafe.Pointer(&now)) return } func nanotime1_trampoline() int64 ================================================ FILE: 1.19_linux/runtime/sys_libc.go.patch ================================================ //--from //go:build darwin || (openbsd && !mips64) //--to //go:build darwin || (openbsd && !mips64) || linux ================================================ FILE: 1.19_linux/runtime/sys_linux_amd64.s.patch ================================================ //--from TEXT runtime·open(SB),NOSPLIT,$0-20 // This uses openat instead of open, because Android O blocks open. MOVL $AT_FDCWD, DI // AT_FDCWD, so this acts like open MOVQ name+0(FP), SI MOVL mode+8(FP), DX MOVL perm+12(FP), R10 MOVL $SYS_openat, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVL 8(DI), SI // arg 2 flags MOVL 12(DI), DX // arg 3 mode MOVQ 0(DI), DI // arg 1 pathname XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_open(SB) MOVQ AX, 16(BX) POPQ BP RET //--from TEXT runtime·futex(SB),NOSPLIT,$0 MOVQ addr+0(FP), DI MOVL op+8(FP), SI MOVL val+12(FP), DX MOVQ ts+16(FP), R10 MOVQ addr2+24(FP), R8 MOVL val3+32(FP), R9 MOVL $SYS_futex, AX SYSCALL MOVL AX, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 addr MOVL 8(BX), SI // arg 2 op MOVL 12(BX), DX // arg 3 val MOVQ 16(BX), CX // arg 4 ts MOVQ 24(BX), R8 // arg 5 addr2 MOVL 32(BX), R9 // arg 6 val3 CALL hitsumabushi_futex(SB) MOVL AX, 40(BX) POPQ BP RET //--from TEXT runtime·exit(SB),NOSPLIT,$0-4 MOVL code+0(FP), DI MOVL $SYS_exit_group, AX SYSCALL RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 exit status CALL hitsumabushi_exit(SB) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·read(SB),NOSPLIT,$0-28 MOVL fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_read, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 0(BX), DI // arg 1 fd MOVQ 8(BX), SI // arg 2 buf MOVQ 16(BX), DX // arg 3 count CALL hitsumabushi_read(SB) MOVQ AX, 24(BX) // return value POPQ BP RET //--from TEXT runtime·closefd(SB),NOSPLIT,$0-12 MOVL fd+0(FP), DI MOVL $SYS_close, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 fd CALL hitsumabushi_closefd(SB) POPQ BP RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVL $SYS_gettid, AX SYSCALL MOVL AX, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_gettid(SB) POPQ BP RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT,$-8 MOVQ new+0(FP), DI MOVQ old+8(FP), SI MOVQ $SYS_sigaltstack, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $0xf1, 0xf1 // crash RET //--to TEXT runtime·sigaltstack_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 old MOVQ 0(DI), DI // arg 1 new CALL hitsumabushi_sigaltstack(SB) TESTQ AX, AX JEQ 2(PC) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·raise(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, R12 MOVL $SYS_gettid, AX SYSCALL MOVL AX, SI // arg 2 tid MOVL R12, DI // arg 1 pid MOVL sig+0(FP), DX // arg 3 MOVL $SYS_tgkill, AX SYSCALL RET //--to TEXT runtime·raise_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 signal CALL hitsumabushi_raise(SB) POPQ BP RET //--from TEXT runtime·raiseproc(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, DI // arg 1 pid MOVL sig+0(FP), SI // arg 2 MOVL $SYS_kill, AX SYSCALL RET //--to TEXT runtime·raiseproc_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), BX // signal CALL hitsumabushi_getpid(SB) MOVL AX, DI // arg 1 pid MOVL BX, SI // arg 2 signal CALL hitsumabushi_kill(SB) POPQ BP RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0 MOVQ pid+0(FP), DI MOVQ len+8(FP), SI MOVQ buf+16(FP), DX MOVL $SYS_sched_getaffinity, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 len MOVQ 16(DI), DX // arg 3 buf MOVQ 0(DI), DI // arg 1 pid CALL hitsumabushi_sched_getaffinity(SB) POPQ BP RET //--from TEXT runtime·osyield(SB),NOSPLIT,$0 MOVL $SYS_sched_yield, AX SYSCALL RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_osyield(SB) POPQ BP RET //--from TEXT runtime·usleep(SB),NOSPLIT,$16 MOVL $0, DX MOVL usec+0(FP), AX MOVL $1000000, CX DIVL CX MOVQ AX, 0(SP) MOVL $1000, AX // usec to nsec MULL DX MOVQ AX, 8(SP) // nanosleep(&ts, 0) MOVQ SP, DI MOVL $0, SI MOVL $SYS_nanosleep, AX SYSCALL RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 usec CALL hitsumabushi_usleep(SB) POPQ BP RET //--from TEXT runtime·write1(SB),NOSPLIT,$0-28 MOVQ fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_write, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 p MOVQ 16(DI), DX // arg 3 n MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_write1(SB) POPQ BP RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$16-8 // We don't know how much stack space the VDSO code will need, // so switch to g0. // In particular, a kernel configured with CONFIG_OPTIMIZE_INLINING=n // and hardening can use a full page of stack space in gettime_sym // due to stack probes inserted to avoid stack/heap collisions. // See issue #20427. MOVQ SP, R12 // Save old SP; R12 unchanged by C code. MOVQ g_m(R14), BX // BX unchanged by C code. // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVQ m_vdsoPC(BX), CX MOVQ m_vdsoSP(BX), DX MOVQ CX, 0(SP) MOVQ DX, 8(SP) LEAQ ret+0(FP), DX MOVQ -8(DX), CX MOVQ CX, m_vdsoPC(BX) MOVQ DX, m_vdsoSP(BX) CMPQ R14, m_curg(BX) // Only switch if on curg. JNE noswitch MOVQ m_g0(BX), DX MOVQ (g_sched+gobuf_sp)(DX), SP // Set SP to g0 stack noswitch: SUBQ $16, SP // Space for results ANDQ $~15, SP // Align for C code MOVL $1, DI // CLOCK_MONOTONIC LEAQ 0(SP), SI MOVQ runtime·vdsoClockgettimeSym(SB), AX CMPQ AX, $0 JEQ fallback CALL AX ret: MOVQ 0(SP), AX // sec MOVQ 8(SP), DX // nsec MOVQ R12, SP // Restore real SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVQ 8(SP), CX MOVQ CX, m_vdsoSP(BX) MOVQ 0(SP), CX MOVQ CX, m_vdsoPC(BX) // sec is in AX, nsec in DX // return nsec in AX IMULQ $1000000000, AX ADDQ DX, AX MOVQ AX, ret+0(FP) RET fallback: MOVQ $SYS_clock_gettime, AX SYSCALL JMP ret //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ DI, BX // BX is callee-saved MOVQ SP, BP CALL hitsumabushi_nanotime1(SB) MOVQ AX, 0(BX) POPQ BP RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(DI), DI CALL hitsumabushi_sysAllocOS(SB) MOVQ AX, 8(BX) POPQ BP RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUnusedOS(SB) POPQ BP RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUsedOS(SB) POPQ BP RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysHugePageOS(SB) POPQ BP RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFreeOS(SB) POPQ BP RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFaultOS(SB) POPQ BP RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysReserveOS(SB) MOVQ AX, 16(BX) POPQ BP RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysMapOS(SB) POPQ BP RET TEXT runtime·walltime1_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_walltime1(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 cmd MOVQ 16(DI), DX // arg 3 arg MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_fcntl(SB) POPQ BP RET TEXT runtime·fstat_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 stat MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_fstat(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·lseek_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 offset MOVQ 16(DI), DX // arg 3 whence MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_lseek(SB) MOVQ AX, 24(BX) // return value POPQ BP RET TEXT runtime·renameat_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_renameat(SB) MOVL AX, 32(BX) POPQ BP RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_fstatat(SB) MOVL AX, 32(BX) POPQ BP RET ================================================ FILE: 1.19_linux/runtime/sys_linux_arm64.s.patch ================================================ //--from #define SYS_exit 93 #define SYS_read 63 #define SYS_write 64 #define SYS_openat 56 #define SYS_close 57 #define SYS_pipe2 59 #define SYS_fcntl 25 #define SYS_nanosleep 101 #define SYS_mmap 222 #define SYS_munmap 215 #define SYS_setitimer 103 #define SYS_clone 220 #define SYS_sched_yield 124 #define SYS_rt_sigreturn 139 #define SYS_rt_sigaction 134 #define SYS_rt_sigprocmask 135 #define SYS_sigaltstack 132 #define SYS_madvise 233 #define SYS_mincore 232 #define SYS_getpid 172 #define SYS_gettid 178 #define SYS_kill 129 #define SYS_tgkill 131 #define SYS_futex 98 #define SYS_sched_getaffinity 123 #define SYS_exit_group 94 #define SYS_epoll_create1 20 #define SYS_epoll_ctl 21 #define SYS_epoll_pwait 22 #define SYS_clock_gettime 113 #define SYS_faccessat 48 #define SYS_socket 198 #define SYS_connect 203 #define SYS_brk 214 //--to #define SYS_exit 2147483647 #define SYS_read 2147483647 #define SYS_write 2147483647 #define SYS_openat 2147483647 #define SYS_close 2147483647 #define SYS_pipe2 2147483647 #define SYS_fcntl 2147483647 #define SYS_nanosleep 2147483647 #define SYS_mmap 2147483647 #define SYS_munmap 2147483647 #define SYS_setitimer 2147483647 #define SYS_clone 2147483647 #define SYS_sched_yield 2147483647 #define SYS_rt_sigreturn 2147483647 #define SYS_rt_sigaction 2147483647 #define SYS_rt_sigprocmask 2147483647 #define SYS_sigaltstack 2147483647 #define SYS_madvise 2147483647 #define SYS_mincore 2147483647 #define SYS_getpid 2147483647 #define SYS_gettid 2147483647 #define SYS_kill 2147483647 #define SYS_tgkill 2147483647 #define SYS_futex 2147483647 #define SYS_sched_getaffinity 2147483647 #define SYS_exit_group 2147483647 #define SYS_epoll_create1 2147483647 #define SYS_epoll_ctl 2147483647 #define SYS_epoll_pwait 2147483647 #define SYS_clock_gettime 2147483647 #define SYS_faccessat 2147483647 #define SYS_socket 2147483647 #define SYS_connect 2147483647 #define SYS_brk 2147483647 //--from TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0-4 MOVW code+0(FP), R0 MOVD $SYS_exit_group, R8 SVC RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_exit(SB) RET //--from TEXT runtime·open(SB),NOSPLIT|NOFRAME,$0-20 MOVD $AT_FDCWD, R0 MOVD name+0(FP), R1 MOVW mode+8(FP), R2 MOVW perm+12(FP), R3 MOVD $SYS_openat, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_open(SB) RET //--from TEXT runtime·closefd(SB),NOSPLIT|NOFRAME,$0-12 MOVW fd+0(FP), R0 MOVD $SYS_close, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT,$0-12 MOVW 0(R0), R0 BL hitsumabushi_closefd(SB) RET //--from TEXT runtime·write1(SB),NOSPLIT|NOFRAME,$0-28 MOVD fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_write, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_write1(SB) RET //--from TEXT runtime·read(SB),NOSPLIT|NOFRAME,$0-28 MOVW fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_read, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_read(SB) RET //--from TEXT runtime·usleep(SB),NOSPLIT,$24-4 MOVWU usec+0(FP), R3 MOVD R3, R5 MOVW $1000000, R4 UDIV R4, R3 MOVD R3, 8(RSP) MUL R3, R4 SUB R4, R5 MOVW $1000, R4 MUL R4, R5 MOVD R5, 16(RSP) // nanosleep(&ts, 0) ADD $8, RSP, R0 MOVD $0, R1 MOVD $SYS_nanosleep, R8 SVC RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_usleep(SB) RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVD $SYS_gettid, R8 SVC MOVW R0, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_gettid(SB) MOVW R0, 0(R19) // return value RET //--from TEXT runtime·raise(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R19 MOVD $SYS_gettid, R8 SVC MOVW R0, R1 // arg 2 tid MOVW R19, R0 // arg 1 pid MOVW sig+0(FP), R2 // arg 3 MOVD $SYS_tgkill, R8 SVC RET //--to //--from TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R0 // arg 1 pid MOVW sig+0(FP), R1 // arg 2 MOVD $SYS_kill, R8 SVC RET //--to //--from TEXT runtime·walltime(SB),NOSPLIT,$24-12 MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $16, R1 BIC $15, R1 // Align for C code MOVD R1, RSP MOVW $CLOCK_REALTIME, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) MOVD R3, sec+0(FP) MOVW R5, nsec+8(FP) RET //--to TEXT runtime·walltime1_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_walltime1(SB) RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$24-8 MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $32, R1 BIC $15, R1 MOVD R1, RSP MOVW $CLOCK_MONOTONIC, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) // sec is in R3, nsec in R5 // return nsec in R3 MOVD $1000000000, R4 MUL R4, R3 ADD R5, R3 MOVD R3, ret+0(FP) RET //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_nanotime1(SB) MOVD R0, 0(R19) // return value RET //--from TEXT runtime·futex(SB),NOSPLIT|NOFRAME,$0 MOVD addr+0(FP), R0 MOVW op+8(FP), R1 MOVW val+12(FP), R2 MOVD ts+16(FP), R3 MOVD addr2+24(FP), R4 MOVW val3+32(FP), R5 MOVD $SYS_futex, R8 SVC MOVW R0, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 16(R0), R3 MOVD 24(R0), R4 MOVW 32(R0), R5 MOVD 0(R0), R0 BL hitsumabushi_futex(SB) RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT|NOFRAME,$0 MOVD new+0(FP), R0 MOVD old+8(FP), R1 MOVD $SYS_sigaltstack, R8 SVC CMN $4095, R0 BCC ok MOVD $0, R0 MOVD R0, (R0) // crash ok: RET //--to //--from TEXT runtime·osyield(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_sched_yield, R8 SVC RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT,$0 BL hitsumabushi_osyield(SB) RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT|NOFRAME,$0 MOVD pid+0(FP), R0 MOVD len+8(FP), R1 MOVD buf+16(FP), R2 MOVD $SYS_sched_getaffinity, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVD 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_sched_getaffinity(SB) RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 0(R0), R0 BL hitsumabushi_sysAllocOS(SB) MOVD R0, 8(R19) // return value RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUnusedOS(SB) RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUsedOS(SB) RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysHugePageOS(SB) RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFreeOS(SB) RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFaultOS(SB) RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysReserveOS(SB) MOVD R0, 16(R19) // return value RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysMapOS(SB) RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVW 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_fcntl(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·fstat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 0(R0), R0 BL hitsumabushi_fstat(SB) MOVW R0, 16(R19) // return value RET TEXT runtime·lseek_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_lseek(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·renameat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_renameat(SB) MOVW R0, 32(R19) // return value RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_fstatat(SB) MOVW R0, 32(R19) // return value RET ================================================ FILE: 1.19_linux/runtime/time_linux_amd64.s.patch ================================================ //--from //go:build !faketime //--to //go:build ignore ================================================ FILE: 1.19_linux/runtime/timeasm.go.patch ================================================ //--from //go:build !faketime && (windows || (linux && amd64)) //--to //go:build !faketime && windows ================================================ FILE: 1.19_linux/runtime/timestub.go.patch ================================================ //--from //go:build !faketime && !windows && !(linux && amd64) //--to //go:build !faketime && !windows ================================================ FILE: 1.19_linux/runtime/timestub2.go.patch ================================================ //--from //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !windows && !(linux && amd64) //--to //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !windows //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func walltime() (sec int64, nsec int32) //--to func walltime() (sec int64, nsec int32) { walltime1(&sec, &nsec) return } //go:nosplit //go:cgo_unsafe_args func walltime1(sec *int64, nsec *int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(walltime1_trampoline)), unsafe.Pointer(&sec)) } func walltime1_trampoline(sec *int64, nsec *int32) ================================================ FILE: 1.19_linux/strconv/fp_test.go.patch ================================================ //--from import ( "bufio" "fmt" "os" "strconv" "strings" "testing" ) //--to import ( "strconv" "strings" "testing" ) //--from func TestFp(t *testing.T) { f, err := os.Open("testdata/testfp.txt") if err != nil { t.Fatal("testfp: open testdata/testfp.txt:", err) } defer f.Close() s := bufio.NewScanner(f) for lineno := 1; s.Scan(); lineno++ { line := s.Text() if len(line) == 0 || line[0] == '#' { continue } a := strings.Split(line, " ") if len(a) != 4 { t.Error("testdata/testfp.txt:", lineno, ": wrong field count") continue } var s string var v float64 switch a[0] { case "float64": var ok bool v, ok = myatof64(a[2]) if !ok { t.Error("testdata/testfp.txt:", lineno, ": cannot atof64 ", a[2]) continue } s = fmt.Sprintf(a[1], v) case "float32": v1, ok := myatof32(a[2]) if !ok { t.Error("testdata/testfp.txt:", lineno, ": cannot atof32 ", a[2]) continue } s = fmt.Sprintf(a[1], v1) v = float64(v1) } if s != a[3] { t.Error("testdata/testfp.txt:", lineno, ": ", a[0], " ", a[1], " ", a[2], " (", v, ") ", "want ", a[3], " got ", s) } } if s.Err() != nil { t.Fatal("testfp: read testdata/testfp.txt: ", s.Err()) } } //--to func TestFp(t *testing.T) { t.Skip("file is not supported in this environment") } ================================================ FILE: 1.19_linux/sync/atomic/atomic_test.go.patch ================================================ //--from func TestStoreLoadSeqCst32(t *testing.T) { if runtime.NumCPU() == 1 { t.Skipf("Skipping test on %v processor machine", runtime.NumCPU()) } defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4)) N := int32(1e3) if testing.Short() { N = int32(1e2) } c := make(chan bool, 2) X := [2]int32{} ack := [2][3]int32{{-1, -1, -1}, {-1, -1, -1}} for p := 0; p < 2; p++ { go func(me int) { he := 1 - me for i := int32(1); i < N; i++ { StoreInt32(&X[me], i) my := LoadInt32(&X[he]) StoreInt32(&ack[me][i%3], my) for w := 1; LoadInt32(&ack[he][i%3]) == -1; w++ { if w%1000 == 0 { runtime.Gosched() } } his := LoadInt32(&ack[he][i%3]) if (my != i && my != i-1) || (his != i && his != i-1) { t.Errorf("invalid values: %d/%d (%d)", my, his, i) break } if my != i && his != i { t.Errorf("store/load are not sequentially consistent: %d/%d (%d)", my, his, i) break } StoreInt32(&ack[me][(i-1)%3], -1) } c <- true }(p) } <-c <-c } //--to func TestStoreLoadSeqCst32(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") } //--from func TestStoreLoadSeqCst64(t *testing.T) { if runtime.NumCPU() == 1 { t.Skipf("Skipping test on %v processor machine", runtime.NumCPU()) } if test64err != nil { t.Skipf("Skipping 64-bit tests: %v", test64err) } defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4)) N := int64(1e3) if testing.Short() { N = int64(1e2) } c := make(chan bool, 2) X := [2]int64{} ack := [2][3]int64{{-1, -1, -1}, {-1, -1, -1}} for p := 0; p < 2; p++ { go func(me int) { he := 1 - me for i := int64(1); i < N; i++ { StoreInt64(&X[me], i) my := LoadInt64(&X[he]) StoreInt64(&ack[me][i%3], my) for w := 1; LoadInt64(&ack[he][i%3]) == -1; w++ { if w%1000 == 0 { runtime.Gosched() } } his := LoadInt64(&ack[he][i%3]) if (my != i && my != i-1) || (his != i && his != i-1) { t.Errorf("invalid values: %d/%d (%d)", my, his, i) break } if my != i && his != i { t.Errorf("store/load are not sequentially consistent: %d/%d (%d)", my, his, i) break } StoreInt64(&ack[me][(i-1)%3], -1) } c <- true }(p) } <-c <-c } //--to func TestStoreLoadSeqCst64(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") } //--from func TestNilDeref(t *testing.T) { funcs := [...]func(){ func() { CompareAndSwapInt32(nil, 0, 0) }, func() { (*Int32)(nil).CompareAndSwap(0, 0) }, func() { CompareAndSwapInt64(nil, 0, 0) }, func() { (*Int64)(nil).CompareAndSwap(0, 0) }, func() { CompareAndSwapUint32(nil, 0, 0) }, func() { (*Uint32)(nil).CompareAndSwap(0, 0) }, func() { CompareAndSwapUint64(nil, 0, 0) }, func() { (*Uint64)(nil).CompareAndSwap(0, 0) }, func() { CompareAndSwapUintptr(nil, 0, 0) }, func() { (*Uintptr)(nil).CompareAndSwap(0, 0) }, func() { CompareAndSwapPointer(nil, nil, nil) }, func() { (*Pointer[byte])(nil).CompareAndSwap(nil, nil) }, func() { SwapInt32(nil, 0) }, func() { (*Int32)(nil).Swap(0) }, func() { SwapUint32(nil, 0) }, func() { (*Uint32)(nil).Swap(0) }, func() { SwapInt64(nil, 0) }, func() { (*Int64)(nil).Swap(0) }, func() { SwapUint64(nil, 0) }, func() { (*Uint64)(nil).Swap(0) }, func() { SwapUintptr(nil, 0) }, func() { (*Uintptr)(nil).Swap(0) }, func() { SwapPointer(nil, nil) }, func() { (*Pointer[byte])(nil).Swap(nil) }, func() { AddInt32(nil, 0) }, func() { (*Int32)(nil).Add(0) }, func() { AddUint32(nil, 0) }, func() { (*Uint32)(nil).Add(0) }, func() { AddInt64(nil, 0) }, func() { (*Int64)(nil).Add(0) }, func() { AddUint64(nil, 0) }, func() { (*Uint64)(nil).Add(0) }, func() { AddUintptr(nil, 0) }, func() { (*Uintptr)(nil).Add(0) }, func() { LoadInt32(nil) }, func() { (*Int32)(nil).Load() }, func() { LoadInt64(nil) }, func() { (*Int64)(nil).Load() }, func() { LoadUint32(nil) }, func() { (*Uint32)(nil).Load() }, func() { LoadUint64(nil) }, func() { (*Uint64)(nil).Load() }, func() { LoadUintptr(nil) }, func() { (*Uintptr)(nil).Load() }, func() { LoadPointer(nil) }, func() { (*Pointer[byte])(nil).Load() }, func() { StoreInt32(nil, 0) }, func() { (*Int32)(nil).Store(0) }, func() { StoreInt64(nil, 0) }, func() { (*Int64)(nil).Store(0) }, func() { StoreUint32(nil, 0) }, func() { (*Uint32)(nil).Store(0) }, func() { StoreUint64(nil, 0) }, func() { (*Uint64)(nil).Store(0) }, func() { StoreUintptr(nil, 0) }, func() { (*Uintptr)(nil).Store(0) }, func() { StorePointer(nil, nil) }, func() { (*Pointer[byte])(nil).Store(nil) }, } for _, f := range funcs { func() { defer func() { runtime.GC() recover() }() f() }() } } //--to func TestNilDeref(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } ================================================ FILE: 1.19_linux/syscall/hitsumabushi_stubs_linux_amd64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_FSTATAT = 0xffffffffffffffff // Stub: on amd64 Go uses SYS_NEWFSTATAT instead ) ================================================ FILE: 1.19_linux/syscall/hitsumabushi_stubs_linux_arm64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_NEWFSTATAT = 0xffffffffffffffff // Stub: on arm64 Go uses SYS_FSTATAT instead ) ================================================ FILE: 1.19_linux/syscall/rlimit.go.patch ================================================ //--from func init() { var lim Rlimit if err := Getrlimit(RLIMIT_NOFILE, &lim); err == nil && lim.Cur != lim.Max { origRlimitNofile.Store(lim) lim.Cur = lim.Max adjustFileLimit(&lim) setrlimit(RLIMIT_NOFILE, &lim) } } //--to func init() { } ================================================ FILE: 1.19_linux/syscall/syscall_linux.go.patch ================================================ //--from func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { return RawSyscall6(trap, a1, a2, a3, 0, 0, 0) } //--to func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { println("not implemented syscall at RawSyscall", trap) panic("syscall.RawSyscall") return 0, 0, ENOSYS } //--from func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() // N.B. Calling RawSyscall here is unsafe with atomic coverage // instrumentation and race mode. // // Coverage instrumentation will add a sync/atomic call to RawSyscall. // Race mode will add race instrumentation to sync/atomic. Race // instrumentation requires a P, which we no longer have. // // RawSyscall6 is fine because it is implemented in assembly and thus // has no coverage instrumentation. // // This is typically not a problem in the runtime because cmd/go avoids // adding coverage instrumentation to the runtime in race mode. r1, r2, err = RawSyscall6(trap, a1, a2, a3, 0, 0, 0) runtime_exitsyscall() return } //--to func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FCNTL: r = fcntl1(a1, a2, a3) case SYS_FSTAT: r = fstat1(a1, unsafe.Pointer(a2)) case SYS_READ: r = runtime_read(uintptr(a1), unsafe.Pointer(a2), int32(a3)) case SYS_WRITE: r = write1(a1, unsafe.Pointer(a2), int32(a3)) case SYS_LSEEK: r = lseek1(a1, int64(a2), int32(a3)) case SYS_CLOSE: r = runtime_closefd(int32(a1)) case SYS_MKDIRAT: println("syscall mkdirat() is not implemented") // Default to permission denied. TODO: implement this return 0, 0, EPERM case SYS_GETDENTS64: println("syscall getdents64() is not implemented") // Default to empty directory. TODO: implement this return 0, 0, 0 default: println("unimplemented syscall at runtime.Syscall", trap) panic("syscall.Syscall") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //go:linkname open runtime.open func open(name *byte, mode, perm int32) int32 //go:linkname write1 runtime.write1 func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname fcntl1 runtime.fcntl1 func fcntl1(fd uintptr, a uintptr, b uintptr) int32 //go:linkname fstat1 runtime.fstat1 func fstat1(fd uintptr, p unsafe.Pointer) int32 //go:linkname lseek1 runtime.lseek1 func lseek1(fd uintptr, offset int64, whence int32) int32 //go:linkname runtime_read runtime.read func runtime_read(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname runtime_closefd runtime.closefd func runtime_closefd(fd int32) int32 //go:linkname runtime_fstatat runtime.fstatat func runtime_fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 //go:linkname runtime_renameat runtime.renameat func runtime_renameat(fd1 uintptr, name1 unsafe.Pointer, fd2 uintptr, name2 unsafe.Pointer) int32 //--from func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() r1, r2, err = RawSyscall6(trap, a1, a2, a3, a4, a5, a6) runtime_exitsyscall() return } //--to func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FSTATAT, SYS_NEWFSTATAT: r = runtime_fstatat(uintptr(a1), unsafe.Pointer(a2), unsafe.Pointer(a3), int32(a4)) case SYS_RENAMEAT: r = runtime_renameat(uintptr(a1), unsafe.Pointer(a2), uintptr(a3), unsafe.Pointer(a4)) default: println("unimplemented syscall at runtime.Syscall6", trap) panic("syscall.Syscall6") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //--from func Open(path string, mode int, perm uint32) (fd int, err error) { return openat(_AT_FDCWD, path, mode|O_LARGEFILE, perm) } //--to func Open(path string, mode int, perm uint32) (fd int, err error) { p0, err := BytePtrFromString(path) if err != nil { return -1, errnoErr(EINVAL) } fd = int(open(p0, int32(mode|O_LARGEFILE), int32(perm))) if fd < 0 { return -1, errnoErr(ENOENT) } return } ================================================ FILE: 1.19_linux/testing/run_example.go ================================================ package testing func runExample(eg InternalExample) (ok bool) { // Do nothing. // TODO: Implement os.Pipe2 and use this here. return true } ================================================ FILE: 1.19_linux/time/format_test.go.patch ================================================ //--from func TestParseInLocation(t *testing.T) { baghdad, err := LoadLocation("Asia/Baghdad") if err != nil { t.Fatal(err) } var t1, t2 Time t1, err = ParseInLocation("Jan 02 2006 MST", "Feb 01 2013 AST", baghdad) if err != nil { t.Fatal(err) } _, offset := t1.Zone() // A zero offset means that ParseInLocation did not recognize the // 'AST' abbreviation as matching the current location (Baghdad, // where we'd expect a +03 hrs offset); likely because we're using // a recent tzdata release (2017a or newer). // If it happens, skip the Baghdad test. if offset != 0 { t2 = Date(2013, February, 1, 00, 00, 00, 0, baghdad) if t1 != t2 { t.Fatalf("ParseInLocation(Feb 01 2013 AST, Baghdad) = %v, want %v", t1, t2) } if offset != 3*60*60 { t.Fatalf("ParseInLocation(Feb 01 2013 AST, Baghdad).Zone = _, %d, want _, %d", offset, 3*60*60) } } blancSablon, err := LoadLocation("America/Blanc-Sablon") if err != nil { t.Fatal(err) } // In this case 'AST' means 'Atlantic Standard Time', and we // expect the abbreviation to correctly match the american // location. t1, err = ParseInLocation("Jan 02 2006 MST", "Feb 01 2013 AST", blancSablon) if err != nil { t.Fatal(err) } t2 = Date(2013, February, 1, 00, 00, 00, 0, blancSablon) if t1 != t2 { t.Fatalf("ParseInLocation(Feb 01 2013 AST, Blanc-Sablon) = %v, want %v", t1, t2) } _, offset = t1.Zone() if offset != -4*60*60 { t.Fatalf("ParseInLocation(Feb 01 2013 AST, Blanc-Sablon).Zone = _, %d, want _, %d", offset, -4*60*60) } } //--to func TestParseInLocation(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestLoadLocationZipFile(t *testing.T) { undo := DisablePlatformSources() defer undo() _, err := LoadLocation("Australia/Sydney") if err != nil { t.Fatal(err) } } //--to func TestLoadLocationZipFile(t *testing.T) { t.Skip("location is not supported in this environment") } ================================================ FILE: 1.19_linux/time/internal_test.go.patch ================================================ //--from func initTestingZone() { // For hermeticity, use only tzinfo source from the test's GOROOT, // not the system sources and not whatever GOROOT may happen to be // set in the process's environment (if any). // This test runs in GOROOT/src/time, so GOROOT is "../..", // but it is theoretically possible sources := []string{"../../lib/time/zoneinfo.zip"} z, err := loadLocation("America/Los_Angeles", sources) if err != nil { panic("cannot load America/Los_Angeles for testing: " + err.Error() + "; you may want to use -tags=timetzdata") } z.name = "Local" localLoc = *z } //--to func initTestingZone() { // Data from the playground. // https://go.dev/play/p/VGXU57KZZ-x // name is replaced with "Local". // cachStart, cacheEnd, and cacheZone are removed. localLoc = Location{name:"Local",zone:[]zone{zone{name:"LMT", offset:-28378, isDST:false}, zone{name:"PDT", offset:-25200, isDST:true}, zone{name:"PST", offset:-28800, isDST:false}, zone{name:"PWT", offset:-25200, isDST:true}, zone{name:"PPT", offset:-25200, isDST:true}}, tx:[]zoneTrans{zoneTrans{when:-576460752303423488, index:0x0, isstd:false, isutc:false}, zoneTrans{when:-2717640000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1633269600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-1615129200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1601820000, index:0x1, isstd:true, isutc:true}, zoneTrans{when:-1583679600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-880207200, index:0x3, isstd:false, isutc:false}, zoneTrans{when:-769395600, index:0x4, isstd:false, isutc:false}, zoneTrans{when:-765385200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-687967140, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-662655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-620838000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-608137200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-589388400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-576082800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-557938800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-544633200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-526489200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-513183600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-495039600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-481734000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-463590000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-450284400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-431535600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-418230000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-400086000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-386780400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-368636400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-355330800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-337186800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-323881200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-305737200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-292431600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-273682800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-260982000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-242233200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-226508400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-210783600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-195058800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-179334000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-163609200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-147884400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-131554800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-116434800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-100105200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-84376800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-68655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-52927200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-37206000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-21477600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-5756400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:9972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:25693200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:41421600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:57747600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:73476000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:89197200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:104925600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:120646800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:126698400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:152096400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:162381600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:183546000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:199274400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:215600400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:230724000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:247050000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:262778400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:278499600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:294228000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:309949200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:325677600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:341398800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:357127200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:372848400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:388576800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:404902800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:420026400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:436352400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:452080800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:467802000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:483530400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:499251600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:514980000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:530701200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:544615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:562150800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:576064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:594205200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:607514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:625654800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:638964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:657104400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:671018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:688554000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:702468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:720003600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:733917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:752058000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:765367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:783507600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:796816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:814957200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:828871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:846406800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:860320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:877856400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:891770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:909306000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:923220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:941360400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:954669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:972810000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:986119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1004259600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1018173600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1035709200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1049623200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1067158800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1081072800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1099213200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1112522400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1130662800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1143972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1162112400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1173607200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1194166800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1205056800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1225616400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1236506400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1257066000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1268560800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1289120400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1300010400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1320570000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1331460000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1352019600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1362909600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1383469200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1394359200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1414918800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1425808800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1446368400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1457863200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1478422800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1489312800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1509872400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1520762400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1541322000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1552212000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1572771600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1583661600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1604221200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1615716000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1636275600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1647165600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1667725200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1678615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1699174800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1710064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1730624400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1741514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1762074000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1772964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1793523600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1805018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1825578000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1836468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1857027600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1867917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1888477200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1899367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1919926800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1930816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1951376400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1962871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1983430800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1994320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2014880400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2025770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2046330000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2057220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2077779600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2088669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2109229200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2120119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2140678800, index:0x2, isstd:false, isutc:false}}, extend:"PST8PDT,M3.2.0,M11.1.0"} } ================================================ FILE: 1.19_linux/time/sleep_test.go.patch ================================================ //--from func TestSleep(t *testing.T) { const delay = 100 * Millisecond go func() { Sleep(delay / 2) Interrupt() }() start := Now() Sleep(delay) delayadj := delay if runtime.GOOS == "windows" { delayadj -= windowsInaccuracy } duration := Now().Sub(start) if duration < delayadj { t.Fatalf("Sleep(%s) slept for only %s", delay, duration) } } //--to func TestSleep(t *testing.T) { t.Skip("Interrupt (syscall.Kill) is not supported in this environment") } //--from func TestIssue5745(t *testing.T) { ticker := NewTicker(Hour) defer func() { // would deadlock here before the fix due to // lock taken before the segfault. ticker.Stop() if r := recover(); r == nil { t.Error("Expected panic, but none happened.") } }() // cause a panic due to a segfault var timer *Timer timer.Stop() t.Error("Should be unreachable.") } //--to func TestIssue5745(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } ================================================ FILE: 1.19_linux/time/time_test.go.patch ================================================ //--from func TestLoadFixed(t *testing.T) { // Issue 4064: handle locations without any zone transitions. loc, err := LoadLocation("Etc/GMT+1") if err != nil { t.Fatal(err) } // The tzdata name Etc/GMT+1 uses "east is negative", // but Go and most other systems use "east is positive". // So GMT+1 corresponds to -3600 in the Go zone, not +3600. name, offset := Now().In(loc).Zone() // The zone abbreviation is "-01" since tzdata-2016g, and "GMT+1" // on earlier versions; we accept both. (Issue #17276). if !(name == "GMT+1" || name == "-01") || offset != -1*60*60 { t.Errorf("Now().In(loc).Zone() = %q, %d, want %q or %q, %d", name, offset, "GMT+1", "-01", -1*60*60) } } //--to func TestLoadFixed(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestTimeIsDST(t *testing.T) { undo := DisablePlatformSources() defer undo() tzWithDST, err := LoadLocation("Australia/Sydney") if err != nil { t.Fatalf("could not load tz 'Australia/Sydney': %v", err) } tzWithoutDST, err := LoadLocation("Australia/Brisbane") if err != nil { t.Fatalf("could not load tz 'Australia/Brisbane': %v", err) } tzFixed := FixedZone("FIXED_TIME", 12345) tests := [...]struct { time Time want bool }{ 0: {Date(2009, 1, 1, 12, 0, 0, 0, UTC), false}, 1: {Date(2009, 6, 1, 12, 0, 0, 0, UTC), false}, 2: {Date(2009, 1, 1, 12, 0, 0, 0, tzWithDST), true}, 3: {Date(2009, 6, 1, 12, 0, 0, 0, tzWithDST), false}, 4: {Date(2009, 1, 1, 12, 0, 0, 0, tzWithoutDST), false}, 5: {Date(2009, 6, 1, 12, 0, 0, 0, tzWithoutDST), false}, 6: {Date(2009, 1, 1, 12, 0, 0, 0, tzFixed), false}, 7: {Date(2009, 6, 1, 12, 0, 0, 0, tzFixed), false}, } for i, tt := range tests { got := tt.time.IsDST() if got != tt.want { t.Errorf("#%d:: (%#v).IsDST()=%t, want %t", i, tt.time.Format(RFC3339), got, tt.want) } } } //--to func TestTimeIsDST(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestTimeWithZoneTransition(t *testing.T) { undo := DisablePlatformSources() defer undo() loc, err := LoadLocation("Asia/Shanghai") if err != nil { t.Fatal(err) } tests := [...]struct { give Time want Time }{ // 14 Apr 1991 - Daylight Saving Time Started // When time of "Asia/Shanghai" was about to reach // Sunday, 14 April 1991, 02:00:00 clocks were turned forward 1 hour to // Sunday, 14 April 1991, 03:00:00 local daylight time instead. // The UTC time was 13 April 1991, 18:00:00 0: {Date(1991, April, 13, 17, 50, 0, 0, loc), Date(1991, April, 13, 9, 50, 0, 0, UTC)}, 1: {Date(1991, April, 13, 18, 0, 0, 0, loc), Date(1991, April, 13, 10, 0, 0, 0, UTC)}, 2: {Date(1991, April, 14, 1, 50, 0, 0, loc), Date(1991, April, 13, 17, 50, 0, 0, UTC)}, 3: {Date(1991, April, 14, 3, 0, 0, 0, loc), Date(1991, April, 13, 18, 0, 0, 0, UTC)}, // 15 Sep 1991 - Daylight Saving Time Ended // When local daylight time of "Asia/Shanghai" was about to reach // Sunday, 15 September 1991, 02:00:00 clocks were turned backward 1 hour to // Sunday, 15 September 1991, 01:00:00 local standard time instead. // The UTC time was 14 September 1991, 17:00:00 4: {Date(1991, September, 14, 16, 50, 0, 0, loc), Date(1991, September, 14, 7, 50, 0, 0, UTC)}, 5: {Date(1991, September, 14, 17, 0, 0, 0, loc), Date(1991, September, 14, 8, 0, 0, 0, UTC)}, 6: {Date(1991, September, 15, 0, 50, 0, 0, loc), Date(1991, September, 14, 15, 50, 0, 0, UTC)}, 7: {Date(1991, September, 15, 2, 00, 0, 0, loc), Date(1991, September, 14, 18, 00, 0, 0, UTC)}, } for i, tt := range tests { if !tt.give.Equal(tt.want) { t.Errorf("#%d:: %#v is not equal to %#v", i, tt.give.Format(RFC3339), tt.want.Format(RFC3339)) } } } //--to func TestTimeWithZoneTransition(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestMarshalBinaryVersion2(t *testing.T) { t0, err := Parse(RFC3339, "1880-01-01T00:00:00Z") if err != nil { t.Errorf("Failed to parse time, error = %v", err) } loc, err := LoadLocation("US/Eastern") if err != nil { t.Errorf("Failed to load location, error = %v", err) } t1 := t0.In(loc) b, err := t1.MarshalBinary() if err != nil { t.Errorf("Failed to Marshal, error = %v", err) } t2 := Time{} err = t2.UnmarshalBinary(b) if err != nil { t.Errorf("Failed to Unmarshal, error = %v", err) } if !(t0.Equal(t1) && t1.Equal(t2)) { if !t0.Equal(t1) { t.Errorf("The result t1: %+v after Marshal is not matched original t0: %+v", t1, t0) } if !t1.Equal(t2) { t.Errorf("The result t2: %+v after Unmarshal is not matched original t1: %+v", t2, t1) } } } //--to func TestMarshalBinaryVersion2(t *testing.T) { t.Skip("location is not supported in this environment") } ================================================ FILE: 1.19_linux/time/tzdata_test.go.patch ================================================ //--from import ( "reflect" "testing" "time" _ "time/tzdata" ) //--to import ( "reflect" "testing" _ "time/tzdata" ) //--from func TestEmbeddedTZData(t *testing.T) { undo := time.DisablePlatformSources() defer undo() for _, zone := range zones { ref, err := time.LoadLocation(zone) if err != nil { t.Errorf("LoadLocation(%q): %v", zone, err) continue } embedded, err := time.LoadFromEmbeddedTZData(zone) if err != nil { t.Errorf("LoadFromEmbeddedTZData(%q): %v", zone, err) continue } sample, err := time.LoadLocationFromTZData(zone, []byte(embedded)) if err != nil { t.Errorf("LoadLocationFromTZData failed for %q: %v", zone, err) continue } // Compare the name and zone fields of ref and sample. // The tx field changes faster as tzdata is updated. // The cache fields are expected to differ. v1 := reflect.ValueOf(ref).Elem() v2 := reflect.ValueOf(sample).Elem() typ := v1.Type() nf := typ.NumField() found := 0 for i := 0; i < nf; i++ { ft := typ.Field(i) if ft.Name != "name" && ft.Name != "zone" { continue } found++ if !equal(t, v1.Field(i), v2.Field(i)) { t.Errorf("zone %s: system and embedded tzdata field %s differs", zone, ft.Name) } } if found != 2 { t.Errorf("test must be updated for change to time.Location struct") } } } //--to func TestEmbeddedTZData(t *testing.T) { t.Skip("location is not supported in this environment") } ================================================ FILE: 1.19_linux/time/zoneinfo_test.go.patch ================================================ //--from import ( "errors" "fmt" "internal/testenv" "os" "reflect" "testing" "time" ) //--to import ( "fmt" "testing" "time" ) //--from func TestEnvVarUsage(t *testing.T) { time.ResetZoneinfoForTesting() const testZoneinfo = "foo.zip" const env = "ZONEINFO" t.Setenv(env, testZoneinfo) // Result isn't important, we're testing the side effect of this command time.LoadLocation("Asia/Jerusalem") defer time.ResetZoneinfoForTesting() if zoneinfo := time.ZoneinfoForTesting(); testZoneinfo != *zoneinfo { t.Errorf("zoneinfo does not match env variable: got %q want %q", *zoneinfo, testZoneinfo) } } //--to func TestEnvVarUsage(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestBadLocationErrMsg(t *testing.T) { time.ResetZoneinfoForTesting() loc := "Asia/SomethingNotExist" want := errors.New("unknown time zone " + loc) _, err := time.LoadLocation(loc) if err.Error() != want.Error() { t.Errorf("LoadLocation(%q) error = %v; want %v", loc, err, want) } } //--to func TestBadLocationErrMsg(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestVersion3(t *testing.T) { undo := time.DisablePlatformSources() defer undo() _, err := time.LoadLocation("Asia/Jerusalem") if err != nil { t.Fatal(err) } } //--to func TestVersion3(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestFirstZone(t *testing.T) { undo := time.DisablePlatformSources() defer undo() const format = "Mon, 02 Jan 2006 15:04:05 -0700 (MST)" var tests = []struct { zone string unix int64 want1 string want2 string }{ { "PST8PDT", -1633269601, "Sun, 31 Mar 1918 01:59:59 -0800 (PST)", "Sun, 31 Mar 1918 03:00:00 -0700 (PDT)", }, { "Pacific/Fakaofo", 1325242799, "Thu, 29 Dec 2011 23:59:59 -1100 (-11)", "Sat, 31 Dec 2011 00:00:00 +1300 (+13)", }, } for _, test := range tests { z, err := time.LoadLocation(test.zone) if err != nil { t.Fatal(err) } s := time.Unix(test.unix, 0).In(z).Format(format) if s != test.want1 { t.Errorf("for %s %d got %q want %q", test.zone, test.unix, s, test.want1) } s = time.Unix(test.unix+1, 0).In(z).Format(format) if s != test.want2 { t.Errorf("for %s %d got %q want %q", test.zone, test.unix, s, test.want2) } } } //--to func TestFirstZone(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestLoadLocationFromTZData(t *testing.T) { undo := time.DisablePlatformSources() defer undo() const locationName = "Asia/Jerusalem" reference, err := time.LoadLocation(locationName) if err != nil { t.Fatal(err) } gorootSource, ok := time.GorootZoneSource(testenv.GOROOT(t)) if !ok { t.Fatal("Failed to locate tzinfo source in GOROOT.") } tzinfo, err := time.LoadTzinfo(locationName, gorootSource) if err != nil { t.Fatal(err) } sample, err := time.LoadLocationFromTZData(locationName, tzinfo) if err != nil { t.Fatal(err) } if !reflect.DeepEqual(reference, sample) { t.Errorf("return values of LoadLocationFromTZData and LoadLocation don't match") } } //--to func TestLoadLocationFromTZData(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestEarlyLocation(t *testing.T) { undo := time.DisablePlatformSources() defer undo() const locName = "America/New_York" loc, err := time.LoadLocation(locName) if err != nil { t.Fatal(err) } d := time.Date(1900, time.January, 1, 0, 0, 0, 0, loc) tzName, tzOffset := d.Zone() if want := "EST"; tzName != want { t.Errorf("Zone name == %s, want %s", tzName, want) } if want := -18000; tzOffset != want { t.Errorf("Zone offset == %d, want %d", tzOffset, want) } } //--to func TestEarlyLocation(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestLoadLocationFromTZDataSlim(t *testing.T) { for _, test := range slimTests { tzData, err := os.ReadFile("testdata/" + test.fileName) if err != nil { t.Error(err) continue } reference, err := time.LoadLocationFromTZData(test.zoneName, tzData) if err != nil { t.Error(err) continue } d := test.date(reference) tzName, tzOffset := d.Zone() if tzName != test.wantName { t.Errorf("Zone name == %s, want %s", tzName, test.wantName) } if tzOffset != test.wantOffset { t.Errorf("Zone offset == %d, want %d", tzOffset, test.wantOffset) } } } //--to func TestLoadLocationFromTZDataSlim(t *testing.T) { t.Skip("location is not supported in this environment") } ================================================ FILE: 1.19_linux/time/zoneinfo_unix.go.patch ================================================ //--from import ( "syscall" ) //--to //--from func initLocal() { // consult $TZ to find the time zone to use. // no $TZ means use the system default /etc/localtime. // $TZ="" means use UTC. // $TZ="foo" or $TZ=":foo" if foo is an absolute path, then the file pointed // by foo will be used to initialize timezone; otherwise, file // /usr/share/zoneinfo/foo will be used. tz, ok := syscall.Getenv("TZ") switch { case !ok: z, err := loadLocation("localtime", []string{"/etc"}) if err == nil { localLoc = *z localLoc.name = "Local" return } case tz != "": if tz[0] == ':' { tz = tz[1:] } if tz != "" && tz[0] == '/' { if z, err := loadLocation(tz, []string{""}); err == nil { localLoc = *z if tz == "/etc/localtime" { localLoc.name = "Local" } else { localLoc.name = tz } return } } else if tz != "" && tz != "UTC" { if z, err := loadLocation(tz, platformZoneSources); err == nil { localLoc = *z return } } } // Fall back to UTC. localLoc.name = "UTC" } //--to func initLocal() { localLoc.name = "UTC" } ================================================ FILE: 1.19_linux/time/zoneinfo_unix_test.go.patch ================================================ //--from import ( "os" "testing" "time" ) //--to import ( "testing" ) //--from func TestEnvTZUsage(t *testing.T) { const env = "TZ" tz, ok := os.LookupEnv(env) if !ok { defer os.Unsetenv(env) } else { defer os.Setenv(env, tz) } defer time.ForceUSPacificForTesting() localZoneName := "Local" // The file may not exist. if _, err := os.Stat("/etc/localtime"); os.IsNotExist(err) { localZoneName = "UTC" } cases := []struct { nilFlag bool tz string local string }{ // no $TZ means use the system default /etc/localtime. {true, "", localZoneName}, // $TZ="" means use UTC. {false, "", "UTC"}, {false, ":", "UTC"}, {false, "Asia/Shanghai", "Asia/Shanghai"}, {false, ":Asia/Shanghai", "Asia/Shanghai"}, {false, "/etc/localtime", localZoneName}, {false, ":/etc/localtime", localZoneName}, } for _, c := range cases { time.ResetLocalOnceForTest() if c.nilFlag { os.Unsetenv(env) } else { os.Setenv(env, c.tz) } if time.Local.String() != c.local { t.Errorf("invalid Local location name for %q: got %q want %q", c.tz, time.Local, c.local) } } time.ResetLocalOnceForTest() // The file may not exist on Solaris 2 and IRIX 6. path := "/usr/share/zoneinfo/Asia/Shanghai" os.Setenv(env, path) if _, err := os.Stat(path); os.IsNotExist(err) { if time.Local.String() != "UTC" { t.Errorf(`invalid path should fallback to UTC: got %q want "UTC"`, time.Local) } return } if time.Local.String() != path { t.Errorf(`custom path should lead to path itself: got %q want %q`, time.Local, path) } timeInUTC := time.Date(2009, 1, 1, 12, 0, 0, 0, time.UTC) sameTimeInShanghai := time.Date(2009, 1, 1, 20, 0, 0, 0, time.Local) if !timeInUTC.Equal(sameTimeInShanghai) { t.Errorf("invalid timezone: got %q want %q", timeInUTC, sameTimeInShanghai) } time.ResetLocalOnceForTest() os.Setenv(env, ":"+path) if time.Local.String() != path { t.Errorf(`custom path should lead to path itself: got %q want %q`, time.Local, path) } time.ResetLocalOnceForTest() os.Setenv(env, path[:len(path)-1]) if time.Local.String() != "UTC" { t.Errorf(`invalid path should fallback to UTC: got %q want "UTC"`, time.Local) } } //--to func TestEnvTZUsage(t *testing.T) { t.Skip("location is not supported in this environment") } ================================================ FILE: 1.19_windows/runtime/abi_test.go.patch ================================================ //--from func TestFinalizerRegisterABI(t *testing.T) { //--to func TestFinalizerRegisterABI(t *testing.T) { t.Skip("creating a new process with os.Args[0] doesn't work in this environment") ================================================ FILE: 1.19_windows/runtime/cgo/gcc_fatalf.c.patch ================================================ //--from #include //--to ================================================ FILE: 1.19_windows/runtime/cgo/gcc_libinit.c.patch ================================================ //--from #include //--to ================================================ FILE: 1.19_windows/runtime/cgo/gcc_libinit_windows.c.patch ================================================ //--from #include //--to ================================================ FILE: 1.19_windows/runtime/cgo/gcc_windows_amd64.c.patch ================================================ //--from #include //--to //--from static void threadentry(void *v) { //--to static int getproccount() { static int proccount = 0; if (!proccount) { SYSTEM_INFO info; GetSystemInfo(&info); proccount = info.dwNumberOfProcessors; } return proccount; } static void threadentry(void *v) { SetThreadAffinityMask(GetCurrentThread(), (1< //--to //--append #define fprintf dummy_fprintf #define stderr dummy_stderr // TODO: Use OutputDebugMessage. #define dummy_fprintf(stream, format, ...) #define dummy_stderr 2 ================================================ FILE: 1.19_windows/runtime/crash_test.go.patch ================================================ //--from func TestRuntimePanic(t *testing.T) { testenv.MustHaveExec(t) cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=TestRuntimePanic")) cmd.Env = append(cmd.Env, "GO_TEST_RUNTIME_PANIC=1") out, err := cmd.CombinedOutput() t.Logf("%s", out) if err == nil { t.Error("child process did not fail") } else if want := "runtime.unexportedPanicForTesting"; !bytes.Contains(out, []byte(want)) { t.Errorf("output did not contain expected string %q", want) } } //--to func TestRuntimePanic(t *testing.T) { t.Skip("analyzing output is not supported in this environment") } //--from func TestG0StackOverflow(t *testing.T) { testenv.MustHaveExec(t) switch runtime.GOOS { case "darwin", "dragonfly", "freebsd", "linux", "netbsd", "openbsd", "android": t.Skipf("g0 stack is wrong on pthread platforms (see golang.org/issue/26061)") } if os.Getenv("TEST_G0_STACK_OVERFLOW") != "1" { cmd := testenv.CleanCmdEnv(exec.Command(os.Args[0], "-test.run=TestG0StackOverflow", "-test.v")) cmd.Env = append(cmd.Env, "TEST_G0_STACK_OVERFLOW=1") out, err := cmd.CombinedOutput() // Don't check err since it's expected to crash. if n := strings.Count(string(out), "morestack on g0\n"); n != 1 { t.Fatalf("%s\n(exit status %v)", out, err) } // Check that it's a signal-style traceback. if runtime.GOOS != "windows" { if want := "PC="; !strings.Contains(string(out), want) { t.Errorf("output does not contain %q:\n%s", want, out) } } return } runtime.G0StackOverflow() } //--to func TestG0StackOverflow(t *testing.T) { t.Skip("analyzing output is not supported in this environment") } ================================================ FILE: 1.19_windows/runtime/malloc_test.go.patch ================================================ //--from func TestArenaCollision(t *testing.T) { //--to func TestArenaCollision(t *testing.T) { t.Skip("creating a new process with os.Args[0] doesn't work in this environment") ================================================ FILE: 1.19_windows/runtime/os_windows.go.patch ================================================ //--from //go:cgo_import_dynamic runtime._GetConsoleMode GetConsoleMode%2 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._SetConsoleCtrlHandler SetConsoleCtrlHandler%2 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._WriteConsoleW WriteConsoleW%5 "kernel32.dll" //--to //go:cgo_import_dynamic runtime._OutputDebugStringW OutputDebugStringW%1 "kernel32.dll" //--from _GetConsoleMode, //--to //--from _SetConsoleCtrlHandler, //--to //--from _WriteConsoleW, //--to _OutputDebugStringW, //--from _timeBeginPeriod, _timeEndPeriod, //--to //--from var winmmdll = []byte("winmm.dll\000") m32 := windowsLoadSystemLib(winmmdll) if m32 == 0 { throw("winmm.dll not found") } _timeBeginPeriod = windowsFindfunc(m32, []byte("timeBeginPeriod\000")) _timeEndPeriod = windowsFindfunc(m32, []byte("timeEndPeriod\000")) if _timeBeginPeriod == nil || _timeEndPeriod == nil { throw("timeBegin/EndPeriod not found") } //--to //--from // We call these all the way here, late in init, so that malloc works // for the callback functions these generate. var fn any = ctrlHandler ctrlHandlerPC := compileCallback(*efaceOf(&fn), true) stdcall2(_SetConsoleCtrlHandler, ctrlHandlerPC, 1) //--to //--from func osRelax(relax bool) uint32 { if haveHighResTimer { // If the high resolution timer is available, the runtime uses the timer // to sleep for short durations. This means there's no need to adjust // the global clock frequency. return 0 } if relax { return uint32(stdcall1(_timeEndPeriod, 1)) } else { return uint32(stdcall1(_timeBeginPeriod, 1)) } } //--to func osRelax(relax bool) uint32 { if haveHighResTimer { // If the high resolution timer is available, the runtime uses the timer // to sleep for short durations. This means there's no need to adjust // the global clock frequency. return 0 } throw("not reached") return 0 } //--from func write1(fd uintptr, buf unsafe.Pointer, n int32) int32 { const ( _STD_OUTPUT_HANDLE = ^uintptr(10) // -11 _STD_ERROR_HANDLE = ^uintptr(11) // -12 ) var handle uintptr switch fd { case 1: handle = stdcall1(_GetStdHandle, _STD_OUTPUT_HANDLE) case 2: handle = stdcall1(_GetStdHandle, _STD_ERROR_HANDLE) default: // assume fd is real windows handle. handle = fd } isASCII := true b := (*[1 << 30]byte)(buf)[:n] for _, x := range b { if x >= 0x80 { isASCII = false break } } if !isASCII { var m uint32 isConsole := stdcall2(_GetConsoleMode, handle, uintptr(unsafe.Pointer(&m))) != 0 // If this is a console output, various non-unicode code pages can be in use. // Use the dedicated WriteConsole call to ensure unicode is printed correctly. if isConsole { return int32(writeConsole(handle, buf, n)) } } var written uint32 stdcall5(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--to func write1(fd uintptr, buf unsafe.Pointer, n int32) int32 { const ( _STD_OUTPUT_HANDLE = ^uintptr(10) // -11 _STD_ERROR_HANDLE = ^uintptr(11) // -12 ) var handle uintptr switch fd { case 1: handle = stdcall1(_GetStdHandle, _STD_OUTPUT_HANDLE) case 2: handle = stdcall1(_GetStdHandle, _STD_ERROR_HANDLE) default: // assume fd is real windows handle. handle = fd } if fd == 1 || fd == 2 { // Note that handle is not used anyway. return int32(writeConsole(handle, buf, n)) } var written uint32 stdcall5(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--from func writeConsoleUTF16(handle uintptr, b []uint16) { l := uint32(len(b)) if l == 0 { return } var written uint32 stdcall5(_WriteConsoleW, handle, uintptr(unsafe.Pointer(&b[0])), uintptr(l), uintptr(unsafe.Pointer(&written)), 0, ) return } //--to func writeConsoleUTF16(handle uintptr, b []uint16) { b = b[:len(b)+1] b[len(b)-1] = 0 l := uint32(len(b)) if l <= 1 { return } stdcall1(_OutputDebugStringW, uintptr(unsafe.Pointer(&b[0])), ) return } ================================================ FILE: 1.19_windows/runtime/syscall_windows.go.patch ================================================ //--from func syscall_SyscallN(trap uintptr, args ...uintptr) (r1, r2, err uintptr) { //--to func syscall_SyscallN(trap uintptr, args ...uintptr) (r1, r2, err uintptr) { if trap == 0 { panic("trap must not be 0 at SyscallN") } ================================================ FILE: 1.19_windows/runtime/syscall_windows_test.go.patch ================================================ //--from func TestNumCPU(t *testing.T) { //--to func TestNumCPU(t *testing.T) { t.Skip("creating a new process with os.Args[0] doesn't work in this environment") ================================================ FILE: 1.19_windows/sync/mutex_test.go.patch ================================================ //--from import ( "fmt" "internal/testenv" "os" "os/exec" "runtime" "strings" . "sync" "testing" "time" ) //--to import ( "fmt" "os" "runtime" . "sync" "testing" "time" ) //--from func TestMutexMisuse(t *testing.T) { testenv.MustHaveExec(t) for _, test := range misuseTests { out, err := exec.Command(os.Args[0], "TESTMISUSE", test.name).CombinedOutput() if err == nil || !strings.Contains(string(out), "unlocked") { t.Errorf("%s: did not find failure with message about unlocked lock: %s\n%s\n", test.name, err, out) } } } //--to func TestMutexMisuse(t *testing.T) { t.Skip("analyzing output is not supported in this environment") } ================================================ FILE: 1.20_linux/internal/reflectlite/reflect_mirror_test.go.patch ================================================ //--from func TestMirrorWithReflect(t *testing.T) { //--to func TestMirrorWithReflect(t *testing.T) { t.Skip("file is not supported in this environment") return ================================================ FILE: 1.20_linux/internal/testenv/exec.go.patch ================================================ //--from func HasExec() bool { switch runtime.GOOS { case "js", "ios": return false } return true } //--to func HasExec() bool { return false } ================================================ FILE: 1.20_linux/internal/testenv/testenv.go.patch ================================================ //--from func HasGoBuild() bool { if os.Getenv("GO_GCFLAGS") != "" { // It's too much work to require every caller of the go command // to pass along "-gcflags="+os.Getenv("GO_GCFLAGS"). // For now, if $GO_GCFLAGS is set, report that we simply can't // run go build. return false } switch runtime.GOOS { case "android", "js", "ios": return false } return true } //--to func HasGoBuild() bool { return false } ================================================ FILE: 1.20_linux/internal/testenv/testenv_notunix.go.patch ================================================ //--from //go:build windows || plan9 || (js && wasm) //--to //go:build windows || plan9 || (js && wasm) || linux ================================================ FILE: 1.20_linux/internal/testenv/testenv_unix.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.20_linux/math/big/link_test.go.patch ================================================ //--from import ( "bytes" "internal/testenv" "os" "os/exec" "path/filepath" "testing" ) //--to import ( "testing" ) //--from func TestLinkerGC(t *testing.T) { if testing.Short() { t.Skip("skipping in short mode") } t.Parallel() tmp := t.TempDir() goBin := testenv.GoToolPath(t) goFile := filepath.Join(tmp, "x.go") file := []byte(`package main import _ "math/big" func main() {} `) if err := os.WriteFile(goFile, file, 0644); err != nil { t.Fatal(err) } cmd := exec.Command(goBin, "build", "-o", "x.exe", "x.go") cmd.Dir = tmp if out, err := cmd.CombinedOutput(); err != nil { t.Fatalf("compile: %v, %s", err, out) } cmd = exec.Command(goBin, "tool", "nm", "x.exe") cmd.Dir = tmp nm, err := cmd.CombinedOutput() if err != nil { t.Fatalf("nm: %v, %s", err, nm) } const want = "runtime.main" if !bytes.Contains(nm, []byte(want)) { // Test the test. t.Errorf("expected symbol %q not found", want) } bad := []string{ "math/big.(*Float)", "math/big.(*Rat)", "math/big.(*Int)", } for _, sym := range bad { if bytes.Contains(nm, []byte(sym)) { t.Errorf("unexpected symbol %q found", sym) } } if t.Failed() { t.Logf("Got: %s", nm) } } //--to func TestLinkerGC(t *testing.T) { t.Skip("go tools are not supported in this environment") } ================================================ FILE: 1.20_linux/runtime/align_test.go.patch ================================================ //--from import ( "go/ast" "go/build" "go/importer" "go/parser" "go/printer" "go/token" "go/types" "internal/testenv" "os" "regexp" "runtime" "strings" "testing" ) //--to import ( "go/ast" "go/build" "go/printer" "go/token" "go/types" "strings" "testing" ) //--from func TestAtomicAlignment(t *testing.T) { testenv.MustHaveGoBuild(t) // go command needed to resolve std .a files for importer.Default(). // Read the code making the tables above, to see which fields and // variables we are currently checking. checked := map[string]bool{} x, err := os.ReadFile("./align_runtime_test.go") if err != nil { t.Fatalf("read failed: %v", err) } fieldDesc := map[int]string{} r := regexp.MustCompile(`unsafe[.]Offsetof[(](\w+){}[.](\w+)[)]`) matches := r.FindAllStringSubmatch(string(x), -1) for i, v := range matches { checked["field runtime."+v[1]+"."+v[2]] = true fieldDesc[i] = v[1] + "." + v[2] } varDesc := map[int]string{} r = regexp.MustCompile(`unsafe[.]Pointer[(]&(\w+)[)]`) matches = r.FindAllStringSubmatch(string(x), -1) for i, v := range matches { checked["var "+v[1]] = true varDesc[i] = v[1] } // Check all of our alignemnts. This is the actual core of the test. for i, d := range runtime.AtomicFields { if d%8 != 0 { t.Errorf("field alignment of %s failed: offset is %d", fieldDesc[i], d) } } for i, p := range runtime.AtomicVariables { if uintptr(p)%8 != 0 { t.Errorf("variable alignment of %s failed: address is %x", varDesc[i], p) } } // The code above is the actual test. The code below attempts to check // that the tables used by the code above are exhaustive. // Parse the whole runtime package, checking that arguments of // appropriate atomic operations are in the list above. fset := token.NewFileSet() m, err := parser.ParseDir(fset, ".", nil, 0) if err != nil { t.Fatalf("parsing runtime failed: %v", err) } pkg := m["runtime"] // Note: ignore runtime_test and main packages // Filter files by those for the current architecture/os being tested. fileMap := map[string]bool{} for _, f := range buildableFiles(t, ".") { fileMap[f] = true } var files []*ast.File for fname, f := range pkg.Files { if fileMap[fname] { files = append(files, f) } } // Call go/types to analyze the runtime package. var info types.Info info.Types = map[ast.Expr]types.TypeAndValue{} conf := types.Config{Importer: importer.Default()} _, err = conf.Check("runtime", fset, files, &info) if err != nil { t.Fatalf("typechecking runtime failed: %v", err) } // Analyze all atomic.*64 callsites. v := Visitor{t: t, fset: fset, types: info.Types, checked: checked} ast.Walk(&v, pkg) } //--to func TestAtomicAlignment(t *testing.T) { t.Skip("file is not supported in this environment") } ================================================ FILE: 1.20_linux/runtime/callers_test.go.patch ================================================ //--from func TestCallersNilPointerPanic(t *testing.T) { // Make sure we don't have any extra frames on the stack (due to // open-coded defer processing) want := []string{"runtime.Callers", "runtime_test.TestCallersNilPointerPanic.func1", "runtime.gopanic", "runtime.panicmem", "runtime.sigpanic", "runtime_test.TestCallersNilPointerPanic"} defer func() { if r := recover(); r == nil { t.Fatal("did not panic") } pcs := make([]uintptr, 20) pcs = pcs[:runtime.Callers(0, pcs)] testCallersEqual(t, pcs, want) }() var p *int if *p == 3 { t.Fatal("did not see nil pointer panic") } } //--to func TestCallersNilPointerPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } //--from func TestCallersDeferNilFuncPanic(t *testing.T) { // Make sure we don't have any extra frames on the stack. We cut off the check // at runtime.sigpanic, because non-open-coded defers (which may be used in // non-opt or race checker mode) include an extra 'deferreturn' frame (which is // where the nil pointer deref happens). state := 1 want := []string{"runtime.Callers", "runtime_test.TestCallersDeferNilFuncPanic.func1", "runtime.gopanic", "runtime.panicmem", "runtime.sigpanic"} defer func() { if r := recover(); r == nil { t.Fatal("did not panic") } pcs := make([]uintptr, 20) pcs = pcs[:runtime.Callers(0, pcs)] testCallersEqual(t, pcs, want) if state == 1 { t.Fatal("nil defer func panicked at defer time rather than function exit time") } }() var f func() defer f() // Use the value of 'state' to make sure nil defer func f causes panic at // function exit, rather than at the defer statement. state = 2 } //--to func TestCallersDeferNilFuncPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } //--from func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { state := 1 want := []string{"runtime.Callers", "runtime_test.TestCallersDeferNilFuncPanicWithLoop.func1", "runtime.gopanic", "runtime.panicmem", "runtime.sigpanic", "runtime.deferreturn", "runtime_test.TestCallersDeferNilFuncPanicWithLoop"} defer func() { if r := recover(); r == nil { t.Fatal("did not panic") } pcs := make([]uintptr, 20) pcs = pcs[:runtime.Callers(0, pcs)] testCallersEqual(t, pcs, want) if state == 1 { t.Fatal("nil defer func panicked at defer time rather than function exit time") } }() for i := 0; i < 1; i++ { var f func() defer f() } // Use the value of 'state' to make sure nil defer func f causes panic at // function exit, rather than at the defer statement. state = 2 } //--to func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } ================================================ FILE: 1.20_linux/runtime/cgo/cgo.go.patch ================================================ //--from */ import "C" //--to #cgo !darwin LDFLAGS: -Wl,-unresolved-symbols=ignore-all #cgo darwin LDFLAGS: -Wl,-undefined,dynamic_lookup */ import "C" ================================================ FILE: 1.20_linux/runtime/cgo/gcc_linux_amd64.c.patch ================================================ //--from #include #include #include // strerror #include #include #include "libcgo.h" #include "libcgo_unix.h" //--to #include #include #include // strerror #include #include "libcgo.h" #include "libcgo_unix.h" //--from void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--to void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; pthread_t p; size_t size; int err; pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--from static void* threadentry(void *v) { //--to static void* threadentry(void *v) { extern void hitsumabushi_initializeThread(void); hitsumabushi_initializeThread(); ================================================ FILE: 1.20_linux/runtime/cgo/gcc_linux_arm64.c.patch ================================================ //--from void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--to void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 16 * 4096); // Hack for some special environments pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--from void x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase) { pthread_attr_t *attr; size_t size; /* The memory sanitizer distributed with versions of clang before 3.8 has a bug: if you call mmap before malloc, mmap may return an address that is later overwritten by the msan library. Avoid this problem by forcing a call to malloc here, before we ever call malloc. This is only required for the memory sanitizer, so it's unfortunate that we always run it. It should be possible to remove this when we no longer care about versions of clang before 3.8. The test for this is misc/cgo/testsanitizers. GCC works hard to eliminate a seemingly unnecessary call to malloc, so we actually use the memory we allocate. */ setg_gcc = setg; attr = (pthread_attr_t*)malloc(sizeof *attr); if (attr == NULL) { fatalf("malloc failed: %s", strerror(errno)); } pthread_attr_init(attr); pthread_attr_getstacksize(attr, &size); g->stacklo = (uintptr)&size - size + 4096; pthread_attr_destroy(attr); free(attr); if (x_cgo_inittls) { x_cgo_inittls(tlsg, tlsbase); } } //--to void x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase) { pthread_attr_t *attr; size_t size; /* The memory sanitizer distributed with versions of clang before 3.8 has a bug: if you call mmap before malloc, mmap may return an address that is later overwritten by the msan library. Avoid this problem by forcing a call to malloc here, before we ever call malloc. This is only required for the memory sanitizer, so it's unfortunate that we always run it. It should be possible to remove this when we no longer care about versions of clang before 3.8. The test for this is misc/cgo/testsanitizers. GCC works hard to eliminate a seemingly unnecessary call to malloc, so we actually use the memory we allocate. */ setg_gcc = setg; attr = (pthread_attr_t*)malloc(sizeof *attr); if (attr == NULL) { fatalf("malloc failed: %s", strerror(errno)); } pthread_attr_init(attr); pthread_attr_setstacksize(attr, 16 * 4096); // Hack for some special environments pthread_attr_getstacksize(attr, &size); g->stacklo = (uintptr)&size - size + 4096; pthread_attr_destroy(attr); free(attr); if (x_cgo_inittls) { x_cgo_inittls(tlsg, tlsbase); } } //--from static void* threadentry(void *v) { //--to static void* threadentry(void *v) { extern void hitsumabushi_initializeThread(void); hitsumabushi_initializeThread(); ================================================ FILE: 1.20_linux/runtime/cgo/gcc_setenv.c.patch ================================================ //--from void x_cgo_setenv(char **arg) { _cgo_tsan_acquire(); setenv(arg[0], arg[1], 1); _cgo_tsan_release(); } //--to void x_cgo_setenv(char **arg) { } //--from void x_cgo_unsetenv(char **arg) { _cgo_tsan_acquire(); unsetenv(arg[0]); _cgo_tsan_release(); } //--to void x_cgo_unsetenv(char **arg) { } ================================================ FILE: 1.20_linux/runtime/cgo/gcc_sigaction.c.patch ================================================ //--from // +build linux,amd64 linux,arm64 linux,ppc64le //--to // +build linux,arm64 linux,ppc64le ================================================ FILE: 1.20_linux/runtime/cgo/hitsumabushi_clock_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp) { return clock_gettime(clk_id, tp); } ================================================ FILE: 1.20_linux/runtime/cgo/hitsumabushi_cpu_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int32_t hitsumabushi_getproccount() { return 1; } ================================================ FILE: 1.20_linux/runtime/cgo/hitsumabushi_filesystem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include #include #include "libcgo.h" #include "libcgo_unix.h" static const int kFDOffset = 100; typedef struct { const void* content; size_t content_size; size_t current; int32_t fd; } pseudo_file; // TODO: Do we need to protect this by mutex? static pseudo_file pseudo_files[100]; static pthread_mutex_t* pseudo_file_mutex() { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; return &mutex; } static int32_t open_pseudo_file(const void* content, size_t content_size) { pthread_mutex_lock(pseudo_file_mutex()); int index = 0; int found = 0; for (int i = 0; i < sizeof(pseudo_files) / sizeof(pseudo_file); i++) { if (pseudo_files[i].fd == 0) { index = i; found = 1; break; } } if (!found) { // Too many pseudo files are opened. pthread_mutex_unlock(pseudo_file_mutex()); return -1; } int32_t fd = index + kFDOffset; pseudo_files[index].content = content; pseudo_files[index].content_size = content_size; pseudo_files[index].current = 0; pseudo_files[index].fd = fd; pthread_mutex_unlock(pseudo_file_mutex()); return fd; } static size_t read_pseudo_file(int32_t fd, void *p, int32_t n) { pthread_mutex_lock(pseudo_file_mutex()); int32_t index = fd - kFDOffset; pseudo_file *file = &pseudo_files[index]; size_t rest = file->content_size - file->current; if (rest < n) { n = rest; } memcpy(p, file->content + file->current, n); pseudo_files[index].current += n; pthread_mutex_unlock(pseudo_file_mutex()); return n; } static void close_pseudo_file(int32_t fd) { pthread_mutex_lock(pseudo_file_mutex()); int32_t index = fd - kFDOffset; pseudo_files[index].content = NULL; pseudo_files[index].content_size = 0; pseudo_files[index].current = 0; pseudo_files[index].fd = 0; pthread_mutex_unlock(pseudo_file_mutex()); } int32_t hitsumabushi_closefd(int32_t fd) { if (fd >= kFDOffset) { close_pseudo_file(fd); return 0; } fprintf(stderr, "syscall close(%d) is not implemented\n", fd); return 0; } int32_t hitsumabushi_open(char *name, int32_t mode, int32_t perm) { if (strcmp(name, "/proc/self/auxv") == 0) { static const char auxv[] = "\x06\x00\x00\x00\x00\x00\x00\x00" // _AT_PAGESZ tag (6) "\x00\x10\x00\x00\x00\x00\x00\x00" // 4096 bytes per page "\x00\x00\x00\x00\x00\x00\x00\x00" // Dummy bytes "\x00\x00\x00\x00\x00\x00\x00\x00"; // Dummy bytes return open_pseudo_file(auxv, sizeof(auxv) / sizeof(char)); } if (strcmp(name, "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size") == 0) { static const char hpage_pmd_size[] = "\x30\x5c"; // '0', '\n' return open_pseudo_file(hpage_pmd_size, sizeof(hpage_pmd_size) / sizeof(char)); } fprintf(stderr, "syscall open(%s, %d, %d) is not implemented\n", name, mode, perm); const static int kENOENT = 0x2; return kENOENT; } int32_t hitsumabushi_read(int32_t fd, void *p, int32_t n) { if (fd >= kFDOffset) { return read_pseudo_file(fd, p, n); } fprintf(stderr, "syscall read(%d, %p, %d) is not implemented\n", fd, p, n); const static int kEBADF = 0x9; return kEBADF; } int32_t hitsumabushi_write1(uintptr_t fd, void *p, int32_t n) { static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; int32_t ret = 0; pthread_mutex_lock(&m); switch (fd) { case 1: ret = fwrite(p, 1, n, stdout); fflush(stdout); break; case 2: ret = fwrite(p, 1, n, stderr); fflush(stderr); break; default: fprintf(stderr, "syscall write(%lu, %p, %d) is not implemented\n", fd, p, n); ret = -EBADF; break; } pthread_mutex_unlock(&m); return ret; } int32_t hitsumabushi_lseek(uintptr_t fd, off_t offset, int32_t whence) { fprintf(stderr, "syscall lseek(%lu, %lu, %d) is not implemented\n", fd, offset, whence); return -ENOSYS; } int32_t hitsumabushi_fcntl(int32_t fd, int32_t cmd, int32_t arg) { if (fd == 0 || fd == 1 || fd == 2) { if (cmd == F_GETFL) { return 0; } } fprintf(stderr, "syscall fcntl(%d, %d, %d) is not implemented\n", fd, cmd, arg); return -EBADF; } int32_t hitsumabushi_fstat(int32_t fd, struct stat *stat) { fprintf(stderr, "syscall fstat(%d, %p) is not implemented\n", fd, stat); return -ENOSYS; } int32_t hitsumabushi_renameat(int32_t fd1, char* name1, int32_t fd2, char* name2) { fprintf(stderr, "syscall renameat(%d, %s, %d, %s) is not implemented\n", fd1, name1, fd2, name2); return -ENOSYS; } int32_t hitsumabushi_fstatat(int32_t fd, char* name, struct stat* p, int32_t flags) { fprintf(stderr, "syscall fstatat(%d, %s, %p, %d) is not implemented\n", fd, name, p, flags); return -ENOSYS; } ================================================ FILE: 1.20_linux/runtime/cgo/hitsumabushi_futex_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include #include #include #include static const int kPseudoFutexWait = 0; static const int kPseudoFutexWake = 1; static void pseudo_futex(uint32_t *uaddr, int mode, uint32_t val, const struct timespec *reltime) { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; struct timespec abstime; if (reltime) { // We are not sure CLOCK_REALTIME is correct or not here. // However, this time limit is actually not used as the condition variable is shared by // all the threads. Before the time limit reaches, the thread wakes up in 99.9999...% cases. clock_gettime(CLOCK_REALTIME, &abstime); abstime.tv_sec += reltime->tv_sec; abstime.tv_nsec += reltime->tv_nsec; if (1000000000 <= abstime.tv_nsec) { abstime.tv_sec += 1; abstime.tv_nsec -= 1000000000; } } int ret = pthread_mutex_lock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_lock failed: %d\n", ret); abort(); } switch (mode) { case kPseudoFutexWait: if (reltime) { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_timedwait(&cond, &mutex, &abstime); if (ret && ret != ETIMEDOUT) { fprintf(stderr, "pthread_cond_timedwait failed: %d\n", ret); abort(); } } } else { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_wait(&cond, &mutex); if (ret) { fprintf(stderr, "pthread_cond_wait failed: %d\n", ret); abort(); } } } break; case kPseudoFutexWake: if (val != 1) { fprintf(stderr, "val for waking must be 1 but %d\n", val); abort(); } // TODO: broadcasting is not efficient. Use a mutex for each uaddr. int ret = pthread_cond_broadcast(&cond); if (ret) { fprintf(stderr, "pthread_cond_broadcast failed: %d\n", ret); abort(); } break; } ret = pthread_mutex_unlock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_unlock failed: %d\n", ret); abort(); } } int32_t hitsumabushi_futex(uint32_t *uaddr, int32_t futex_op, uint32_t val, const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3) { enum { kFutexWaitPrivate = 128, kFutexWakePrivate = 129, }; switch (futex_op) { case kFutexWaitPrivate: pseudo_futex(uaddr, kPseudoFutexWait, val, timeout); break; case kFutexWakePrivate: pseudo_futex(uaddr, kPseudoFutexWake, val, NULL); break; } // This function should return the number of awaken threads, but now it is impossible. // Just return 0. return 0; } ================================================ FILE: 1.20_linux/runtime/cgo/hitsumabushi_mem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include void* hitsumabushi_sysReserveOS(void* v, uintptr_t n); void* hitsumabushi_sysAllocOS(uintptr_t n) { return hitsumabushi_sysReserveOS(NULL, n); } void hitsumabushi_sysUnusedOS(void* v, uintptr_t n) { } void hitsumabushi_sysUsedOS(void* v, uintptr_t n) { } void hitsumabushi_sysHugePageOS(void* v, uintptr_t n) { } void hitsumabushi_sysFreeOS(void* v, uintptr_t n) { } void hitsumabushi_sysFaultOS(void* v, uintptr_t n) { } void* hitsumabushi_sysReserveOS(void* v, uintptr_t n) { if (v) { return NULL; } return calloc(n, 1); } void hitsumabushi_sysMapOS(void* v, uintptr_t n) { } ================================================ FILE: 1.20_linux/runtime/cgo/hitsumabushi_syscalls_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include // for usleep #include // for size_t #include "libcgo.h" #include "libcgo_unix.h" typedef unsigned int gid_t; extern int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp); extern int32_t hitsumabushi_getproccount(); void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { abort(); return NULL; } int munmap(void *addr, size_t length) { abort(); return 0; } int pthread_sigmask(int how, void *set, void *oldset) { // Do nothing. return 0; } int setegid(gid_t gid) { // Do nothing. return 0; } int seteuid(uid_t gid) { // Do nothing. return 0; } int setgid(gid_t gid) { // Do nothing. return 0; } int setgroups(size_t size, const gid_t *list) { // Do nothing. return 0; } int setregid(gid_t rgid, gid_t egid) { // Do nothing. return 0; } int setreuid(uid_t ruid, uid_t euid) { // Do nothing. return 0; } int setresgid(gid_t rgid, gid_t egid, gid_t sgid) { // Do nothing. return 0; } int setresuid(uid_t ruid, uid_t euid, uid_t suid) { // Do nothing. return 0; } int setuid(uid_t gid) { // Do nothing. return 0; } int sigaction(int signum, void *act, void *oldact) { // Do nothing. return 0; } int sigaddset(void *set, int signum) { // Do nothing. return 0; } int sigemptyset(void *set) { // Do nothing. return 0; } int sigfillset(void *set) { // Do nothing. return 0; } int sigismember(void *set, int signum) { // Do nothing. return 0; } uint32_t hitsumabushi_gettid() { uint64_t tid64 = (uint64_t)(pthread_self()); uint32_t tid = (uint32_t)(tid64 >> 32) ^ (uint32_t)(tid64); return tid; } int64_t hitsumabushi_nanotime1() { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_MONOTONIC, &tp); return (int64_t)(tp.tv_sec) * 1000000000ll + (int64_t)tp.tv_nsec; } int32_t hitsumabushi_osyield() { return sched_yield(); } int32_t hitsumabushi_sched_getaffinity(pid_t pid, size_t cpusetsize, void *mask) { int32_t numcpu = hitsumabushi_getproccount(); for (int32_t i = 0; i < numcpu; i += 8) ((unsigned char*)mask)[i / 8] = (unsigned char)((1u << (numcpu - i)) - 1); // https://man7.org/linux/man-pages/man2/sched_setaffinity.2.html // > On success, the raw sched_getaffinity() system call returns the // > number of bytes placed copied into the mask buffer; return (numcpu + 7) / 8; } void hitsumabushi_usleep(useconds_t usec) { usleep(usec); } void hitsumabushi_walltime1(int64_t* sec, int32_t* nsec) { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_REALTIME, &tp); *sec = tp.tv_sec; *nsec = tp.tv_nsec; } void hitsumabushi_exit(int32_t code) { exit(code); } ================================================ FILE: 1.20_linux/runtime/cgo/hitsumabushi_thread_linux.c ================================================ void hitsumabushi_initializeThread(void) { } ================================================ FILE: 1.20_linux/runtime/cgo/linux_syscall.c.patch ================================================ //--from #include #include #include #include #include "libcgo.h" //--to #include #include #include #include "libcgo.h" //--from void _cgo_libc_setegid(argset_t* x) { SET_RETVAL(setegid((gid_t) x->args[0])); } //--to void _cgo_libc_setegid(argset_t* x) { } //--from void _cgo_libc_seteuid(argset_t* x) { SET_RETVAL(seteuid((uid_t) x->args[0])); } //--to void _cgo_libc_seteuid(argset_t* x) { } //--from void _cgo_libc_setgid(argset_t* x) { SET_RETVAL(setgid((gid_t) x->args[0])); } //--to void _cgo_libc_setgid(argset_t* x) { } //--from void _cgo_libc_setgroups(argset_t* x) { SET_RETVAL(setgroups((size_t) x->args[0], (const gid_t *) x->args[1])); } //--to void _cgo_libc_setgroups(argset_t* x) { } //--from void _cgo_libc_setregid(argset_t* x) { SET_RETVAL(setregid((gid_t) x->args[0], (gid_t) x->args[1])); } //--to void _cgo_libc_setregid(argset_t* x) { } //--from void _cgo_libc_setresgid(argset_t* x) { SET_RETVAL(setresgid((gid_t) x->args[0], (gid_t) x->args[1], (gid_t) x->args[2])); } //--to void _cgo_libc_setresgid(argset_t* x) { } //--from void _cgo_libc_setreuid(argset_t* x) { SET_RETVAL(setreuid((uid_t) x->args[0], (uid_t) x->args[1])); } //--to void _cgo_libc_setreuid(argset_t* x) { } //--from void _cgo_libc_setuid(argset_t* x) { SET_RETVAL(setuid((uid_t) x->args[0])); } //--to void _cgo_libc_setuid(argset_t* x) { } ================================================ FILE: 1.20_linux/runtime/cgo/sigaction.go.patch ================================================ //--from //go:build (linux && amd64) || (freebsd && amd64) || (linux && arm64) || (linux && ppc64le) //--to //go:build (freebsd && amd64) || (linux && arm64) || (linux && ppc64le) ================================================ FILE: 1.20_linux/runtime/crash_test.go.patch ================================================ //--from import ( "bytes" "errors" "flag" "fmt" "internal/testenv" "os" "os/exec" "path/filepath" "regexp" "runtime" "strings" "sync" "testing" "time" ) //--to import ( "bytes" "errors" "flag" "internal/testenv" "os" "os/exec" "regexp" "runtime" "strings" "sync" "testing" "time" ) //--from func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { if *flagQuick { t.Skip("-quick") } testenv.MustHaveGoBuild(t) testprog.Lock() if testprog.dir == "" { dir, err := os.MkdirTemp("", "go-build") if err != nil { t.Fatalf("failed to create temp directory: %v", err) } testprog.dir = dir toRemove = append(toRemove, dir) } if testprog.target == nil { testprog.target = make(map[string]*buildexe) } name := binary if len(flags) > 0 { name += "_" + strings.Join(flags, "_") } target, ok := testprog.target[name] if !ok { target = &buildexe{} testprog.target[name] = target } dir := testprog.dir // Unlock testprog while actually building, so that other // tests can look up executables that were already built. testprog.Unlock() target.once.Do(func() { // Only do two "go build"'s at a time, // to keep load from getting too high. serializeBuild <- true defer func() { <-serializeBuild }() // Don't get confused if testenv.GoToolPath calls t.Skip. target.err = errors.New("building test called t.Skip") exe := filepath.Join(dir, name+".exe") t.Logf("running go build -o %s %s", exe, strings.Join(flags, " ")) cmd := exec.Command(testenv.GoToolPath(t), append([]string{"build", "-o", exe}, flags...)...) cmd.Dir = "testdata/" + binary out, err := testenv.CleanCmdEnv(cmd).CombinedOutput() if err != nil { target.err = fmt.Errorf("building %s %v: %v\n%s", binary, flags, err, out) } else { target.exe = exe target.err = nil } }) return target.exe, target.err } //--to func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { t.Skip("buildTestProg is not supported in this environment") return "", nil } //--from func TestPanicInlined(t *testing.T) { defer func() { r := recover() if r == nil { t.Fatalf("recover failed") } buf := make([]byte, 2048) n := runtime.Stack(buf, false) buf = buf[:n] if !bytes.Contains(buf, []byte("(*point).negate(")) { t.Fatalf("expecting stack trace to contain call to (*point).negate()") } }() pt := new(point) pt.negate() } //--to func TestPanicInlined(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") defer func() { r := recover() if r == nil { t.Fatalf("recover failed") } buf := make([]byte, 2048) n := runtime.Stack(buf, false) buf = buf[:n] if !bytes.Contains(buf, []byte("(*point).negate(")) { t.Fatalf("expecting stack trace to contain call to (*point).negate()") } }() pt := new(point) pt.negate() } ================================================ FILE: 1.20_linux/runtime/crash_unix_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.20_linux/runtime/debug/heapdump_test.go.patch ================================================ //--from import ( "os" "runtime" . "runtime/debug" "testing" ) //--to import ( "testing" ) //--from func TestWriteHeapDumpNonempty(t *testing.T) { if runtime.GOOS == "js" { t.Skipf("WriteHeapDump is not available on %s.", runtime.GOOS) } f, err := os.CreateTemp("", "heapdumptest") if err != nil { t.Fatalf("TempFile failed: %v", err) } defer os.Remove(f.Name()) defer f.Close() WriteHeapDump(f.Fd()) fi, err := f.Stat() if err != nil { t.Fatalf("Stat failed: %v", err) } const minSize = 1 if size := fi.Size(); size < minSize { t.Fatalf("Heap dump size %d bytes, expected at least %d bytes", size, minSize) } } //--to func TestWriteHeapDumpNonempty(t *testing.T) { t.Skip("file is not supported in this environment") } //--from func TestWriteHeapDumpFinalizers(t *testing.T) { if runtime.GOOS == "js" { t.Skipf("WriteHeapDump is not available on %s.", runtime.GOOS) } f, err := os.CreateTemp("", "heapdumptest") if err != nil { t.Fatalf("TempFile failed: %v", err) } defer os.Remove(f.Name()) defer f.Close() // bug 9172: WriteHeapDump couldn't handle more than one finalizer println("allocating objects") x := &Obj{} runtime.SetFinalizer(x, objfin) y := &Obj{} runtime.SetFinalizer(y, objfin) // Trigger collection of x and y, queueing of their finalizers. println("starting gc") runtime.GC() // Make sure WriteHeapDump doesn't fail with multiple queued finalizers. println("starting dump") WriteHeapDump(f.Fd()) println("done dump") } //--to func TestWriteHeapDumpFinalizers(t *testing.T) { t.Skip("file is not supported in this environment") } //--from func TestWriteHeapDumpTypeName(t *testing.T) { if runtime.GOOS == "js" { t.Skipf("WriteHeapDump is not available on %s.", runtime.GOOS) } f, err := os.CreateTemp("", "heapdumptest") if err != nil { t.Fatalf("TempFile failed: %v", err) } defer os.Remove(f.Name()) defer f.Close() WriteHeapDump(f.Fd()) dummy.M() dummy2.M() } //--to func TestWriteHeapDumpTypeName(t *testing.T) { t.Skip("file is not supported in this environment") } ================================================ FILE: 1.20_linux/runtime/debug/panic_test.go.patch ================================================ //--from import ( "runtime" "runtime/debug" "syscall" "testing" "unsafe" ) //--to import ( "testing" ) //--from func TestPanicOnFault(t *testing.T) { if runtime.GOARCH == "s390x" { t.Skip("s390x fault addresses are missing the low order bits") } if runtime.GOOS == "ios" { t.Skip("iOS doesn't provide fault addresses") } if runtime.GOOS == "netbsd" && runtime.GOARCH == "arm" { t.Skip("netbsd-arm doesn't provide fault address (golang.org/issue/45026)") } m, err := syscall.Mmap(-1, 0, 0x1000, syscall.PROT_READ /* Note: no PROT_WRITE */, syscall.MAP_SHARED|syscall.MAP_ANON) if err != nil { t.Fatalf("can't map anonymous memory: %s", err) } defer syscall.Munmap(m) old := debug.SetPanicOnFault(true) defer debug.SetPanicOnFault(old) const lowBits = 0x3e7 defer func() { r := recover() if r == nil { t.Fatalf("write did not fault") } type addressable interface { Addr() uintptr } a, ok := r.(addressable) if !ok { t.Fatalf("fault does not contain address") } want := uintptr(unsafe.Pointer(&m[lowBits])) got := a.Addr() if got != want { t.Fatalf("fault address %x, want %x", got, want) } }() m[lowBits] = 1 // will fault } //--to func TestPanicOnFault(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } ================================================ FILE: 1.20_linux/runtime/debug_test.go.patch ================================================ //--from //go:build (amd64 || arm64) && linux && !race //--to //go:build ignore ================================================ FILE: 1.20_linux/runtime/export_unix_test.go ================================================ // Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build unix package runtime const ( O_WRONLY = _O_WRONLY O_CREAT = _O_CREAT O_TRUNC = _O_TRUNC ) ================================================ FILE: 1.20_linux/runtime/internal/syscall/asm_linux_amd64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0 // a6 already in R9. // a5 already in R8. MOVQ SI, R10 // a4 MOVQ DI, DX // a3 MOVQ CX, SI // a2 MOVQ BX, DI // a1 // num already in AX. SYSCALL CMPQ AX, $0xfffffffffffff001 JLS ok NEGQ AX MOVQ AX, CX // errno MOVQ $-1, AX // r1 MOVQ $0, BX // r2 RET ok: // r1 already in AX. MOVQ DX, BX // r2 MOVQ $0, CX // errno RET //--to ================================================ FILE: 1.20_linux/runtime/internal/syscall/asm_linux_arm64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0-80 MOVD num+0(FP), R8 // syscall entry MOVD a1+8(FP), R0 MOVD a2+16(FP), R1 MOVD a3+24(FP), R2 MOVD a4+32(FP), R3 MOVD a5+40(FP), R4 MOVD a6+48(FP), R5 SVC CMN $4095, R0 BCC ok MOVD $-1, R4 MOVD R4, r1+56(FP) MOVD ZR, r2+64(FP) NEG R0, R0 MOVD R0, errno+72(FP) RET ok: MOVD R0, r1+56(FP) MOVD R1, r2+64(FP) MOVD ZR, errno+72(FP) RET //--to ================================================ FILE: 1.20_linux/runtime/internal/syscall/syscall_linux.go.patch ================================================ //--from func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) //--to func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { println("not implemented syscall at Syscall6", num) panic("syscall.Syscall6") return 0, 0, 0x26 // ENOSYS } //--from func syscall_RawSyscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { return Syscall6(num, a1, a2, a3, a4, a5, a6) } //--to func syscall_RawSyscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { println("not implemented syscall at RawSyscall6", num) panic("syscall.RawSyscall6") return 0, 0, 0x26 // ENOSYS } ================================================ FILE: 1.20_linux/runtime/internal/syscall/syscall_linux_test.go.patch ================================================ //--from import ( "runtime/internal/syscall" "testing" ) //--to import ( "testing" ) //--from func TestEpollctlErrorSign(t *testing.T) { v := syscall.EpollCtl(-1, 1, -1, &syscall.EpollEvent{}) const EBADF = 0x09 if v != EBADF { t.Errorf("epollctl = %v, want %v", v, EBADF) } } //--to func TestEpollctlErrorSign(t *testing.T) { t.Skip("Epollctl is not supported in this environment") } ================================================ FILE: 1.20_linux/runtime/mem_linux.go ================================================ // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This implementation is the most fundamental and minimal allocations like Wasm. // Malloced memory regions are never freed. package runtime import ( "internal/abi" "unsafe" ) // Don't split the stack as this method may be invoked without a valid G, which // prevents us from allocating more stack. // //go:nosplit //go:cgo_unsafe_args func sysAllocOS(n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysAllocOS_trampoline)), unsafe.Pointer(&n)) return } func sysAllocOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit //go:cgo_unsafe_args func sysUnusedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUnusedOS_trampoline)), unsafe.Pointer(&v)) } func sysUnusedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysUsedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUsedOS_trampoline)), unsafe.Pointer(&v)) } func sysUsedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysHugePageOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysHugePageOS_trampoline)), unsafe.Pointer(&v)) } func sysHugePageOS_trampoline(n uintptr, size uintptr) // Don't split the stack as this function may be invoked without a valid G, // which prevents us from allocating more stack. // //go:nosplit //go:cgo_unsafe_args func sysFreeOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFreeOS_trampoline)), unsafe.Pointer(&v)) } func sysFreeOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysFaultOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFaultOS_trampoline)), unsafe.Pointer(&v)) } func sysFaultOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysReserveOS(v unsafe.Pointer, n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysReserveOS_trampoline)), unsafe.Pointer(&v)) return } func sysReserveOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit //go:cgo_unsafe_args func sysMapOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysMapOS_trampoline)), unsafe.Pointer(&v)) } func sysMapOS_trampoline(n uintptr, size uintptr) ================================================ FILE: 1.20_linux/runtime/memmove_linux_amd64_test.go.patch ================================================ //--from func TestMemmoveOverflow(t *testing.T) { //--to func TestMemmoveOverflow(t *testing.T) { t.Skip("file is not supported in this environment") return ================================================ FILE: 1.20_linux/runtime/nbpipe_pipe2.go.patch ================================================ //--from //go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris //--to //go:build dragonfly || freebsd || netbsd || openbsd || solaris ================================================ FILE: 1.20_linux/runtime/nbpipe_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.20_linux/runtime/netpoll_epoll.go.patch ================================================ //--from //go:build linux //--to //go:build ignore ================================================ FILE: 1.20_linux/runtime/netpoll_fake.go.patch ================================================ //--from //go:build js && wasm //--to //go:build linux ================================================ FILE: 1.20_linux/runtime/norace_linux_test.go.patch ================================================ //--from import ( "internal/abi" "runtime" "testing" "time" "unsafe" ) //--to import ( "testing" ) //--from func TestNewOSProc0(t *testing.T) { runtime.NewOSProc0(0x800000, unsafe.Pointer(abi.FuncPCABIInternal(newOSProcCreated))) check := time.NewTicker(100 * time.Millisecond) defer check.Stop() end := time.After(5 * time.Second) for { select { case <-check.C: if newOSProcDone { return } case <-end: t.Fatalf("couldn't create new OS process") } } } //--to func TestNewOSProc0(t *testing.T) { t.Skip("newosproc0 is not supported in this environment") } ================================================ FILE: 1.20_linux/runtime/os_linux.go.patch ================================================ //--from import ( "internal/abi" "internal/goarch" "runtime/internal/atomic" "runtime/internal/syscall" "unsafe" ) //--to import ( "internal/abi" "runtime/internal/atomic" "runtime/internal/syscall" "unsafe" ) //--from //go:noescape func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 //--to //go:nosplit //go:cgo_unsafe_args func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 { ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(futex_trampoline)), unsafe.Pointer(&addr)) return ret } func futex_trampoline(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 //--from func sysargs(argc int32, argv **byte) { n := argc + 1 // skip over argv, envp to get to auxv for argv_index(argv, n) != nil { n++ } // skip NULL separator n++ // now argv+n is auxv auxv := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*goarch.PtrSize)) if sysauxv(auxv[:]) != 0 { return } // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } var buf [128]uintptr n = read(fd, noescape(unsafe.Pointer(&buf[0])), int32(unsafe.Sizeof(buf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. buf[len(buf)-2] = _AT_NULL sysauxv(buf[:]) } //--to func sysargs(argc int32, argv **byte) { // argc/argv is not reliable on some machines. // Skip analysing them. // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } var buf [128]uintptr n := read(fd, noescape(unsafe.Pointer(&buf[0])), int32(unsafe.Sizeof(buf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. buf[len(buf)-2] = _AT_NULL sysauxv(buf[:]) } //--from func getRandomData(r []byte) { if startupRandomData != nil { n := copy(r, startupRandomData) extendRandom(r, n) return } fd := open(&urandom_dev[0], 0 /* O_RDONLY */, 0) n := read(fd, unsafe.Pointer(&r[0]), int32(len(r))) closefd(fd) extendRandom(r, int(n)) } //--to // Use getRandomData in os_plan9.go. //go:nosplit func getRandomData(r []byte) { // inspired by wyrand see hash32.go for detail t := nanotime() v := getg().m.procid ^ uint64(t) for len(r) > 0 { v ^= 0xa0761d6478bd642f v *= 0xe7037ed1a0b428db size := 8 if len(r) < 8 { size = len(r) } for i := 0; i < size; i++ { r[i] = byte(v >> (8 * i)) } r = r[size:] v = v>>32 | v<<32 } } //--from func gettid() uint32 //--to //go:nosplit //go:cgo_unsafe_args func gettid() (tid uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(gettid_trampoline)), unsafe.Pointer(&tid)) return } func gettid_trampoline() uint32 //--from //go:noescape func sigaltstack(new, old *stackt) //--to func sigaltstack(new, old *stackt) { // Do nothing. } //--from func sigprocmask(how int32, new, old *sigset) { rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--to func sigprocmask(how int32, new, old *sigset) { // Do nothing. // rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--from func raise(sig uint32) //--to func raise(sig uint32) { // Do nothing } //--from func raiseproc(sig uint32) //--to func raiseproc(sig uint32) { // Do nothing } //--from //go:noescape func sched_getaffinity(pid, len uintptr, buf *byte) int32 //--to //go:nosplit //go:cgo_unsafe_args func sched_getaffinity(pid, len uintptr, buf *byte) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(sched_getaffinity_trampoline)), unsafe.Pointer(&pid)) } func sched_getaffinity_trampoline(pid, len uintptr, buf *byte) int32 //--from func osyield() //--to //go:nosplit //go:cgo_unsafe_args func osyield() { libcCall(unsafe.Pointer(abi.FuncPCABI0(osyield_trampoline)), nil) } func osyield_trampoline() //--from func sysSigaction(sig uint32, new, old *sigactiont) { //--to func sysSigaction(sig uint32, new, old *sigactiont) { // Do nothing. return //--from func signalM(mp *m, sig int) { tgkill(getpid(), int(mp.procid), sig) } //--to func signalM(mp *m, sig int) { // Do nothiing. } //--from func runPerThreadSyscall() { gp := getg() if gp.m.needPerThreadSyscall.Load() == 0 { return } args := perThreadSyscall r1, r2, errno := syscall.Syscall6(args.trap, args.a1, args.a2, args.a3, args.a4, args.a5, args.a6) if GOARCH == "ppc64" || GOARCH == "ppc64le" { // TODO(https://go.dev/issue/51192 ): ppc64 doesn't use r2. r2 = 0 } if errno != 0 || r1 != args.r1 || r2 != args.r2 { print("trap:", args.trap, ", a123456=[", args.a1, ",", args.a2, ",", args.a3, ",", args.a4, ",", args.a5, ",", args.a6, "]\n") print("results: got {r1=", r1, ",r2=", r2, ",errno=", errno, "}, want {r1=", args.r1, ",r2=", args.r2, ",errno=0}\n") fatal("AllThreadsSyscall6 results differ between threads; runtime corrupted") } gp.m.needPerThreadSyscall.Store(0) } //--to func runPerThreadSyscall() { // Do nothing. // needPerThreadSyscall should never be 1 as syscall_runtime_doAllThreadsSyscall is not available with Cgo. } //--append //go:linkname hitsumabushi_closefd hitsumabushi_closefd //go:cgo_import_static hitsumabushi_closefd var hitsumabushi_closefd byte //go:linkname hitsumabushi_exit hitsumabushi_exit //go:cgo_import_static hitsumabushi_exit var hitsumabushi_exit byte //go:linkname hitsumabushi_gettid hitsumabushi_gettid //go:cgo_import_static hitsumabushi_gettid var hitsumabushi_gettid byte //go:linkname hitsumabushi_nanotime1 hitsumabushi_nanotime1 //go:cgo_import_static hitsumabushi_nanotime1 var hitsumabushi_nanotime1 byte //go:linkname hitsumabushi_open hitsumabushi_open //go:cgo_import_static hitsumabushi_open var hitsumabushi_open byte //go:linkname hitsumabushi_osyield hitsumabushi_osyield //go:cgo_import_static hitsumabushi_osyield var hitsumabushi_osyield byte //go:linkname hitsumabushi_read hitsumabushi_read //go:cgo_import_static hitsumabushi_read var hitsumabushi_read byte //go:linkname hitsumabushi_sched_getaffinity hitsumabushi_sched_getaffinity //go:cgo_import_static hitsumabushi_sched_getaffinity var hitsumabushi_sched_getaffinity byte //go:linkname hitsumabushi_usleep hitsumabushi_usleep //go:cgo_import_static hitsumabushi_usleep var hitsumabushi_usleep byte //go:linkname hitsumabushi_walltime1 hitsumabushi_walltime1 //go:cgo_import_static hitsumabushi_walltime1 var hitsumabushi_walltime1 byte //go:linkname hitsumabushi_write1 hitsumabushi_write1 //go:cgo_import_static hitsumabushi_write1 var hitsumabushi_write1 byte //go:nosplit //go:cgo_unsafe_args func fcntl1(fd, cmd, arg int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fcntl_trampoline)), unsafe.Pointer(&fd)) } func fcntl_trampoline() //go:nosplit //go:cgo_unsafe_args func fstat1(fd int, stat unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstat_trampoline)), unsafe.Pointer(&fd)) } func fstat_trampoline(fd int, stat unsafe.Pointer) int32 //go:nosplit //go:cgo_unsafe_args func lseek1(fd int, offset int64, whence int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(lseek_trampoline)), unsafe.Pointer(&fd)) } func lseek_trampoline() //go:nosplit //go:cgo_unsafe_args func renameat(fd1 int, name1 unsafe.Pointer, fd2 int, name2 unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(renameat_trampoline)), unsafe.Pointer(&fd1)) } func renameat_trampoline() //go:nosplit //go:cgo_unsafe_args func fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstatat_trampoline)), unsafe.Pointer(&fd)) } func fstatat_trampoline() ================================================ FILE: 1.20_linux/runtime/proc_test.go.patch ================================================ //--from func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) testGoroutineParallelism2(t, false, true) testGoroutineParallelism2(t, true, true) } //--to func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) //testGoroutineParallelism2(t, false, true) //testGoroutineParallelism2(t, true, true) } ================================================ FILE: 1.20_linux/runtime/runtime1.go.patch ================================================ //--from func argv_index(argv **byte, i int32) *byte { return *(**byte)(add(unsafe.Pointer(argv), uintptr(i)*goarch.PtrSize)) } //--to func argv_index(argv **byte, i int32) *byte { return nil } //--from func args(c int32, v **byte) { argc = c argv = v sysargs(c, v) } //--to func args(c int32, v **byte) { // In the original code, physPageSize is determined at sysargs. // Hitsumabushi gives an initial value for physPageSize at its declaration, so sysargs doesn't have to be called. } //--append // Expose the entry point for some special environments. //go:cgo_export_static _rt0_amd64_linux_lib //go:cgo_export_dynamic _rt0_amd64_linux_lib ================================================ FILE: 1.20_linux/runtime/runtime_linux_test.go.patch ================================================ //--from func TestMincoreErrorSign(t *testing.T) { var dst byte v := Mincore(Add(unsafe.Pointer(new(int32)), 1), 1, &dst) const EINVAL = 0x16 if v != -EINVAL { t.Errorf("mincore = %v, want %v", v, -EINVAL) } } //--to func TestMincoreErrorSign(t *testing.T) { t.Skip("mincore is not supported in this environment") } ================================================ FILE: 1.20_linux/runtime/runtime_mmap_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.20_linux/runtime/runtime_test.go.patch ================================================ //--from func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { if GOOS == "js" { t.Skip("js does not support catching faults") } defer func() { if err := recover(); err != nil { *nfault++ } }() // The read should fault, except that sometimes we hit // addresses that have had C or kernel pages mapped there // readable by user code. So just log the content. // If no addresses fault, we'll fail the test. v := *(*byte)(unsafe.Pointer(addr)) t.Logf("addr %#x: %#x\n", addr, v) } //--to func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { t.Skip("catching faults is not supported in this environment") } ================================================ FILE: 1.20_linux/runtime/runtime_unix_test.go.patch ================================================ //--from //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || plan9 //--to //go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || plan9 ================================================ FILE: 1.20_linux/runtime/stack_test.go.patch ================================================ //--from func TestDeferLeafSigpanic(t *testing.T) { // Push a defer that will walk the stack. defer func() { if err := recover(); err == nil { t.Fatal("expected panic from nil pointer") } GC() }() // Call a leaf function. We must set up the exact call stack: // // defering function -> leaf function -> sigpanic // // On LR machines, the leaf function will have the same SP as // the SP pushed for the defer frame. testDeferLeafSigpanic1() } //--to func TestDeferLeafSigpanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } //--from func TestStackWrapperStackPanic(t *testing.T) { t.Run("sigpanic", func(t *testing.T) { // nil calls to interface methods cause a sigpanic. testStackWrapperPanic(t, func() { I.M(nil) }, "runtime_test.I.M") }) t.Run("panicwrap", func(t *testing.T) { // Nil calls to value method wrappers call panicwrap. wrapper := (*structWithMethod).nop testStackWrapperPanic(t, func() { wrapper(nil) }, "runtime_test.(*structWithMethod).nop") }) } //--to func TestStackWrapperStackPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } //--from func TestTracebackInlineExcluded(t *testing.T) { defer func() { recover() buf := make([]byte, 4<<10) stk := string(buf[:Stack(buf, false)]) t.Log(stk) if not := "tracebackExcluded"; strings.Contains(stk, not) { t.Errorf("found but did not expect %q", not) } if want := "tracebackNotExcluded"; !strings.Contains(stk, want) { t.Errorf("expected %q in stack", want) } }() tracebackExcluded() } //--to func TestTracebackInlineExcluded(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } ================================================ FILE: 1.20_linux/runtime/stubs2.go.patch ================================================ //--from import ( "runtime/internal/atomic" "unsafe" ) //--to import ( "internal/abi" "runtime/internal/atomic" "unsafe" ) //--from func read(fd int32, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func read(fd int32, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(read_trampoline)), unsafe.Pointer(&fd)) } func read_trampoline(fd int32, p unsafe.Pointer, n int32) int32 //--from func closefd(fd int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func closefd(fd int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(closefd_trampoline)), unsafe.Pointer(&fd)) } func closefd_trampoline(fd int32) int32 //--from func exit(code int32) //--to //go:nosplit //go:cgo_unsafe_args func exit(code int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(exit_trampoline)), unsafe.Pointer(&code)) } func exit_trampoline(code int32) //--from func usleep(usec uint32) //--to //go:nosplit //go:cgo_unsafe_args func usleep(usec uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } func usleep_trampoline(usec uint32) //--from //go:nosplit func usleep_no_g(usec uint32) { usleep(usec) } //--to //go:nosplit //go:cgo_unsafe_args func usleep_no_g(usec uint32) { asmcgocall_no_g(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } //--from //go:noescape func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func write1(fd uintptr, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(write1_trampoline)), unsafe.Pointer(&fd)) } func write1_trampoline(fd uintptr, p unsafe.Pointer, n int32) int32 //--from //go:noescape func open(name *byte, mode, perm int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func open(name *byte, mode, perm int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(open_trampoline)), unsafe.Pointer(&name)) } func open_trampoline(name *byte, mode, perm int32) int32 ================================================ FILE: 1.20_linux/runtime/stubs3.go.patch ================================================ //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func nanotime1() int64 //--to //go:nosplit //go:cgo_unsafe_args func nanotime1() (now int64) { libcCall(unsafe.Pointer(abi.FuncPCABI0(nanotime1_trampoline)), unsafe.Pointer(&now)) return } func nanotime1_trampoline() int64 ================================================ FILE: 1.20_linux/runtime/sys_libc.go.patch ================================================ //--from //go:build darwin || (openbsd && !mips64) //--to //go:build darwin || (openbsd && !mips64) || linux ================================================ FILE: 1.20_linux/runtime/sys_linux_amd64.s.patch ================================================ //--from TEXT runtime·open(SB),NOSPLIT,$0-20 // This uses openat instead of open, because Android O blocks open. MOVL $AT_FDCWD, DI // AT_FDCWD, so this acts like open MOVQ name+0(FP), SI MOVL mode+8(FP), DX MOVL perm+12(FP), R10 MOVL $SYS_openat, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVL 8(DI), SI // arg 2 flags MOVL 12(DI), DX // arg 3 mode MOVQ 0(DI), DI // arg 1 pathname XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_open(SB) MOVQ AX, 16(BX) POPQ BP RET //--from TEXT runtime·futex(SB),NOSPLIT,$0 MOVQ addr+0(FP), DI MOVL op+8(FP), SI MOVL val+12(FP), DX MOVQ ts+16(FP), R10 MOVQ addr2+24(FP), R8 MOVL val3+32(FP), R9 MOVL $SYS_futex, AX SYSCALL MOVL AX, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 addr MOVL 8(BX), SI // arg 2 op MOVL 12(BX), DX // arg 3 val MOVQ 16(BX), CX // arg 4 ts MOVQ 24(BX), R8 // arg 5 addr2 MOVL 32(BX), R9 // arg 6 val3 CALL hitsumabushi_futex(SB) MOVL AX, 40(BX) POPQ BP RET //--from TEXT runtime·exit(SB),NOSPLIT,$0-4 MOVL code+0(FP), DI MOVL $SYS_exit_group, AX SYSCALL RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 exit status CALL hitsumabushi_exit(SB) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·read(SB),NOSPLIT,$0-28 MOVL fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_read, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 0(BX), DI // arg 1 fd MOVQ 8(BX), SI // arg 2 buf MOVQ 16(BX), DX // arg 3 count CALL hitsumabushi_read(SB) MOVQ AX, 24(BX) // return value POPQ BP RET //--from TEXT runtime·closefd(SB),NOSPLIT,$0-12 MOVL fd+0(FP), DI MOVL $SYS_close, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 fd CALL hitsumabushi_closefd(SB) POPQ BP RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVL $SYS_gettid, AX SYSCALL MOVL AX, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_gettid(SB) POPQ BP RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT,$-8 MOVQ new+0(FP), DI MOVQ old+8(FP), SI MOVQ $SYS_sigaltstack, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $0xf1, 0xf1 // crash RET //--to TEXT runtime·sigaltstack_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 old MOVQ 0(DI), DI // arg 1 new CALL hitsumabushi_sigaltstack(SB) TESTQ AX, AX JEQ 2(PC) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·raise(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, R12 MOVL $SYS_gettid, AX SYSCALL MOVL AX, SI // arg 2 tid MOVL R12, DI // arg 1 pid MOVL sig+0(FP), DX // arg 3 MOVL $SYS_tgkill, AX SYSCALL RET //--to TEXT runtime·raise_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 signal CALL hitsumabushi_raise(SB) POPQ BP RET //--from TEXT runtime·raiseproc(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, DI // arg 1 pid MOVL sig+0(FP), SI // arg 2 MOVL $SYS_kill, AX SYSCALL RET //--to TEXT runtime·raiseproc_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), BX // signal CALL hitsumabushi_getpid(SB) MOVL AX, DI // arg 1 pid MOVL BX, SI // arg 2 signal CALL hitsumabushi_kill(SB) POPQ BP RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0 MOVQ pid+0(FP), DI MOVQ len+8(FP), SI MOVQ buf+16(FP), DX MOVL $SYS_sched_getaffinity, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 len MOVQ 16(DI), DX // arg 3 buf MOVQ 0(DI), DI // arg 1 pid CALL hitsumabushi_sched_getaffinity(SB) POPQ BP RET //--from TEXT runtime·osyield(SB),NOSPLIT,$0 MOVL $SYS_sched_yield, AX SYSCALL RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_osyield(SB) POPQ BP RET //--from TEXT runtime·usleep(SB),NOSPLIT,$16 MOVL $0, DX MOVL usec+0(FP), AX MOVL $1000000, CX DIVL CX MOVQ AX, 0(SP) MOVL $1000, AX // usec to nsec MULL DX MOVQ AX, 8(SP) // nanosleep(&ts, 0) MOVQ SP, DI MOVL $0, SI MOVL $SYS_nanosleep, AX SYSCALL RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 usec CALL hitsumabushi_usleep(SB) POPQ BP RET //--from TEXT runtime·write1(SB),NOSPLIT,$0-28 MOVQ fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_write, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 p MOVQ 16(DI), DX // arg 3 n MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_write1(SB) POPQ BP RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$16-8 // We don't know how much stack space the VDSO code will need, // so switch to g0. // In particular, a kernel configured with CONFIG_OPTIMIZE_INLINING=n // and hardening can use a full page of stack space in gettime_sym // due to stack probes inserted to avoid stack/heap collisions. // See issue #20427. MOVQ SP, R12 // Save old SP; R12 unchanged by C code. MOVQ g_m(R14), BX // BX unchanged by C code. // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVQ m_vdsoPC(BX), CX MOVQ m_vdsoSP(BX), DX MOVQ CX, 0(SP) MOVQ DX, 8(SP) LEAQ ret+0(FP), DX MOVQ -8(DX), CX MOVQ CX, m_vdsoPC(BX) MOVQ DX, m_vdsoSP(BX) CMPQ R14, m_curg(BX) // Only switch if on curg. JNE noswitch MOVQ m_g0(BX), DX MOVQ (g_sched+gobuf_sp)(DX), SP // Set SP to g0 stack noswitch: SUBQ $16, SP // Space for results ANDQ $~15, SP // Align for C code MOVL $1, DI // CLOCK_MONOTONIC LEAQ 0(SP), SI MOVQ runtime·vdsoClockgettimeSym(SB), AX CMPQ AX, $0 JEQ fallback CALL AX ret: MOVQ 0(SP), AX // sec MOVQ 8(SP), DX // nsec MOVQ R12, SP // Restore real SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVQ 8(SP), CX MOVQ CX, m_vdsoSP(BX) MOVQ 0(SP), CX MOVQ CX, m_vdsoPC(BX) // sec is in AX, nsec in DX // return nsec in AX IMULQ $1000000000, AX ADDQ DX, AX MOVQ AX, ret+0(FP) RET fallback: MOVQ $SYS_clock_gettime, AX SYSCALL JMP ret //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ DI, BX // BX is callee-saved MOVQ SP, BP CALL hitsumabushi_nanotime1(SB) MOVQ AX, 0(BX) POPQ BP RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(DI), DI CALL hitsumabushi_sysAllocOS(SB) MOVQ AX, 8(BX) POPQ BP RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUnusedOS(SB) POPQ BP RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUsedOS(SB) POPQ BP RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysHugePageOS(SB) POPQ BP RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFreeOS(SB) POPQ BP RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFaultOS(SB) POPQ BP RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysReserveOS(SB) MOVQ AX, 16(BX) POPQ BP RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysMapOS(SB) POPQ BP RET TEXT runtime·walltime1_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_walltime1(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 cmd MOVQ 16(DI), DX // arg 3 arg MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_fcntl(SB) POPQ BP RET TEXT runtime·fstat_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 stat MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_fstat(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·lseek_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 offset MOVQ 16(DI), DX // arg 3 whence MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_lseek(SB) MOVQ AX, 24(BX) // return value POPQ BP RET TEXT runtime·renameat_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_renameat(SB) MOVL AX, 32(BX) POPQ BP RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_fstatat(SB) MOVL AX, 32(BX) POPQ BP RET ================================================ FILE: 1.20_linux/runtime/sys_linux_arm64.s.patch ================================================ //--from #define SYS_exit 93 #define SYS_read 63 #define SYS_write 64 #define SYS_openat 56 #define SYS_close 57 #define SYS_pipe2 59 #define SYS_nanosleep 101 #define SYS_mmap 222 #define SYS_munmap 215 #define SYS_setitimer 103 #define SYS_clone 220 #define SYS_sched_yield 124 #define SYS_rt_sigreturn 139 #define SYS_rt_sigaction 134 #define SYS_rt_sigprocmask 135 #define SYS_sigaltstack 132 #define SYS_madvise 233 #define SYS_mincore 232 #define SYS_getpid 172 #define SYS_gettid 178 #define SYS_kill 129 #define SYS_tgkill 131 #define SYS_futex 98 #define SYS_sched_getaffinity 123 #define SYS_exit_group 94 #define SYS_clock_gettime 113 #define SYS_faccessat 48 #define SYS_socket 198 #define SYS_connect 203 #define SYS_brk 214 #define SYS_timer_create 107 #define SYS_timer_settime 110 #define SYS_timer_delete 111 //--to #define SYS_exit 2147483647 #define SYS_read 2147483647 #define SYS_write 2147483647 #define SYS_openat 2147483647 #define SYS_close 2147483647 #define SYS_pipe2 2147483647 #define SYS_nanosleep 2147483647 #define SYS_mmap 2147483647 #define SYS_munmap 2147483647 #define SYS_setitimer 2147483647 #define SYS_clone 2147483647 #define SYS_sched_yield 2147483647 #define SYS_rt_sigreturn 2147483647 #define SYS_rt_sigaction 2147483647 #define SYS_rt_sigprocmask 2147483647 #define SYS_sigaltstack 2147483647 #define SYS_madvise 2147483647 #define SYS_mincore 2147483647 #define SYS_getpid 2147483647 #define SYS_gettid 2147483647 #define SYS_kill 2147483647 #define SYS_tgkill 2147483647 #define SYS_futex 2147483647 #define SYS_sched_getaffinity 2147483647 #define SYS_exit_group 2147483647 #define SYS_clock_gettime 2147483647 #define SYS_faccessat 2147483647 #define SYS_socket 2147483647 #define SYS_connect 2147483647 #define SYS_brk 2147483647 #define SYS_timer_create 2147483647 #define SYS_timer_settime 2147483647 #define SYS_timer_delete 2147483647 //--from TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0-4 MOVW code+0(FP), R0 MOVD $SYS_exit_group, R8 SVC RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_exit(SB) RET //--from TEXT runtime·open(SB),NOSPLIT|NOFRAME,$0-20 MOVD $AT_FDCWD, R0 MOVD name+0(FP), R1 MOVW mode+8(FP), R2 MOVW perm+12(FP), R3 MOVD $SYS_openat, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_open(SB) RET //--from TEXT runtime·closefd(SB),NOSPLIT|NOFRAME,$0-12 MOVW fd+0(FP), R0 MOVD $SYS_close, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT,$0-12 MOVW 0(R0), R0 BL hitsumabushi_closefd(SB) RET //--from TEXT runtime·write1(SB),NOSPLIT|NOFRAME,$0-28 MOVD fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_write, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_write1(SB) RET //--from TEXT runtime·read(SB),NOSPLIT|NOFRAME,$0-28 MOVW fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_read, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_read(SB) RET //--from TEXT runtime·usleep(SB),NOSPLIT,$24-4 MOVWU usec+0(FP), R3 MOVD R3, R5 MOVW $1000000, R4 UDIV R4, R3 MOVD R3, 8(RSP) MUL R3, R4 SUB R4, R5 MOVW $1000, R4 MUL R4, R5 MOVD R5, 16(RSP) // nanosleep(&ts, 0) ADD $8, RSP, R0 MOVD $0, R1 MOVD $SYS_nanosleep, R8 SVC RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_usleep(SB) RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVD $SYS_gettid, R8 SVC MOVW R0, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_gettid(SB) MOVW R0, 0(R19) // return value RET //--from TEXT runtime·raise(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R19 MOVD $SYS_gettid, R8 SVC MOVW R0, R1 // arg 2 tid MOVW R19, R0 // arg 1 pid MOVW sig+0(FP), R2 // arg 3 MOVD $SYS_tgkill, R8 SVC RET //--to //--from TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R0 // arg 1 pid MOVW sig+0(FP), R1 // arg 2 MOVD $SYS_kill, R8 SVC RET //--to //--from TEXT runtime·walltime(SB),NOSPLIT,$24-12 MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $16, R1 BIC $15, R1 // Align for C code MOVD R1, RSP MOVW $CLOCK_REALTIME, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) MOVD R3, sec+0(FP) MOVW R5, nsec+8(FP) RET //--to TEXT runtime·walltime1_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_walltime1(SB) RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$24-8 MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $32, R1 BIC $15, R1 MOVD R1, RSP MOVW $CLOCK_MONOTONIC, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) // sec is in R3, nsec in R5 // return nsec in R3 MOVD $1000000000, R4 MUL R4, R3 ADD R5, R3 MOVD R3, ret+0(FP) RET //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_nanotime1(SB) MOVD R0, 0(R19) // return value RET //--from TEXT runtime·futex(SB),NOSPLIT|NOFRAME,$0 MOVD addr+0(FP), R0 MOVW op+8(FP), R1 MOVW val+12(FP), R2 MOVD ts+16(FP), R3 MOVD addr2+24(FP), R4 MOVW val3+32(FP), R5 MOVD $SYS_futex, R8 SVC MOVW R0, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 16(R0), R3 MOVD 24(R0), R4 MOVW 32(R0), R5 MOVD 0(R0), R0 BL hitsumabushi_futex(SB) RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT|NOFRAME,$0 MOVD new+0(FP), R0 MOVD old+8(FP), R1 MOVD $SYS_sigaltstack, R8 SVC CMN $4095, R0 BCC ok MOVD $0, R0 MOVD R0, (R0) // crash ok: RET //--to //--from TEXT runtime·osyield(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_sched_yield, R8 SVC RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT,$0 BL hitsumabushi_osyield(SB) RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT|NOFRAME,$0 MOVD pid+0(FP), R0 MOVD len+8(FP), R1 MOVD buf+16(FP), R2 MOVD $SYS_sched_getaffinity, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVD 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_sched_getaffinity(SB) RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 0(R0), R0 BL hitsumabushi_sysAllocOS(SB) MOVD R0, 8(R19) // return value RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUnusedOS(SB) RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUsedOS(SB) RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysHugePageOS(SB) RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFreeOS(SB) RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFaultOS(SB) RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysReserveOS(SB) MOVD R0, 16(R19) // return value RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysMapOS(SB) RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVW 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_fcntl(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·fstat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 0(R0), R0 BL hitsumabushi_fstat(SB) MOVW R0, 16(R19) // return value RET TEXT runtime·lseek_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_lseek(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·renameat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_renameat(SB) MOVW R0, 32(R19) // return value RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_fstatat(SB) MOVW R0, 32(R19) // return value RET ================================================ FILE: 1.20_linux/runtime/time_linux_amd64.s.patch ================================================ //--from //go:build !faketime //--to //go:build ignore ================================================ FILE: 1.20_linux/runtime/timeasm.go.patch ================================================ //--from //go:build !faketime && (windows || (linux && amd64)) //--to //go:build !faketime && windows ================================================ FILE: 1.20_linux/runtime/timestub.go.patch ================================================ //--from //go:build !faketime && !windows && !(linux && amd64) //--to //go:build !faketime && !windows ================================================ FILE: 1.20_linux/runtime/timestub2.go.patch ================================================ //--from //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !windows && !(linux && amd64) //--to //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !windows //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func walltime() (sec int64, nsec int32) //--to func walltime() (sec int64, nsec int32) { walltime1(&sec, &nsec) return } //go:nosplit //go:cgo_unsafe_args func walltime1(sec *int64, nsec *int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(walltime1_trampoline)), unsafe.Pointer(&sec)) } func walltime1_trampoline(sec *int64, nsec *int32) ================================================ FILE: 1.20_linux/strconv/fp_test.go.patch ================================================ //--from import ( "bufio" "fmt" "os" "strconv" "strings" "testing" ) //--to import ( "strconv" "strings" "testing" ) //--from func TestFp(t *testing.T) { f, err := os.Open("testdata/testfp.txt") if err != nil { t.Fatal("testfp: open testdata/testfp.txt:", err) } defer f.Close() s := bufio.NewScanner(f) for lineno := 1; s.Scan(); lineno++ { line := s.Text() if len(line) == 0 || line[0] == '#' { continue } a := strings.Split(line, " ") if len(a) != 4 { t.Error("testdata/testfp.txt:", lineno, ": wrong field count") continue } var s string var v float64 switch a[0] { case "float64": var ok bool v, ok = myatof64(a[2]) if !ok { t.Error("testdata/testfp.txt:", lineno, ": cannot atof64 ", a[2]) continue } s = fmt.Sprintf(a[1], v) case "float32": v1, ok := myatof32(a[2]) if !ok { t.Error("testdata/testfp.txt:", lineno, ": cannot atof32 ", a[2]) continue } s = fmt.Sprintf(a[1], v1) v = float64(v1) } if s != a[3] { t.Error("testdata/testfp.txt:", lineno, ": ", a[0], " ", a[1], " ", a[2], " (", v, ") ", "want ", a[3], " got ", s) } } if s.Err() != nil { t.Fatal("testfp: read testdata/testfp.txt: ", s.Err()) } } //--to func TestFp(t *testing.T) { t.Skip("file is not supported in this environment") } ================================================ FILE: 1.20_linux/sync/atomic/atomic_test.go.patch ================================================ //--from func TestStoreLoadSeqCst32(t *testing.T) { if runtime.NumCPU() == 1 { t.Skipf("Skipping test on %v processor machine", runtime.NumCPU()) } defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4)) N := int32(1e3) if testing.Short() { N = int32(1e2) } c := make(chan bool, 2) X := [2]int32{} ack := [2][3]int32{{-1, -1, -1}, {-1, -1, -1}} for p := 0; p < 2; p++ { go func(me int) { he := 1 - me for i := int32(1); i < N; i++ { StoreInt32(&X[me], i) my := LoadInt32(&X[he]) StoreInt32(&ack[me][i%3], my) for w := 1; LoadInt32(&ack[he][i%3]) == -1; w++ { if w%1000 == 0 { runtime.Gosched() } } his := LoadInt32(&ack[he][i%3]) if (my != i && my != i-1) || (his != i && his != i-1) { t.Errorf("invalid values: %d/%d (%d)", my, his, i) break } if my != i && his != i { t.Errorf("store/load are not sequentially consistent: %d/%d (%d)", my, his, i) break } StoreInt32(&ack[me][(i-1)%3], -1) } c <- true }(p) } <-c <-c } //--to func TestStoreLoadSeqCst32(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") } //--from func TestStoreLoadSeqCst64(t *testing.T) { if runtime.NumCPU() == 1 { t.Skipf("Skipping test on %v processor machine", runtime.NumCPU()) } defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(4)) N := int64(1e3) if testing.Short() { N = int64(1e2) } c := make(chan bool, 2) X := [2]int64{} ack := [2][3]int64{{-1, -1, -1}, {-1, -1, -1}} for p := 0; p < 2; p++ { go func(me int) { he := 1 - me for i := int64(1); i < N; i++ { StoreInt64(&X[me], i) my := LoadInt64(&X[he]) StoreInt64(&ack[me][i%3], my) for w := 1; LoadInt64(&ack[he][i%3]) == -1; w++ { if w%1000 == 0 { runtime.Gosched() } } his := LoadInt64(&ack[he][i%3]) if (my != i && my != i-1) || (his != i && his != i-1) { t.Errorf("invalid values: %d/%d (%d)", my, his, i) break } if my != i && his != i { t.Errorf("store/load are not sequentially consistent: %d/%d (%d)", my, his, i) break } StoreInt64(&ack[me][(i-1)%3], -1) } c <- true }(p) } <-c <-c } //--to func TestStoreLoadSeqCst64(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") } //--from func TestNilDeref(t *testing.T) { funcs := [...]func(){ func() { CompareAndSwapInt32(nil, 0, 0) }, func() { (*Int32)(nil).CompareAndSwap(0, 0) }, func() { CompareAndSwapInt64(nil, 0, 0) }, func() { (*Int64)(nil).CompareAndSwap(0, 0) }, func() { CompareAndSwapUint32(nil, 0, 0) }, func() { (*Uint32)(nil).CompareAndSwap(0, 0) }, func() { CompareAndSwapUint64(nil, 0, 0) }, func() { (*Uint64)(nil).CompareAndSwap(0, 0) }, func() { CompareAndSwapUintptr(nil, 0, 0) }, func() { (*Uintptr)(nil).CompareAndSwap(0, 0) }, func() { CompareAndSwapPointer(nil, nil, nil) }, func() { (*Pointer[byte])(nil).CompareAndSwap(nil, nil) }, func() { SwapInt32(nil, 0) }, func() { (*Int32)(nil).Swap(0) }, func() { SwapUint32(nil, 0) }, func() { (*Uint32)(nil).Swap(0) }, func() { SwapInt64(nil, 0) }, func() { (*Int64)(nil).Swap(0) }, func() { SwapUint64(nil, 0) }, func() { (*Uint64)(nil).Swap(0) }, func() { SwapUintptr(nil, 0) }, func() { (*Uintptr)(nil).Swap(0) }, func() { SwapPointer(nil, nil) }, func() { (*Pointer[byte])(nil).Swap(nil) }, func() { AddInt32(nil, 0) }, func() { (*Int32)(nil).Add(0) }, func() { AddUint32(nil, 0) }, func() { (*Uint32)(nil).Add(0) }, func() { AddInt64(nil, 0) }, func() { (*Int64)(nil).Add(0) }, func() { AddUint64(nil, 0) }, func() { (*Uint64)(nil).Add(0) }, func() { AddUintptr(nil, 0) }, func() { (*Uintptr)(nil).Add(0) }, func() { LoadInt32(nil) }, func() { (*Int32)(nil).Load() }, func() { LoadInt64(nil) }, func() { (*Int64)(nil).Load() }, func() { LoadUint32(nil) }, func() { (*Uint32)(nil).Load() }, func() { LoadUint64(nil) }, func() { (*Uint64)(nil).Load() }, func() { LoadUintptr(nil) }, func() { (*Uintptr)(nil).Load() }, func() { LoadPointer(nil) }, func() { (*Pointer[byte])(nil).Load() }, func() { StoreInt32(nil, 0) }, func() { (*Int32)(nil).Store(0) }, func() { StoreInt64(nil, 0) }, func() { (*Int64)(nil).Store(0) }, func() { StoreUint32(nil, 0) }, func() { (*Uint32)(nil).Store(0) }, func() { StoreUint64(nil, 0) }, func() { (*Uint64)(nil).Store(0) }, func() { StoreUintptr(nil, 0) }, func() { (*Uintptr)(nil).Store(0) }, func() { StorePointer(nil, nil) }, func() { (*Pointer[byte])(nil).Store(nil) }, } for _, f := range funcs { func() { defer func() { runtime.GC() recover() }() f() }() } } //--to func TestNilDeref(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } ================================================ FILE: 1.20_linux/syscall/hitsumabushi_stubs_linux_amd64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_FSTATAT = 0xffffffffffffffff // Stub: on amd64 Go uses SYS_NEWFSTATAT instead ) ================================================ FILE: 1.20_linux/syscall/hitsumabushi_stubs_linux_arm64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_NEWFSTATAT = 0xffffffffffffffff // Stub: on arm64 Go uses SYS_FSTATAT instead ) ================================================ FILE: 1.20_linux/syscall/rlimit.go.patch ================================================ //--from func init() { var lim Rlimit if err := Getrlimit(RLIMIT_NOFILE, &lim); err == nil && lim.Cur != lim.Max { origRlimitNofile.Store(lim) lim.Cur = lim.Max adjustFileLimit(&lim) setrlimit(RLIMIT_NOFILE, &lim) } } //--to func init() { } ================================================ FILE: 1.20_linux/syscall/syscall_linux.go.patch ================================================ //--from func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { return RawSyscall6(trap, a1, a2, a3, 0, 0, 0) } //--to func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { println("not implemented syscall at RawSyscall", trap) panic("syscall.RawSyscall") return 0, 0, ENOSYS } //--from func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() // N.B. Calling RawSyscall here is unsafe with atomic coverage // instrumentation and race mode. // // Coverage instrumentation will add a sync/atomic call to RawSyscall. // Race mode will add race instrumentation to sync/atomic. Race // instrumentation requires a P, which we no longer have. // // RawSyscall6 is fine because it is implemented in assembly and thus // has no coverage instrumentation. // // This is typically not a problem in the runtime because cmd/go avoids // adding coverage instrumentation to the runtime in race mode. r1, r2, err = RawSyscall6(trap, a1, a2, a3, 0, 0, 0) runtime_exitsyscall() return } //--to func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FCNTL: r = fcntl1(a1, a2, a3) case SYS_FSTAT: r = fstat1(a1, unsafe.Pointer(a2)) case SYS_READ: r = runtime_read(uintptr(a1), unsafe.Pointer(a2), int32(a3)) case SYS_WRITE: r = write1(a1, unsafe.Pointer(a2), int32(a3)) case SYS_LSEEK: r = lseek1(a1, int64(a2), int32(a3)) case SYS_CLOSE: r = runtime_closefd(int32(a1)) case SYS_MKDIRAT: println("syscall mkdirat() is not implemented") // Default to permission denied. TODO: implement this return 0, 0, EPERM case SYS_GETDENTS64: println("syscall getdents64() is not implemented") // Default to empty directory. TODO: implement this return 0, 0, 0 default: println("unimplemented syscall at runtime.Syscall", trap) panic("syscall.Syscall") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //go:linkname open runtime.open func open(name *byte, mode, perm int32) int32 //go:linkname write1 runtime.write1 func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname fcntl1 runtime.fcntl1 func fcntl1(fd uintptr, a uintptr, b uintptr) int32 //go:linkname fstat1 runtime.fstat1 func fstat1(fd uintptr, p unsafe.Pointer) int32 //go:linkname lseek1 runtime.lseek1 func lseek1(fd uintptr, offset int64, whence int32) int32 //go:linkname runtime_read runtime.read func runtime_read(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname runtime_closefd runtime.closefd func runtime_closefd(fd int32) int32 //go:linkname runtime_fstatat runtime.fstatat func runtime_fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 //go:linkname runtime_renameat runtime.renameat func runtime_renameat(fd1 uintptr, name1 unsafe.Pointer, fd2 uintptr, name2 unsafe.Pointer) int32 //--from func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() r1, r2, err = RawSyscall6(trap, a1, a2, a3, a4, a5, a6) runtime_exitsyscall() return } //--to func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FSTATAT, SYS_NEWFSTATAT: r = runtime_fstatat(uintptr(a1), unsafe.Pointer(a2), unsafe.Pointer(a3), int32(a4)) case SYS_RENAMEAT: r = runtime_renameat(uintptr(a1), unsafe.Pointer(a2), uintptr(a3), unsafe.Pointer(a4)) default: println("unimplemented syscall at runtime.Syscall6", trap) panic("syscall.Syscall6") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //--from func Open(path string, mode int, perm uint32) (fd int, err error) { return openat(_AT_FDCWD, path, mode|O_LARGEFILE, perm) } //--to func Open(path string, mode int, perm uint32) (fd int, err error) { p0, err := BytePtrFromString(path) if err != nil { return -1, errnoErr(EINVAL) } fd = int(open(p0, int32(mode|O_LARGEFILE), int32(perm))) if fd < 0 { return -1, errnoErr(ENOENT) } return } ================================================ FILE: 1.20_linux/testing/run_example.go ================================================ package testing func runExample(eg InternalExample) (ok bool) { // Do nothing. // TODO: Implement os.Pipe2 and use this here. return true } ================================================ FILE: 1.20_linux/time/format_test.go.patch ================================================ //--from func TestParseInLocation(t *testing.T) { baghdad, err := LoadLocation("Asia/Baghdad") if err != nil { t.Fatal(err) } var t1, t2 Time t1, err = ParseInLocation("Jan 02 2006 MST", "Feb 01 2013 AST", baghdad) if err != nil { t.Fatal(err) } _, offset := t1.Zone() // A zero offset means that ParseInLocation did not recognize the // 'AST' abbreviation as matching the current location (Baghdad, // where we'd expect a +03 hrs offset); likely because we're using // a recent tzdata release (2017a or newer). // If it happens, skip the Baghdad test. if offset != 0 { t2 = Date(2013, February, 1, 00, 00, 00, 0, baghdad) if t1 != t2 { t.Fatalf("ParseInLocation(Feb 01 2013 AST, Baghdad) = %v, want %v", t1, t2) } if offset != 3*60*60 { t.Fatalf("ParseInLocation(Feb 01 2013 AST, Baghdad).Zone = _, %d, want _, %d", offset, 3*60*60) } } blancSablon, err := LoadLocation("America/Blanc-Sablon") if err != nil { t.Fatal(err) } // In this case 'AST' means 'Atlantic Standard Time', and we // expect the abbreviation to correctly match the american // location. t1, err = ParseInLocation("Jan 02 2006 MST", "Feb 01 2013 AST", blancSablon) if err != nil { t.Fatal(err) } t2 = Date(2013, February, 1, 00, 00, 00, 0, blancSablon) if t1 != t2 { t.Fatalf("ParseInLocation(Feb 01 2013 AST, Blanc-Sablon) = %v, want %v", t1, t2) } _, offset = t1.Zone() if offset != -4*60*60 { t.Fatalf("ParseInLocation(Feb 01 2013 AST, Blanc-Sablon).Zone = _, %d, want _, %d", offset, -4*60*60) } } //--to func TestParseInLocation(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestLoadLocationZipFile(t *testing.T) { undo := DisablePlatformSources() defer undo() _, err := LoadLocation("Australia/Sydney") if err != nil { t.Fatal(err) } } //--to func TestLoadLocationZipFile(t *testing.T) { t.Skip("location is not supported in this environment") } ================================================ FILE: 1.20_linux/time/internal_test.go.patch ================================================ //--from func initTestingZone() { // For hermeticity, use only tzinfo source from the test's GOROOT, // not the system sources and not whatever GOROOT may happen to be // set in the process's environment (if any). // This test runs in GOROOT/src/time, so GOROOT is "../..", // but it is theoretically possible sources := []string{"../../lib/time/zoneinfo.zip"} z, err := loadLocation("America/Los_Angeles", sources) if err != nil { panic("cannot load America/Los_Angeles for testing: " + err.Error() + "; you may want to use -tags=timetzdata") } z.name = "Local" localLoc = *z } //--to func initTestingZone() { // Data from the playground. // https://go.dev/play/p/VGXU57KZZ-x // name is replaced with "Local". // cachStart, cacheEnd, and cacheZone are removed. localLoc = Location{name:"Local",zone:[]zone{zone{name:"LMT", offset:-28378, isDST:false}, zone{name:"PDT", offset:-25200, isDST:true}, zone{name:"PST", offset:-28800, isDST:false}, zone{name:"PWT", offset:-25200, isDST:true}, zone{name:"PPT", offset:-25200, isDST:true}}, tx:[]zoneTrans{zoneTrans{when:-576460752303423488, index:0x0, isstd:false, isutc:false}, zoneTrans{when:-2717640000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1633269600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-1615129200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1601820000, index:0x1, isstd:true, isutc:true}, zoneTrans{when:-1583679600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-880207200, index:0x3, isstd:false, isutc:false}, zoneTrans{when:-769395600, index:0x4, isstd:false, isutc:false}, zoneTrans{when:-765385200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-687967140, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-662655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-620838000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-608137200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-589388400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-576082800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-557938800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-544633200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-526489200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-513183600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-495039600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-481734000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-463590000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-450284400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-431535600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-418230000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-400086000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-386780400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-368636400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-355330800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-337186800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-323881200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-305737200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-292431600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-273682800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-260982000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-242233200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-226508400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-210783600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-195058800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-179334000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-163609200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-147884400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-131554800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-116434800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-100105200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-84376800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-68655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-52927200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-37206000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-21477600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-5756400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:9972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:25693200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:41421600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:57747600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:73476000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:89197200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:104925600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:120646800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:126698400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:152096400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:162381600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:183546000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:199274400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:215600400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:230724000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:247050000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:262778400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:278499600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:294228000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:309949200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:325677600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:341398800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:357127200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:372848400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:388576800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:404902800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:420026400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:436352400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:452080800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:467802000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:483530400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:499251600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:514980000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:530701200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:544615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:562150800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:576064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:594205200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:607514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:625654800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:638964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:657104400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:671018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:688554000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:702468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:720003600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:733917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:752058000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:765367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:783507600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:796816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:814957200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:828871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:846406800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:860320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:877856400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:891770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:909306000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:923220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:941360400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:954669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:972810000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:986119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1004259600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1018173600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1035709200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1049623200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1067158800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1081072800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1099213200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1112522400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1130662800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1143972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1162112400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1173607200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1194166800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1205056800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1225616400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1236506400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1257066000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1268560800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1289120400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1300010400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1320570000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1331460000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1352019600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1362909600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1383469200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1394359200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1414918800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1425808800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1446368400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1457863200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1478422800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1489312800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1509872400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1520762400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1541322000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1552212000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1572771600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1583661600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1604221200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1615716000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1636275600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1647165600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1667725200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1678615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1699174800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1710064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1730624400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1741514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1762074000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1772964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1793523600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1805018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1825578000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1836468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1857027600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1867917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1888477200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1899367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1919926800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1930816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1951376400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1962871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1983430800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1994320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2014880400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2025770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2046330000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2057220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2077779600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2088669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2109229200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2120119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2140678800, index:0x2, isstd:false, isutc:false}}, extend:"PST8PDT,M3.2.0,M11.1.0"} } ================================================ FILE: 1.20_linux/time/sleep_test.go.patch ================================================ //--from func TestSleep(t *testing.T) { const delay = 100 * Millisecond go func() { Sleep(delay / 2) Interrupt() }() start := Now() Sleep(delay) delayadj := delay if runtime.GOOS == "windows" { delayadj -= windowsInaccuracy } duration := Now().Sub(start) if duration < delayadj { t.Fatalf("Sleep(%s) slept for only %s", delay, duration) } } //--to func TestSleep(t *testing.T) { t.Skip("Interrupt (syscall.Kill) is not supported in this environment") } //--from func TestIssue5745(t *testing.T) { ticker := NewTicker(Hour) defer func() { // would deadlock here before the fix due to // lock taken before the segfault. ticker.Stop() if r := recover(); r == nil { t.Error("Expected panic, but none happened.") } }() // cause a panic due to a segfault var timer *Timer timer.Stop() t.Error("Should be unreachable.") } //--to func TestIssue5745(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") } ================================================ FILE: 1.20_linux/time/time_test.go.patch ================================================ //--from func TestLoadFixed(t *testing.T) { // Issue 4064: handle locations without any zone transitions. loc, err := LoadLocation("Etc/GMT+1") if err != nil { t.Fatal(err) } // The tzdata name Etc/GMT+1 uses "east is negative", // but Go and most other systems use "east is positive". // So GMT+1 corresponds to -3600 in the Go zone, not +3600. name, offset := Now().In(loc).Zone() // The zone abbreviation is "-01" since tzdata-2016g, and "GMT+1" // on earlier versions; we accept both. (Issue #17276). if !(name == "GMT+1" || name == "-01") || offset != -1*60*60 { t.Errorf("Now().In(loc).Zone() = %q, %d, want %q or %q, %d", name, offset, "GMT+1", "-01", -1*60*60) } } //--to func TestLoadFixed(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestTimeIsDST(t *testing.T) { undo := DisablePlatformSources() defer undo() tzWithDST, err := LoadLocation("Australia/Sydney") if err != nil { t.Fatalf("could not load tz 'Australia/Sydney': %v", err) } tzWithoutDST, err := LoadLocation("Australia/Brisbane") if err != nil { t.Fatalf("could not load tz 'Australia/Brisbane': %v", err) } tzFixed := FixedZone("FIXED_TIME", 12345) tests := [...]struct { time Time want bool }{ 0: {Date(2009, 1, 1, 12, 0, 0, 0, UTC), false}, 1: {Date(2009, 6, 1, 12, 0, 0, 0, UTC), false}, 2: {Date(2009, 1, 1, 12, 0, 0, 0, tzWithDST), true}, 3: {Date(2009, 6, 1, 12, 0, 0, 0, tzWithDST), false}, 4: {Date(2009, 1, 1, 12, 0, 0, 0, tzWithoutDST), false}, 5: {Date(2009, 6, 1, 12, 0, 0, 0, tzWithoutDST), false}, 6: {Date(2009, 1, 1, 12, 0, 0, 0, tzFixed), false}, 7: {Date(2009, 6, 1, 12, 0, 0, 0, tzFixed), false}, } for i, tt := range tests { got := tt.time.IsDST() if got != tt.want { t.Errorf("#%d:: (%#v).IsDST()=%t, want %t", i, tt.time.Format(RFC3339), got, tt.want) } } } //--to func TestTimeIsDST(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestTimeWithZoneTransition(t *testing.T) { undo := DisablePlatformSources() defer undo() loc, err := LoadLocation("Asia/Shanghai") if err != nil { t.Fatal(err) } tests := [...]struct { give Time want Time }{ // 14 Apr 1991 - Daylight Saving Time Started // When time of "Asia/Shanghai" was about to reach // Sunday, 14 April 1991, 02:00:00 clocks were turned forward 1 hour to // Sunday, 14 April 1991, 03:00:00 local daylight time instead. // The UTC time was 13 April 1991, 18:00:00 0: {Date(1991, April, 13, 17, 50, 0, 0, loc), Date(1991, April, 13, 9, 50, 0, 0, UTC)}, 1: {Date(1991, April, 13, 18, 0, 0, 0, loc), Date(1991, April, 13, 10, 0, 0, 0, UTC)}, 2: {Date(1991, April, 14, 1, 50, 0, 0, loc), Date(1991, April, 13, 17, 50, 0, 0, UTC)}, 3: {Date(1991, April, 14, 3, 0, 0, 0, loc), Date(1991, April, 13, 18, 0, 0, 0, UTC)}, // 15 Sep 1991 - Daylight Saving Time Ended // When local daylight time of "Asia/Shanghai" was about to reach // Sunday, 15 September 1991, 02:00:00 clocks were turned backward 1 hour to // Sunday, 15 September 1991, 01:00:00 local standard time instead. // The UTC time was 14 September 1991, 17:00:00 4: {Date(1991, September, 14, 16, 50, 0, 0, loc), Date(1991, September, 14, 7, 50, 0, 0, UTC)}, 5: {Date(1991, September, 14, 17, 0, 0, 0, loc), Date(1991, September, 14, 8, 0, 0, 0, UTC)}, 6: {Date(1991, September, 15, 0, 50, 0, 0, loc), Date(1991, September, 14, 15, 50, 0, 0, UTC)}, 7: {Date(1991, September, 15, 2, 00, 0, 0, loc), Date(1991, September, 14, 18, 00, 0, 0, UTC)}, } for i, tt := range tests { if !tt.give.Equal(tt.want) { t.Errorf("#%d:: %#v is not equal to %#v", i, tt.give.Format(RFC3339), tt.want.Format(RFC3339)) } } } //--to func TestTimeWithZoneTransition(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestMarshalBinaryVersion2(t *testing.T) { t0, err := Parse(RFC3339, "1880-01-01T00:00:00Z") if err != nil { t.Errorf("Failed to parse time, error = %v", err) } loc, err := LoadLocation("US/Eastern") if err != nil { t.Errorf("Failed to load location, error = %v", err) } t1 := t0.In(loc) b, err := t1.MarshalBinary() if err != nil { t.Errorf("Failed to Marshal, error = %v", err) } t2 := Time{} err = t2.UnmarshalBinary(b) if err != nil { t.Errorf("Failed to Unmarshal, error = %v", err) } if !(t0.Equal(t1) && t1.Equal(t2)) { if !t0.Equal(t1) { t.Errorf("The result t1: %+v after Marshal is not matched original t0: %+v", t1, t0) } if !t1.Equal(t2) { t.Errorf("The result t2: %+v after Unmarshal is not matched original t1: %+v", t2, t1) } } } //--to func TestMarshalBinaryVersion2(t *testing.T) { t.Skip("location is not supported in this environment") } ================================================ FILE: 1.20_linux/time/tzdata_test.go.patch ================================================ //--from import ( "reflect" "testing" "time" _ "time/tzdata" ) //--to import ( "reflect" "testing" _ "time/tzdata" ) //--from func TestEmbeddedTZData(t *testing.T) { undo := time.DisablePlatformSources() defer undo() for _, zone := range zones { ref, err := time.LoadLocation(zone) if err != nil { t.Errorf("LoadLocation(%q): %v", zone, err) continue } embedded, err := time.LoadFromEmbeddedTZData(zone) if err != nil { t.Errorf("LoadFromEmbeddedTZData(%q): %v", zone, err) continue } sample, err := time.LoadLocationFromTZData(zone, []byte(embedded)) if err != nil { t.Errorf("LoadLocationFromTZData failed for %q: %v", zone, err) continue } // Compare the name and zone fields of ref and sample. // The tx field changes faster as tzdata is updated. // The cache fields are expected to differ. v1 := reflect.ValueOf(ref).Elem() v2 := reflect.ValueOf(sample).Elem() typ := v1.Type() nf := typ.NumField() found := 0 for i := 0; i < nf; i++ { ft := typ.Field(i) if ft.Name != "name" && ft.Name != "zone" { continue } found++ if !equal(t, v1.Field(i), v2.Field(i)) { t.Errorf("zone %s: system and embedded tzdata field %s differs", zone, ft.Name) } } if found != 2 { t.Errorf("test must be updated for change to time.Location struct") } } } //--to func TestEmbeddedTZData(t *testing.T) { t.Skip("location is not supported in this environment") } ================================================ FILE: 1.20_linux/time/zoneinfo_test.go.patch ================================================ //--from import ( "errors" "fmt" "internal/testenv" "os" "reflect" "testing" "time" ) //--to import ( "fmt" "testing" "time" ) //--from func TestEnvVarUsage(t *testing.T) { time.ResetZoneinfoForTesting() const testZoneinfo = "foo.zip" const env = "ZONEINFO" t.Setenv(env, testZoneinfo) // Result isn't important, we're testing the side effect of this command time.LoadLocation("Asia/Jerusalem") defer time.ResetZoneinfoForTesting() if zoneinfo := time.ZoneinfoForTesting(); testZoneinfo != *zoneinfo { t.Errorf("zoneinfo does not match env variable: got %q want %q", *zoneinfo, testZoneinfo) } } //--to func TestEnvVarUsage(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestBadLocationErrMsg(t *testing.T) { time.ResetZoneinfoForTesting() loc := "Asia/SomethingNotExist" want := errors.New("unknown time zone " + loc) _, err := time.LoadLocation(loc) if err.Error() != want.Error() { t.Errorf("LoadLocation(%q) error = %v; want %v", loc, err, want) } } //--to func TestBadLocationErrMsg(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestVersion3(t *testing.T) { undo := time.DisablePlatformSources() defer undo() _, err := time.LoadLocation("Asia/Jerusalem") if err != nil { t.Fatal(err) } } //--to func TestVersion3(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestFirstZone(t *testing.T) { undo := time.DisablePlatformSources() defer undo() const format = "Mon, 02 Jan 2006 15:04:05 -0700 (MST)" var tests = []struct { zone string unix int64 want1 string want2 string }{ { "PST8PDT", -1633269601, "Sun, 31 Mar 1918 01:59:59 -0800 (PST)", "Sun, 31 Mar 1918 03:00:00 -0700 (PDT)", }, { "Pacific/Fakaofo", 1325242799, "Thu, 29 Dec 2011 23:59:59 -1100 (-11)", "Sat, 31 Dec 2011 00:00:00 +1300 (+13)", }, } for _, test := range tests { z, err := time.LoadLocation(test.zone) if err != nil { t.Fatal(err) } s := time.Unix(test.unix, 0).In(z).Format(format) if s != test.want1 { t.Errorf("for %s %d got %q want %q", test.zone, test.unix, s, test.want1) } s = time.Unix(test.unix+1, 0).In(z).Format(format) if s != test.want2 { t.Errorf("for %s %d got %q want %q", test.zone, test.unix, s, test.want2) } } } //--to func TestFirstZone(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestLoadLocationFromTZData(t *testing.T) { undo := time.DisablePlatformSources() defer undo() const locationName = "Asia/Jerusalem" reference, err := time.LoadLocation(locationName) if err != nil { t.Fatal(err) } gorootSource, ok := time.GorootZoneSource(testenv.GOROOT(t)) if !ok { t.Fatal("Failed to locate tzinfo source in GOROOT.") } tzinfo, err := time.LoadTzinfo(locationName, gorootSource) if err != nil { t.Fatal(err) } sample, err := time.LoadLocationFromTZData(locationName, tzinfo) if err != nil { t.Fatal(err) } if !reflect.DeepEqual(reference, sample) { t.Errorf("return values of LoadLocationFromTZData and LoadLocation don't match") } } //--to func TestLoadLocationFromTZData(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestEarlyLocation(t *testing.T) { undo := time.DisablePlatformSources() defer undo() const locName = "America/New_York" loc, err := time.LoadLocation(locName) if err != nil { t.Fatal(err) } d := time.Date(1900, time.January, 1, 0, 0, 0, 0, loc) tzName, tzOffset := d.Zone() if want := "EST"; tzName != want { t.Errorf("Zone name == %s, want %s", tzName, want) } if want := -18000; tzOffset != want { t.Errorf("Zone offset == %d, want %d", tzOffset, want) } } //--to func TestEarlyLocation(t *testing.T) { t.Skip("location is not supported in this environment") } //--from func TestLoadLocationFromTZDataSlim(t *testing.T) { for _, test := range slimTests { tzData, err := os.ReadFile("testdata/" + test.fileName) if err != nil { t.Error(err) continue } reference, err := time.LoadLocationFromTZData(test.zoneName, tzData) if err != nil { t.Error(err) continue } d := test.date(reference) tzName, tzOffset := d.Zone() if tzName != test.wantName { t.Errorf("Zone name == %s, want %s", tzName, test.wantName) } if tzOffset != test.wantOffset { t.Errorf("Zone offset == %d, want %d", tzOffset, test.wantOffset) } } } //--to func TestLoadLocationFromTZDataSlim(t *testing.T) { t.Skip("location is not supported in this environment") } ================================================ FILE: 1.20_linux/time/zoneinfo_unix.go.patch ================================================ //--from import ( "syscall" ) //--to //--from func initLocal() { // consult $TZ to find the time zone to use. // no $TZ means use the system default /etc/localtime. // $TZ="" means use UTC. // $TZ="foo" or $TZ=":foo" if foo is an absolute path, then the file pointed // by foo will be used to initialize timezone; otherwise, file // /usr/share/zoneinfo/foo will be used. tz, ok := syscall.Getenv("TZ") switch { case !ok: z, err := loadLocation("localtime", []string{"/etc"}) if err == nil { localLoc = *z localLoc.name = "Local" return } case tz != "": if tz[0] == ':' { tz = tz[1:] } if tz != "" && tz[0] == '/' { if z, err := loadLocation(tz, []string{""}); err == nil { localLoc = *z if tz == "/etc/localtime" { localLoc.name = "Local" } else { localLoc.name = tz } return } } else if tz != "" && tz != "UTC" { if z, err := loadLocation(tz, platformZoneSources); err == nil { localLoc = *z return } } } // Fall back to UTC. localLoc.name = "UTC" } //--to func initLocal() { localLoc.name = "UTC" } ================================================ FILE: 1.20_linux/time/zoneinfo_unix_test.go.patch ================================================ //--from import ( "os" "testing" "time" ) //--to import ( "testing" ) //--from func TestEnvTZUsage(t *testing.T) { const env = "TZ" tz, ok := os.LookupEnv(env) if !ok { defer os.Unsetenv(env) } else { defer os.Setenv(env, tz) } defer time.ForceUSPacificForTesting() localZoneName := "Local" // The file may not exist. if _, err := os.Stat("/etc/localtime"); os.IsNotExist(err) { localZoneName = "UTC" } cases := []struct { nilFlag bool tz string local string }{ // no $TZ means use the system default /etc/localtime. {true, "", localZoneName}, // $TZ="" means use UTC. {false, "", "UTC"}, {false, ":", "UTC"}, {false, "Asia/Shanghai", "Asia/Shanghai"}, {false, ":Asia/Shanghai", "Asia/Shanghai"}, {false, "/etc/localtime", localZoneName}, {false, ":/etc/localtime", localZoneName}, } for _, c := range cases { time.ResetLocalOnceForTest() if c.nilFlag { os.Unsetenv(env) } else { os.Setenv(env, c.tz) } if time.Local.String() != c.local { t.Errorf("invalid Local location name for %q: got %q want %q", c.tz, time.Local, c.local) } } time.ResetLocalOnceForTest() // The file may not exist on Solaris 2 and IRIX 6. path := "/usr/share/zoneinfo/Asia/Shanghai" os.Setenv(env, path) if _, err := os.Stat(path); os.IsNotExist(err) { if time.Local.String() != "UTC" { t.Errorf(`invalid path should fallback to UTC: got %q want "UTC"`, time.Local) } return } if time.Local.String() != path { t.Errorf(`custom path should lead to path itself: got %q want %q`, time.Local, path) } timeInUTC := time.Date(2009, 1, 1, 12, 0, 0, 0, time.UTC) sameTimeInShanghai := time.Date(2009, 1, 1, 20, 0, 0, 0, time.Local) if !timeInUTC.Equal(sameTimeInShanghai) { t.Errorf("invalid timezone: got %q want %q", timeInUTC, sameTimeInShanghai) } time.ResetLocalOnceForTest() os.Setenv(env, ":"+path) if time.Local.String() != path { t.Errorf(`custom path should lead to path itself: got %q want %q`, time.Local, path) } time.ResetLocalOnceForTest() os.Setenv(env, path[:len(path)-1]) if time.Local.String() != "UTC" { t.Errorf(`invalid path should fallback to UTC: got %q want "UTC"`, time.Local) } } //--to func TestEnvTZUsage(t *testing.T) { t.Skip("location is not supported in this environment") } ================================================ FILE: 1.20_windows/runtime/abi_test.go.patch ================================================ //--from func TestFinalizerRegisterABI(t *testing.T) { //--to func TestFinalizerRegisterABI(t *testing.T) { t.Skip("creating a new process with os.Args[0] doesn't work in this environment") ================================================ FILE: 1.20_windows/runtime/cgo/gcc_windows_amd64.c.patch ================================================ //--from static void threadentry(void *v) { //--to static int getproccount() { static int proccount = 0; if (!proccount) { SYSTEM_INFO info; GetSystemInfo(&info); proccount = info.dwNumberOfProcessors; } return proccount; } static void threadentry(void *v) { SetThreadAffinityMask(GetCurrentThread(), (1<= 0x80 { isASCII = false break } } if !isASCII { var m uint32 isConsole := stdcall2(_GetConsoleMode, handle, uintptr(unsafe.Pointer(&m))) != 0 // If this is a console output, various non-unicode code pages can be in use. // Use the dedicated WriteConsole call to ensure unicode is printed correctly. if isConsole { return int32(writeConsole(handle, buf, n)) } } var written uint32 stdcall5(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--to func write1(fd uintptr, buf unsafe.Pointer, n int32) int32 { const ( _STD_OUTPUT_HANDLE = ^uintptr(10) // -11 _STD_ERROR_HANDLE = ^uintptr(11) // -12 ) var handle uintptr switch fd { case 1: handle = stdcall1(_GetStdHandle, _STD_OUTPUT_HANDLE) case 2: handle = stdcall1(_GetStdHandle, _STD_ERROR_HANDLE) default: // assume fd is real windows handle. handle = fd } if fd == 1 || fd == 2 { // Note that handle is not used anyway. return int32(writeConsole(handle, buf, n)) } var written uint32 stdcall5(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--from func writeConsoleUTF16(handle uintptr, b []uint16) { l := uint32(len(b)) if l == 0 { return } var written uint32 stdcall5(_WriteConsoleW, handle, uintptr(unsafe.Pointer(&b[0])), uintptr(l), uintptr(unsafe.Pointer(&written)), 0, ) return } //--to func writeConsoleUTF16(handle uintptr, b []uint16) { b = b[:len(b)+1] b[len(b)-1] = 0 l := uint32(len(b)) if l <= 1 { return } stdcall1(_OutputDebugStringW, uintptr(unsafe.Pointer(&b[0])), ) return } ================================================ FILE: 1.20_windows/runtime/syscall_windows.go.patch ================================================ //--from func syscall_SyscallN(trap uintptr, args ...uintptr) (r1, r2, err uintptr) { //--to func syscall_SyscallN(trap uintptr, args ...uintptr) (r1, r2, err uintptr) { if trap == 0 { panic("trap must not be 0 at SyscallN") } ================================================ FILE: 1.20_windows/runtime/syscall_windows_test.go.patch ================================================ //--from func TestNumCPU(t *testing.T) { //--to func TestNumCPU(t *testing.T) { t.Skip("creating a new process with os.Args[0] doesn't work in this environment") ================================================ FILE: 1.20_windows/sync/mutex_test.go.patch ================================================ //--from import ( "fmt" "internal/testenv" "os" "os/exec" "runtime" "strings" . "sync" "testing" "time" ) //--to import ( "fmt" "os" "runtime" . "sync" "testing" "time" ) //--from func TestMutexMisuse(t *testing.T) { testenv.MustHaveExec(t) for _, test := range misuseTests { out, err := exec.Command(os.Args[0], "TESTMISUSE", test.name).CombinedOutput() if err == nil || !strings.Contains(string(out), "unlocked") { t.Errorf("%s: did not find failure with message about unlocked lock: %s\n%s\n", test.name, err, out) } } } //--to func TestMutexMisuse(t *testing.T) { t.Skip("analyzing output is not supported in this environment") } ================================================ FILE: 1.21_linux/internal/reflectlite/reflect_mirror_test.go.patch ================================================ //--from func TestMirrorWithReflect(t *testing.T) { //--to func TestMirrorWithReflect(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.21_linux/internal/syscall/unix/fcntl_unix.go.patch ================================================ //--from func Fcntl(fd int, cmd int, arg int) (int, error) { val, errno := fcntl(int32(fd), int32(cmd), int32(arg)) if val == -1 { return int(val), syscall.Errno(errno) } return int(val), nil } //--to func Fcntl(fd int, cmd int, arg int) (int, error) { return 0, syscall.ENOSYS } ================================================ FILE: 1.21_linux/internal/testenv/exec.go.patch ================================================ //--from func tryExec() error { //--to func tryExec() error { return fmt.Errorf("can't probe for exec support") ================================================ FILE: 1.21_linux/internal/testenv/testenv.go.patch ================================================ //--from func HasGoBuild() bool { //--to func HasGoBuild() bool { return false ================================================ FILE: 1.21_linux/internal/testenv/testenv_notunix.go.patch ================================================ //--from //go:build windows || plan9 || (js && wasm) || wasip1 //--to //go:build windows || plan9 || (js && wasm) || wasip1 || linux ================================================ FILE: 1.21_linux/internal/testenv/testenv_unix.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.21_linux/math/big/link_test.go.patch ================================================ //--from func TestLinkerGC(t *testing.T) { //--to func TestLinkerGC(t *testing.T) { t.Skip("go tools are not supported in this environment") ================================================ FILE: 1.21_linux/math/rand/default_test.go.patch ================================================ //--from func TestDefaultRace(t *testing.T) { //--to func TestDefaultRace(t *testing.T) { t.Skip("os.Getenv and creating processes are not supported in this environment") ================================================ FILE: 1.21_linux/runtime/align_test.go.patch ================================================ //--from func TestAtomicAlignment(t *testing.T) { //--to func TestAtomicAlignment(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.21_linux/runtime/callers_test.go.patch ================================================ //--from func TestCallersNilPointerPanic(t *testing.T) { //--to func TestCallersNilPointerPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestCallersDeferNilFuncPanic(t *testing.T) { //--to func TestCallersDeferNilFuncPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { //--to func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.21_linux/runtime/cgo/cgo.go.patch ================================================ //--from */ import "C" //--to #cgo !darwin LDFLAGS: -Wl,-unresolved-symbols=ignore-all #cgo darwin LDFLAGS: -Wl,-undefined,dynamic_lookup */ import "C" ================================================ FILE: 1.21_linux/runtime/cgo/gcc_linux_amd64.c.patch ================================================ //--from #include #include #include // strerror #include #include #include "libcgo.h" #include "libcgo_unix.h" //--to #include #include #include // strerror #include #include "libcgo.h" #include "libcgo_unix.h" //--from void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--to void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; pthread_t p; size_t size; int err; pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--from static void* threadentry(void *v) { //--to static void* threadentry(void *v) { extern void hitsumabushi_initializeThread(void); hitsumabushi_initializeThread(); ================================================ FILE: 1.21_linux/runtime/cgo/gcc_linux_arm64.c.patch ================================================ //--from void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--to void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 16 * 4096); // Hack for some special environments pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--from void x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase) { pthread_attr_t *attr; size_t size; /* The memory sanitizer distributed with versions of clang before 3.8 has a bug: if you call mmap before malloc, mmap may return an address that is later overwritten by the msan library. Avoid this problem by forcing a call to malloc here, before we ever call malloc. This is only required for the memory sanitizer, so it's unfortunate that we always run it. It should be possible to remove this when we no longer care about versions of clang before 3.8. The test for this is misc/cgo/testsanitizers. GCC works hard to eliminate a seemingly unnecessary call to malloc, so we actually use the memory we allocate. */ setg_gcc = setg; attr = (pthread_attr_t*)malloc(sizeof *attr); if (attr == NULL) { fatalf("malloc failed: %s", strerror(errno)); } pthread_attr_init(attr); pthread_attr_getstacksize(attr, &size); g->stacklo = (uintptr)&size - size + 4096; pthread_attr_destroy(attr); free(attr); if (x_cgo_inittls) { x_cgo_inittls(tlsg, tlsbase); } } //--to void x_cgo_init(G *g, void (*setg)(void*), void **tlsg, void **tlsbase) { pthread_attr_t *attr; size_t size; /* The memory sanitizer distributed with versions of clang before 3.8 has a bug: if you call mmap before malloc, mmap may return an address that is later overwritten by the msan library. Avoid this problem by forcing a call to malloc here, before we ever call malloc. This is only required for the memory sanitizer, so it's unfortunate that we always run it. It should be possible to remove this when we no longer care about versions of clang before 3.8. The test for this is misc/cgo/testsanitizers. GCC works hard to eliminate a seemingly unnecessary call to malloc, so we actually use the memory we allocate. */ setg_gcc = setg; attr = (pthread_attr_t*)malloc(sizeof *attr); if (attr == NULL) { fatalf("malloc failed: %s", strerror(errno)); } pthread_attr_init(attr); pthread_attr_setstacksize(attr, 16 * 4096); // Hack for some special environments pthread_attr_getstacksize(attr, &size); g->stacklo = (uintptr)&size - size + 4096; pthread_attr_destroy(attr); free(attr); if (x_cgo_inittls) { x_cgo_inittls(tlsg, tlsbase); } } //--from static void* threadentry(void *v) { //--to static void* threadentry(void *v) { // Note that threadentry will also be defined in gcc_linux.go in Go 1.22. extern void hitsumabushi_initializeThread(void); hitsumabushi_initializeThread(); ================================================ FILE: 1.21_linux/runtime/cgo/gcc_setenv.c.patch ================================================ //--from void x_cgo_setenv(char **arg) { _cgo_tsan_acquire(); setenv(arg[0], arg[1], 1); _cgo_tsan_release(); } //--to void x_cgo_setenv(char **arg) { } //--from void x_cgo_unsetenv(char **arg) { _cgo_tsan_acquire(); unsetenv(arg[0]); _cgo_tsan_release(); } //--to void x_cgo_unsetenv(char **arg) { } ================================================ FILE: 1.21_linux/runtime/cgo/gcc_sigaction.c.patch ================================================ //--from //go:build linux && (amd64 || arm64 || ppc64le) //--to //go:build linux && (arm64 || ppc64le) ================================================ FILE: 1.21_linux/runtime/cgo/hitsumabushi_clock_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp) { return clock_gettime(clk_id, tp); } ================================================ FILE: 1.21_linux/runtime/cgo/hitsumabushi_cpu_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int32_t hitsumabushi_getproccount() { return 1; } ================================================ FILE: 1.21_linux/runtime/cgo/hitsumabushi_filesystem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include #include #include "libcgo.h" #include "libcgo_unix.h" static const int kFDOffset = 100; typedef struct { const void* content; size_t content_size; size_t current; int32_t fd; } pseudo_file; // TODO: Do we need to protect this by mutex? static pseudo_file pseudo_files[100]; static pthread_mutex_t* pseudo_file_mutex() { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; return &mutex; } static int32_t open_pseudo_file(const void* content, size_t content_size) { pthread_mutex_lock(pseudo_file_mutex()); int index = 0; int found = 0; for (int i = 0; i < sizeof(pseudo_files) / sizeof(pseudo_file); i++) { if (pseudo_files[i].fd == 0) { index = i; found = 1; break; } } if (!found) { // Too many pseudo files are opened. pthread_mutex_unlock(pseudo_file_mutex()); return -1; } int32_t fd = index + kFDOffset; pseudo_files[index].content = content; pseudo_files[index].content_size = content_size; pseudo_files[index].current = 0; pseudo_files[index].fd = fd; pthread_mutex_unlock(pseudo_file_mutex()); return fd; } static size_t read_pseudo_file(int32_t fd, void *p, int32_t n) { pthread_mutex_lock(pseudo_file_mutex()); int32_t index = fd - kFDOffset; pseudo_file *file = &pseudo_files[index]; size_t rest = file->content_size - file->current; if (rest < n) { n = rest; } memcpy(p, file->content + file->current, n); pseudo_files[index].current += n; pthread_mutex_unlock(pseudo_file_mutex()); return n; } static void close_pseudo_file(int32_t fd) { pthread_mutex_lock(pseudo_file_mutex()); int32_t index = fd - kFDOffset; pseudo_files[index].content = NULL; pseudo_files[index].content_size = 0; pseudo_files[index].current = 0; pseudo_files[index].fd = 0; pthread_mutex_unlock(pseudo_file_mutex()); } int32_t hitsumabushi_closefd(int32_t fd) { if (fd >= kFDOffset) { close_pseudo_file(fd); return 0; } fprintf(stderr, "syscall close(%d) is not implemented\n", fd); return 0; } int32_t hitsumabushi_open(char *name, int32_t mode, int32_t perm) { if (strcmp(name, "/proc/self/auxv") == 0) { static const char auxv[] = "\x06\x00\x00\x00\x00\x00\x00\x00" // _AT_PAGESZ tag (6) "\x00\x10\x00\x00\x00\x00\x00\x00" // 4096 bytes per page "\x00\x00\x00\x00\x00\x00\x00\x00" // Dummy bytes "\x00\x00\x00\x00\x00\x00\x00\x00"; // Dummy bytes return open_pseudo_file(auxv, sizeof(auxv) / sizeof(char)); } if (strcmp(name, "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size") == 0) { static const char hpage_pmd_size[] = "\x30\x5c"; // '0', '\n' return open_pseudo_file(hpage_pmd_size, sizeof(hpage_pmd_size) / sizeof(char)); } fprintf(stderr, "syscall open(%s, %d, %d) is not implemented\n", name, mode, perm); const static int kENOENT = 0x2; return kENOENT; } int32_t hitsumabushi_read(int32_t fd, void *p, int32_t n) { if (fd >= kFDOffset) { return read_pseudo_file(fd, p, n); } fprintf(stderr, "syscall read(%d, %p, %d) is not implemented\n", fd, p, n); const static int kEBADF = 0x9; return kEBADF; } int32_t hitsumabushi_write1(uintptr_t fd, void *p, int32_t n) { static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; int32_t ret = 0; pthread_mutex_lock(&m); switch (fd) { case 1: ret = fwrite(p, 1, n, stdout); fflush(stdout); break; case 2: ret = fwrite(p, 1, n, stderr); fflush(stderr); break; default: fprintf(stderr, "syscall write(%lu, %p, %d) is not implemented\n", fd, p, n); ret = -EBADF; break; } pthread_mutex_unlock(&m); return ret; } int32_t hitsumabushi_lseek(uintptr_t fd, off_t offset, int32_t whence) { fprintf(stderr, "syscall lseek(%lu, %lu, %d) is not implemented\n", fd, offset, whence); return -ENOSYS; } int32_t hitsumabushi_fcntl(int32_t fd, int32_t cmd, int32_t arg) { if (fd == 0 || fd == 1 || fd == 2) { if (cmd == F_GETFL) { return 0; } } fprintf(stderr, "syscall fcntl(%d, %d, %d) is not implemented\n", fd, cmd, arg); return -EBADF; } int32_t hitsumabushi_fstat(int32_t fd, struct stat *stat) { fprintf(stderr, "syscall fstat(%d, %p) is not implemented\n", fd, stat); return -ENOSYS; } int32_t hitsumabushi_renameat(int32_t fd1, char* name1, int32_t fd2, char* name2) { fprintf(stderr, "syscall renameat(%d, %s, %d, %s) is not implemented\n", fd1, name1, fd2, name2); return -ENOSYS; } int32_t hitsumabushi_fstatat(int32_t fd, char* name, struct stat* p, int32_t flags) { fprintf(stderr, "syscall fstatat(%d, %s, %p, %d) is not implemented\n", fd, name, p, flags); return -ENOSYS; } ================================================ FILE: 1.21_linux/runtime/cgo/hitsumabushi_futex_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include #include #include #include static const int kPseudoFutexWait = 0; static const int kPseudoFutexWake = 1; static void pseudo_futex(uint32_t *uaddr, int mode, uint32_t val, const struct timespec *reltime) { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; struct timespec abstime; if (reltime) { // We are not sure CLOCK_REALTIME is correct or not here. // However, this time limit is actually not used as the condition variable is shared by // all the threads. Before the time limit reaches, the thread wakes up in 99.9999...% cases. clock_gettime(CLOCK_REALTIME, &abstime); abstime.tv_sec += reltime->tv_sec; abstime.tv_nsec += reltime->tv_nsec; if (1000000000 <= abstime.tv_nsec) { abstime.tv_sec += 1; abstime.tv_nsec -= 1000000000; } } int ret = pthread_mutex_lock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_lock failed: %d\n", ret); abort(); } switch (mode) { case kPseudoFutexWait: if (reltime) { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_timedwait(&cond, &mutex, &abstime); if (ret && ret != ETIMEDOUT) { fprintf(stderr, "pthread_cond_timedwait failed: %d\n", ret); abort(); } } } else { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_wait(&cond, &mutex); if (ret) { fprintf(stderr, "pthread_cond_wait failed: %d\n", ret); abort(); } } } break; case kPseudoFutexWake: if (val != 1) { fprintf(stderr, "val for waking must be 1 but %d\n", val); abort(); } // TODO: broadcasting is not efficient. Use a mutex for each uaddr. int ret = pthread_cond_broadcast(&cond); if (ret) { fprintf(stderr, "pthread_cond_broadcast failed: %d\n", ret); abort(); } break; } ret = pthread_mutex_unlock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_unlock failed: %d\n", ret); abort(); } } int32_t hitsumabushi_futex(uint32_t *uaddr, int32_t futex_op, uint32_t val, const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3) { enum { kFutexWaitPrivate = 128, kFutexWakePrivate = 129, }; switch (futex_op) { case kFutexWaitPrivate: pseudo_futex(uaddr, kPseudoFutexWait, val, timeout); break; case kFutexWakePrivate: pseudo_futex(uaddr, kPseudoFutexWake, val, NULL); break; } // This function should return the number of awaken threads, but now it is impossible. // Just return 0. return 0; } ================================================ FILE: 1.21_linux/runtime/cgo/hitsumabushi_mem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include void* hitsumabushi_sysReserveOS(void* v, uintptr_t n); void* hitsumabushi_sysAllocOS(uintptr_t n) { return hitsumabushi_sysReserveOS(NULL, n); } void hitsumabushi_sysUnusedOS(void* v, uintptr_t n) { } void hitsumabushi_sysUsedOS(void* v, uintptr_t n) { } void hitsumabushi_sysHugePageOS(void* v, uintptr_t n) { } void hitsumabushi_sysFreeOS(void* v, uintptr_t n) { } void hitsumabushi_sysFaultOS(void* v, uintptr_t n) { } void* hitsumabushi_sysReserveOS(void* v, uintptr_t n) { if (v) { return NULL; } return calloc(n, 1); } void hitsumabushi_sysMapOS(void* v, uintptr_t n) { } ================================================ FILE: 1.21_linux/runtime/cgo/hitsumabushi_syscalls_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include // for usleep #include // for size_t #include "libcgo.h" #include "libcgo_unix.h" typedef unsigned int gid_t; extern int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp); extern int32_t hitsumabushi_getproccount(); void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { abort(); return NULL; } int munmap(void *addr, size_t length) { abort(); return 0; } int pthread_sigmask(int how, void *set, void *oldset) { // Do nothing. return 0; } int setegid(gid_t gid) { // Do nothing. return 0; } int seteuid(uid_t gid) { // Do nothing. return 0; } int setgid(gid_t gid) { // Do nothing. return 0; } int setgroups(size_t size, const gid_t *list) { // Do nothing. return 0; } int setregid(gid_t rgid, gid_t egid) { // Do nothing. return 0; } int setreuid(uid_t ruid, uid_t euid) { // Do nothing. return 0; } int setresgid(gid_t rgid, gid_t egid, gid_t sgid) { // Do nothing. return 0; } int setresuid(uid_t ruid, uid_t euid, uid_t suid) { // Do nothing. return 0; } int setuid(uid_t gid) { // Do nothing. return 0; } int sigaction(int signum, void *act, void *oldact) { // Do nothing. return 0; } int sigaddset(void *set, int signum) { // Do nothing. return 0; } int sigemptyset(void *set) { // Do nothing. return 0; } int sigfillset(void *set) { // Do nothing. return 0; } int sigismember(void *set, int signum) { // Do nothing. return 0; } uint32_t hitsumabushi_gettid() { uint64_t tid64 = (uint64_t)(pthread_self()); uint32_t tid = (uint32_t)(tid64 >> 32) ^ (uint32_t)(tid64); return tid; } int64_t hitsumabushi_nanotime1() { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_MONOTONIC, &tp); return (int64_t)(tp.tv_sec) * 1000000000ll + (int64_t)tp.tv_nsec; } int32_t hitsumabushi_osyield() { return sched_yield(); } int32_t hitsumabushi_sched_getaffinity(pid_t pid, size_t cpusetsize, void *mask) { int32_t numcpu = hitsumabushi_getproccount(); for (int32_t i = 0; i < numcpu; i += 8) ((unsigned char*)mask)[i / 8] = (unsigned char)((1u << (numcpu - i)) - 1); // https://man7.org/linux/man-pages/man2/sched_setaffinity.2.html // > On success, the raw sched_getaffinity() system call returns the // > number of bytes placed copied into the mask buffer; return (numcpu + 7) / 8; } void hitsumabushi_usleep(useconds_t usec) { usleep(usec); } void hitsumabushi_walltime1(int64_t* sec, int32_t* nsec) { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_REALTIME, &tp); *sec = tp.tv_sec; *nsec = tp.tv_nsec; } void hitsumabushi_exit(int32_t code) { exit(code); } ================================================ FILE: 1.21_linux/runtime/cgo/hitsumabushi_thread_linux.c ================================================ void hitsumabushi_initializeThread(void) { } ================================================ FILE: 1.21_linux/runtime/cgo/linux_syscall.c.patch ================================================ //--from #include #include #include #include #include "libcgo.h" //--to #include #include #include #include "libcgo.h" //--from void _cgo_libc_setegid(argset_t* x) { SET_RETVAL(setegid((gid_t) x->args[0])); } //--to void _cgo_libc_setegid(argset_t* x) { } //--from void _cgo_libc_seteuid(argset_t* x) { SET_RETVAL(seteuid((uid_t) x->args[0])); } //--to void _cgo_libc_seteuid(argset_t* x) { } //--from void _cgo_libc_setgid(argset_t* x) { SET_RETVAL(setgid((gid_t) x->args[0])); } //--to void _cgo_libc_setgid(argset_t* x) { } //--from void _cgo_libc_setgroups(argset_t* x) { SET_RETVAL(setgroups((size_t) x->args[0], (const gid_t *) x->args[1])); } //--to void _cgo_libc_setgroups(argset_t* x) { } //--from void _cgo_libc_setregid(argset_t* x) { SET_RETVAL(setregid((gid_t) x->args[0], (gid_t) x->args[1])); } //--to void _cgo_libc_setregid(argset_t* x) { } //--from void _cgo_libc_setresgid(argset_t* x) { SET_RETVAL(setresgid((gid_t) x->args[0], (gid_t) x->args[1], (gid_t) x->args[2])); } //--to void _cgo_libc_setresgid(argset_t* x) { } //--from void _cgo_libc_setreuid(argset_t* x) { SET_RETVAL(setreuid((uid_t) x->args[0], (uid_t) x->args[1])); } //--to void _cgo_libc_setreuid(argset_t* x) { } //--from void _cgo_libc_setuid(argset_t* x) { SET_RETVAL(setuid((uid_t) x->args[0])); } //--to void _cgo_libc_setuid(argset_t* x) { } ================================================ FILE: 1.21_linux/runtime/cgo/sigaction.go.patch ================================================ //--from //go:build (linux && amd64) || (freebsd && amd64) || (linux && arm64) || (linux && ppc64le) //--to //go:build (freebsd && amd64) || (linux && arm64) || (linux && ppc64le) ================================================ FILE: 1.21_linux/runtime/crash_test.go.patch ================================================ //--from func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { //--to func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { t.Skip("buildTestProg is not supported in this environment") //--from func TestPanicInlined(t *testing.T) { //--to func TestPanicInlined(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.21_linux/runtime/crash_unix_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.21_linux/runtime/debug/heapdump_test.go.patch ================================================ //--from func TestWriteHeapDumpNonempty(t *testing.T) { //--to func TestWriteHeapDumpNonempty(t *testing.T) { t.Skip("file is not supported in this environment") //--from func TestWriteHeapDumpFinalizers(t *testing.T) { //--to func TestWriteHeapDumpFinalizers(t *testing.T) { t.Skip("file is not supported in this environment") //--from func TestWriteHeapDumpTypeName(t *testing.T) { //--to func TestWriteHeapDumpTypeName(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.21_linux/runtime/debug/panic_test.go.patch ================================================ //--from func TestPanicOnFault(t *testing.T) { //--to func TestPanicOnFault(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.21_linux/runtime/debug_test.go.patch ================================================ //--from //go:build (amd64 || arm64) && linux && !race //--to //go:build ignore ================================================ FILE: 1.21_linux/runtime/export_unix_test.go ================================================ // Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build unix package runtime const ( O_WRONLY = _O_WRONLY O_CREAT = _O_CREAT O_TRUNC = _O_TRUNC ) ================================================ FILE: 1.21_linux/runtime/internal/syscall/asm_linux_amd64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0 // a6 already in R9. // a5 already in R8. MOVQ SI, R10 // a4 MOVQ DI, DX // a3 MOVQ CX, SI // a2 MOVQ BX, DI // a1 // num already in AX. SYSCALL CMPQ AX, $0xfffffffffffff001 JLS ok NEGQ AX MOVQ AX, CX // errno MOVQ $-1, AX // r1 MOVQ $0, BX // r2 RET ok: // r1 already in AX. MOVQ DX, BX // r2 MOVQ $0, CX // errno RET //--to ================================================ FILE: 1.21_linux/runtime/internal/syscall/asm_linux_arm64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0-80 MOVD num+0(FP), R8 // syscall entry MOVD a1+8(FP), R0 MOVD a2+16(FP), R1 MOVD a3+24(FP), R2 MOVD a4+32(FP), R3 MOVD a5+40(FP), R4 MOVD a6+48(FP), R5 SVC CMN $4095, R0 BCC ok MOVD $-1, R4 MOVD R4, r1+56(FP) MOVD ZR, r2+64(FP) NEG R0, R0 MOVD R0, errno+72(FP) RET ok: MOVD R0, r1+56(FP) MOVD R1, r2+64(FP) MOVD ZR, errno+72(FP) RET //--to ================================================ FILE: 1.21_linux/runtime/internal/syscall/syscall_linux.go.patch ================================================ //--from func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) //--to func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { println("not implemented syscall at Syscall6", num) panic("syscall.Syscall6") return 0, 0, 0x26 // ENOSYS } //--from func syscall_RawSyscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { return Syscall6(num, a1, a2, a3, a4, a5, a6) } //--to func syscall_RawSyscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { println("not implemented syscall at RawSyscall6", num) panic("syscall.RawSyscall6") return 0, 0, 0x26 // ENOSYS } ================================================ FILE: 1.21_linux/runtime/internal/syscall/syscall_linux_test.go.patch ================================================ //--from import ( "runtime/internal/syscall" "testing" ) //--to import ( "testing" ) //--from func TestEpollctlErrorSign(t *testing.T) { v := syscall.EpollCtl(-1, 1, -1, &syscall.EpollEvent{}) const EBADF = 0x09 if v != EBADF { t.Errorf("epollctl = %v, want %v", v, EBADF) } } //--to func TestEpollctlErrorSign(t *testing.T) { t.Skip("Epollctl is not supported in this environment") } ================================================ FILE: 1.21_linux/runtime/mem_linux.go ================================================ // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This implementation is the most fundamental and minimal allocations like Wasm. // Malloced memory regions are never freed. package runtime import ( "internal/abi" "unsafe" ) // Don't split the stack as this method may be invoked without a valid G, which // prevents us from allocating more stack. // //go:nosplit //go:cgo_unsafe_args func sysAllocOS(n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysAllocOS_trampoline)), unsafe.Pointer(&n)) return } func sysAllocOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit //go:cgo_unsafe_args func sysUnusedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUnusedOS_trampoline)), unsafe.Pointer(&v)) } func sysUnusedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysUsedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUsedOS_trampoline)), unsafe.Pointer(&v)) } func sysUsedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysHugePageOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysHugePageOS_trampoline)), unsafe.Pointer(&v)) } func sysHugePageOS_trampoline(n uintptr, size uintptr) func sysNoHugePageOS(v unsafe.Pointer, n uintptr) { } func sysHugePageCollapseOS(v unsafe.Pointer, n uintptr) { } // Don't split the stack as this function may be invoked without a valid G, // which prevents us from allocating more stack. // //go:nosplit //go:cgo_unsafe_args func sysFreeOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFreeOS_trampoline)), unsafe.Pointer(&v)) } func sysFreeOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysFaultOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFaultOS_trampoline)), unsafe.Pointer(&v)) } func sysFaultOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysReserveOS(v unsafe.Pointer, n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysReserveOS_trampoline)), unsafe.Pointer(&v)) return } func sysReserveOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit //go:cgo_unsafe_args func sysMapOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysMapOS_trampoline)), unsafe.Pointer(&v)) } func sysMapOS_trampoline(n uintptr, size uintptr) ================================================ FILE: 1.21_linux/runtime/memmove_linux_amd64_test.go.patch ================================================ //--from func TestMemmoveOverflow(t *testing.T) { //--to func TestMemmoveOverflow(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.21_linux/runtime/nbpipe_pipe2.go.patch ================================================ //--from //go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris //--to //go:build dragonfly || freebsd || netbsd || openbsd || solaris ================================================ FILE: 1.21_linux/runtime/nbpipe_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.21_linux/runtime/netpoll_epoll.go.patch ================================================ //--from //go:build linux //--to //go:build ignore ================================================ FILE: 1.21_linux/runtime/netpoll_fake.go.patch ================================================ //--from //go:build js && wasm //--to //go:build linux ================================================ FILE: 1.21_linux/runtime/norace_linux_test.go.patch ================================================ //--from func TestNewOSProc0(t *testing.T) { //--to func TestNewOSProc0(t *testing.T) { t.Skip("newosproc0 is not supported in this environment") ================================================ FILE: 1.21_linux/runtime/os_linux.go.patch ================================================ //--from import ( "internal/abi" "internal/goarch" "runtime/internal/atomic" "runtime/internal/syscall" "unsafe" ) //--to import ( "internal/abi" "runtime/internal/atomic" "runtime/internal/syscall" "unsafe" ) //--from //go:noescape func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 //--to //go:nosplit //go:cgo_unsafe_args func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 { ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(futex_trampoline)), unsafe.Pointer(&addr)) return ret } func futex_trampoline(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 //--from func sysargs(argc int32, argv **byte) { n := argc + 1 // skip over argv, envp to get to auxv for argv_index(argv, n) != nil { n++ } // skip NULL separator n++ // now argv+n is auxv auxvp := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*goarch.PtrSize)) if pairs := sysauxv(auxvp[:]); pairs != 0 { auxv = auxvp[: pairs*2 : pairs*2] return } // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } n = read(fd, noescape(unsafe.Pointer(&auxvreadbuf[0])), int32(unsafe.Sizeof(auxvreadbuf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. auxvreadbuf[len(auxvreadbuf)-2] = _AT_NULL pairs := sysauxv(auxvreadbuf[:]) auxv = auxvreadbuf[: pairs*2 : pairs*2] } //--to func sysargs(argc int32, argv **byte) { // argc/argv is not reliable on some machines. // Skip analysing them. // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } n := read(fd, noescape(unsafe.Pointer(&auxvreadbuf[0])), int32(unsafe.Sizeof(auxvreadbuf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. auxvreadbuf[len(auxvreadbuf)-2] = _AT_NULL pairs := sysauxv(auxvreadbuf[:]) auxv = auxvreadbuf[: pairs*2 : pairs*2] } //--from func getRandomData(r []byte) { if startupRandomData != nil { n := copy(r, startupRandomData) extendRandom(r, n) return } fd := open(&urandom_dev[0], 0 /* O_RDONLY */, 0) n := read(fd, unsafe.Pointer(&r[0]), int32(len(r))) closefd(fd) extendRandom(r, int(n)) } //--to // Use getRandomData in os_plan9.go. //go:nosplit func getRandomData(r []byte) { // inspired by wyrand see hash32.go for detail t := nanotime() v := getg().m.procid ^ uint64(t) for len(r) > 0 { v ^= 0xa0761d6478bd642f v *= 0xe7037ed1a0b428db size := 8 if len(r) < 8 { size = len(r) } for i := 0; i < size; i++ { r[i] = byte(v >> (8 * i)) } r = r[size:] v = v>>32 | v<<32 } } //--from func gettid() uint32 //--to //go:nosplit //go:cgo_unsafe_args func gettid() (tid uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(gettid_trampoline)), unsafe.Pointer(&tid)) return } func gettid_trampoline() uint32 //--from //go:noescape func sigaltstack(new, old *stackt) //--to func sigaltstack(new, old *stackt) { // Do nothing. } //--from func sigprocmask(how int32, new, old *sigset) { rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--to func sigprocmask(how int32, new, old *sigset) { // Do nothing. // rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--from func raise(sig uint32) //--to func raise(sig uint32) { // Do nothing } //--from func raiseproc(sig uint32) //--to func raiseproc(sig uint32) { // Do nothing } //--from //go:noescape func sched_getaffinity(pid, len uintptr, buf *byte) int32 //--to //go:nosplit //go:cgo_unsafe_args func sched_getaffinity(pid, len uintptr, buf *byte) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(sched_getaffinity_trampoline)), unsafe.Pointer(&pid)) } func sched_getaffinity_trampoline(pid, len uintptr, buf *byte) int32 //--from func osyield() //--to //go:nosplit //go:cgo_unsafe_args func osyield() { libcCall(unsafe.Pointer(abi.FuncPCABI0(osyield_trampoline)), nil) } func osyield_trampoline() //--from func sysSigaction(sig uint32, new, old *sigactiont) { //--to func sysSigaction(sig uint32, new, old *sigactiont) { // Do nothing. return //--from func signalM(mp *m, sig int) { tgkill(getpid(), int(mp.procid), sig) } //--to func signalM(mp *m, sig int) { // Do nothiing. } //--from func runPerThreadSyscall() { gp := getg() if gp.m.needPerThreadSyscall.Load() == 0 { return } args := perThreadSyscall r1, r2, errno := syscall.Syscall6(args.trap, args.a1, args.a2, args.a3, args.a4, args.a5, args.a6) if GOARCH == "ppc64" || GOARCH == "ppc64le" { // TODO(https://go.dev/issue/51192 ): ppc64 doesn't use r2. r2 = 0 } if errno != 0 || r1 != args.r1 || r2 != args.r2 { print("trap:", args.trap, ", a123456=[", args.a1, ",", args.a2, ",", args.a3, ",", args.a4, ",", args.a5, ",", args.a6, "]\n") print("results: got {r1=", r1, ",r2=", r2, ",errno=", errno, "}, want {r1=", args.r1, ",r2=", args.r2, ",errno=0}\n") fatal("AllThreadsSyscall6 results differ between threads; runtime corrupted") } gp.m.needPerThreadSyscall.Store(0) } //--to func runPerThreadSyscall() { // Do nothing. // needPerThreadSyscall should never be 1 as syscall_runtime_doAllThreadsSyscall is not available with Cgo. } //--append //go:linkname hitsumabushi_closefd hitsumabushi_closefd //go:cgo_import_static hitsumabushi_closefd var hitsumabushi_closefd byte //go:linkname hitsumabushi_exit hitsumabushi_exit //go:cgo_import_static hitsumabushi_exit var hitsumabushi_exit byte //go:linkname hitsumabushi_gettid hitsumabushi_gettid //go:cgo_import_static hitsumabushi_gettid var hitsumabushi_gettid byte //go:linkname hitsumabushi_nanotime1 hitsumabushi_nanotime1 //go:cgo_import_static hitsumabushi_nanotime1 var hitsumabushi_nanotime1 byte //go:linkname hitsumabushi_open hitsumabushi_open //go:cgo_import_static hitsumabushi_open var hitsumabushi_open byte //go:linkname hitsumabushi_osyield hitsumabushi_osyield //go:cgo_import_static hitsumabushi_osyield var hitsumabushi_osyield byte //go:linkname hitsumabushi_read hitsumabushi_read //go:cgo_import_static hitsumabushi_read var hitsumabushi_read byte //go:linkname hitsumabushi_sched_getaffinity hitsumabushi_sched_getaffinity //go:cgo_import_static hitsumabushi_sched_getaffinity var hitsumabushi_sched_getaffinity byte //go:linkname hitsumabushi_usleep hitsumabushi_usleep //go:cgo_import_static hitsumabushi_usleep var hitsumabushi_usleep byte //go:linkname hitsumabushi_walltime1 hitsumabushi_walltime1 //go:cgo_import_static hitsumabushi_walltime1 var hitsumabushi_walltime1 byte //go:linkname hitsumabushi_write1 hitsumabushi_write1 //go:cgo_import_static hitsumabushi_write1 var hitsumabushi_write1 byte //go:nosplit //go:cgo_unsafe_args func fcntl1(fd, cmd, arg int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fcntl_trampoline)), unsafe.Pointer(&fd)) } func fcntl_trampoline() //go:nosplit //go:cgo_unsafe_args func fstat1(fd int, stat unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstat_trampoline)), unsafe.Pointer(&fd)) } func fstat_trampoline(fd int, stat unsafe.Pointer) int32 //go:nosplit //go:cgo_unsafe_args func lseek1(fd int, offset int64, whence int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(lseek_trampoline)), unsafe.Pointer(&fd)) } func lseek_trampoline() //go:nosplit //go:cgo_unsafe_args func renameat(fd1 int, name1 unsafe.Pointer, fd2 int, name2 unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(renameat_trampoline)), unsafe.Pointer(&fd1)) } func renameat_trampoline() //go:nosplit //go:cgo_unsafe_args func fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstatat_trampoline)), unsafe.Pointer(&fd)) } func fstatat_trampoline() ================================================ FILE: 1.21_linux/runtime/panicnil_test.go.patch ================================================ //--from func TestPanicNil(t *testing.T) { //--to func TestPanicNil(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.21_linux/runtime/proc_test.go.patch ================================================ //--from func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) testGoroutineParallelism2(t, false, true) testGoroutineParallelism2(t, true, true) } //--to func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) //testGoroutineParallelism2(t, false, true) //testGoroutineParallelism2(t, true, true) } ================================================ FILE: 1.21_linux/runtime/runtime1.go.patch ================================================ //--from func argv_index(argv **byte, i int32) *byte { return *(**byte)(add(unsafe.Pointer(argv), uintptr(i)*goarch.PtrSize)) } //--to func argv_index(argv **byte, i int32) *byte { return nil } //--from func args(c int32, v **byte) { argc = c argv = v sysargs(c, v) } //--to func args(c int32, v **byte) { // In the original code, physPageSize is determined at sysargs. // Hitsumabushi gives an initial value for physPageSize at its declaration, so sysargs doesn't have to be called. } //--append // Expose the entry point for some special environments. //go:cgo_export_static _rt0_amd64_linux_lib //go:cgo_export_dynamic _rt0_amd64_linux_lib ================================================ FILE: 1.21_linux/runtime/runtime_linux_test.go.patch ================================================ //--from func TestMincoreErrorSign(t *testing.T) { //--to func TestMincoreErrorSign(t *testing.T) { t.Skip("mincore is not supported in this environment") ================================================ FILE: 1.21_linux/runtime/runtime_mmap_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.21_linux/runtime/runtime_test.go.patch ================================================ //--from func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { //--to func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { t.Skip("catching faults is not supported in this environment") ================================================ FILE: 1.21_linux/runtime/runtime_unix_test.go.patch ================================================ //--from //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || plan9 //--to //go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || plan9 ================================================ FILE: 1.21_linux/runtime/stack_test.go.patch ================================================ //--from func TestDeferLeafSigpanic(t *testing.T) { //--to func TestDeferLeafSigpanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestStackWrapperStackPanic(t *testing.T) { //--to func TestStackWrapperStackPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.21_linux/runtime/stubs2.go.patch ================================================ //--from import ( "runtime/internal/atomic" "unsafe" ) //--to import ( "internal/abi" "runtime/internal/atomic" "unsafe" ) //--from func read(fd int32, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func read(fd int32, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(read_trampoline)), unsafe.Pointer(&fd)) } func read_trampoline(fd int32, p unsafe.Pointer, n int32) int32 //--from func closefd(fd int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func closefd(fd int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(closefd_trampoline)), unsafe.Pointer(&fd)) } func closefd_trampoline(fd int32) int32 //--from func exit(code int32) //--to //go:nosplit //go:cgo_unsafe_args func exit(code int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(exit_trampoline)), unsafe.Pointer(&code)) } func exit_trampoline(code int32) //--from func usleep(usec uint32) //--to //go:nosplit //go:cgo_unsafe_args func usleep(usec uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } func usleep_trampoline(usec uint32) //--from //go:nosplit func usleep_no_g(usec uint32) { usleep(usec) } //--to //go:nosplit //go:cgo_unsafe_args func usleep_no_g(usec uint32) { asmcgocall_no_g(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } //--from //go:noescape func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func write1(fd uintptr, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(write1_trampoline)), unsafe.Pointer(&fd)) } func write1_trampoline(fd uintptr, p unsafe.Pointer, n int32) int32 //--from //go:noescape func open(name *byte, mode, perm int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func open(name *byte, mode, perm int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(open_trampoline)), unsafe.Pointer(&name)) } func open_trampoline(name *byte, mode, perm int32) int32 ================================================ FILE: 1.21_linux/runtime/stubs3.go.patch ================================================ //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func nanotime1() int64 //--to //go:nosplit //go:cgo_unsafe_args func nanotime1() (now int64) { libcCall(unsafe.Pointer(abi.FuncPCABI0(nanotime1_trampoline)), unsafe.Pointer(&now)) return } func nanotime1_trampoline() int64 ================================================ FILE: 1.21_linux/runtime/sys_libc.go.patch ================================================ //--from //go:build darwin || (openbsd && !mips64) //--to //go:build darwin || (openbsd && !mips64) || linux ================================================ FILE: 1.21_linux/runtime/sys_linux_amd64.s.patch ================================================ //--from TEXT runtime·open(SB),NOSPLIT,$0-20 // This uses openat instead of open, because Android O blocks open. MOVL $AT_FDCWD, DI // AT_FDCWD, so this acts like open MOVQ name+0(FP), SI MOVL mode+8(FP), DX MOVL perm+12(FP), R10 MOVL $SYS_openat, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVL 8(DI), SI // arg 2 flags MOVL 12(DI), DX // arg 3 mode MOVQ 0(DI), DI // arg 1 pathname XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_open(SB) MOVQ AX, 16(BX) POPQ BP RET //--from TEXT runtime·futex(SB),NOSPLIT,$0 MOVQ addr+0(FP), DI MOVL op+8(FP), SI MOVL val+12(FP), DX MOVQ ts+16(FP), R10 MOVQ addr2+24(FP), R8 MOVL val3+32(FP), R9 MOVL $SYS_futex, AX SYSCALL MOVL AX, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 addr MOVL 8(BX), SI // arg 2 op MOVL 12(BX), DX // arg 3 val MOVQ 16(BX), CX // arg 4 ts MOVQ 24(BX), R8 // arg 5 addr2 MOVL 32(BX), R9 // arg 6 val3 CALL hitsumabushi_futex(SB) MOVL AX, 40(BX) POPQ BP RET //--from TEXT runtime·exit(SB),NOSPLIT,$0-4 MOVL code+0(FP), DI MOVL $SYS_exit_group, AX SYSCALL RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 exit status CALL hitsumabushi_exit(SB) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·read(SB),NOSPLIT,$0-28 MOVL fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_read, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 0(BX), DI // arg 1 fd MOVQ 8(BX), SI // arg 2 buf MOVQ 16(BX), DX // arg 3 count CALL hitsumabushi_read(SB) MOVQ AX, 24(BX) // return value POPQ BP RET //--from TEXT runtime·closefd(SB),NOSPLIT,$0-12 MOVL fd+0(FP), DI MOVL $SYS_close, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 fd CALL hitsumabushi_closefd(SB) POPQ BP RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVL $SYS_gettid, AX SYSCALL MOVL AX, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_gettid(SB) POPQ BP RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT,$0 MOVQ new+0(FP), DI MOVQ old+8(FP), SI MOVQ $SYS_sigaltstack, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $0xf1, 0xf1 // crash RET //--to TEXT runtime·sigaltstack_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 old MOVQ 0(DI), DI // arg 1 new CALL hitsumabushi_sigaltstack(SB) TESTQ AX, AX JEQ 2(PC) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·raise(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, R12 MOVL $SYS_gettid, AX SYSCALL MOVL AX, SI // arg 2 tid MOVL R12, DI // arg 1 pid MOVL sig+0(FP), DX // arg 3 MOVL $SYS_tgkill, AX SYSCALL RET //--to TEXT runtime·raise_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 signal CALL hitsumabushi_raise(SB) POPQ BP RET //--from TEXT runtime·raiseproc(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, DI // arg 1 pid MOVL sig+0(FP), SI // arg 2 MOVL $SYS_kill, AX SYSCALL RET //--to TEXT runtime·raiseproc_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), BX // signal CALL hitsumabushi_getpid(SB) MOVL AX, DI // arg 1 pid MOVL BX, SI // arg 2 signal CALL hitsumabushi_kill(SB) POPQ BP RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0 MOVQ pid+0(FP), DI MOVQ len+8(FP), SI MOVQ buf+16(FP), DX MOVL $SYS_sched_getaffinity, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 len MOVQ 16(DI), DX // arg 3 buf MOVQ 0(DI), DI // arg 1 pid CALL hitsumabushi_sched_getaffinity(SB) POPQ BP RET //--from TEXT runtime·osyield(SB),NOSPLIT,$0 MOVL $SYS_sched_yield, AX SYSCALL RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_osyield(SB) POPQ BP RET //--from TEXT runtime·usleep(SB),NOSPLIT,$16 MOVL $0, DX MOVL usec+0(FP), AX MOVL $1000000, CX DIVL CX MOVQ AX, 0(SP) MOVL $1000, AX // usec to nsec MULL DX MOVQ AX, 8(SP) // nanosleep(&ts, 0) MOVQ SP, DI MOVL $0, SI MOVL $SYS_nanosleep, AX SYSCALL RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 usec CALL hitsumabushi_usleep(SB) POPQ BP RET //--from TEXT runtime·write1(SB),NOSPLIT,$0-28 MOVQ fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_write, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 p MOVQ 16(DI), DX // arg 3 n MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_write1(SB) POPQ BP RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$16-8 // We don't know how much stack space the VDSO code will need, // so switch to g0. // In particular, a kernel configured with CONFIG_OPTIMIZE_INLINING=n // and hardening can use a full page of stack space in gettime_sym // due to stack probes inserted to avoid stack/heap collisions. // See issue #20427. MOVQ SP, R12 // Save old SP; R12 unchanged by C code. MOVQ g_m(R14), BX // BX unchanged by C code. // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVQ m_vdsoPC(BX), CX MOVQ m_vdsoSP(BX), DX MOVQ CX, 0(SP) MOVQ DX, 8(SP) LEAQ ret+0(FP), DX MOVQ -8(DX), CX MOVQ CX, m_vdsoPC(BX) MOVQ DX, m_vdsoSP(BX) CMPQ R14, m_curg(BX) // Only switch if on curg. JNE noswitch MOVQ m_g0(BX), DX MOVQ (g_sched+gobuf_sp)(DX), SP // Set SP to g0 stack noswitch: SUBQ $16, SP // Space for results ANDQ $~15, SP // Align for C code MOVL $1, DI // CLOCK_MONOTONIC LEAQ 0(SP), SI MOVQ runtime·vdsoClockgettimeSym(SB), AX CMPQ AX, $0 JEQ fallback CALL AX ret: MOVQ 0(SP), AX // sec MOVQ 8(SP), DX // nsec MOVQ R12, SP // Restore real SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVQ 8(SP), CX MOVQ CX, m_vdsoSP(BX) MOVQ 0(SP), CX MOVQ CX, m_vdsoPC(BX) // sec is in AX, nsec in DX // return nsec in AX IMULQ $1000000000, AX ADDQ DX, AX MOVQ AX, ret+0(FP) RET fallback: MOVQ $SYS_clock_gettime, AX SYSCALL JMP ret //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ DI, BX // BX is callee-saved MOVQ SP, BP CALL hitsumabushi_nanotime1(SB) MOVQ AX, 0(BX) POPQ BP RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(DI), DI CALL hitsumabushi_sysAllocOS(SB) MOVQ AX, 8(BX) POPQ BP RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUnusedOS(SB) POPQ BP RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUsedOS(SB) POPQ BP RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysHugePageOS(SB) POPQ BP RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFreeOS(SB) POPQ BP RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFaultOS(SB) POPQ BP RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysReserveOS(SB) MOVQ AX, 16(BX) POPQ BP RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysMapOS(SB) POPQ BP RET TEXT runtime·walltime1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_walltime1(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 cmd MOVQ 16(DI), DX // arg 3 arg MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_fcntl(SB) POPQ BP RET TEXT runtime·fstat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 stat MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_fstat(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·lseek_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 offset MOVQ 16(DI), DX // arg 3 whence MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_lseek(SB) MOVQ AX, 24(BX) // return value POPQ BP RET TEXT runtime·renameat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_renameat(SB) MOVL AX, 32(BX) POPQ BP RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_fstatat(SB) MOVL AX, 32(BX) POPQ BP RET ================================================ FILE: 1.21_linux/runtime/sys_linux_arm64.s.patch ================================================ //--from #define SYS_exit 93 #define SYS_read 63 #define SYS_write 64 #define SYS_openat 56 #define SYS_close 57 #define SYS_pipe2 59 #define SYS_nanosleep 101 #define SYS_mmap 222 #define SYS_munmap 215 #define SYS_setitimer 103 #define SYS_clone 220 #define SYS_sched_yield 124 #define SYS_rt_sigreturn 139 #define SYS_rt_sigaction 134 #define SYS_rt_sigprocmask 135 #define SYS_sigaltstack 132 #define SYS_madvise 233 #define SYS_mincore 232 #define SYS_getpid 172 #define SYS_gettid 178 #define SYS_kill 129 #define SYS_tgkill 131 #define SYS_futex 98 #define SYS_sched_getaffinity 123 #define SYS_exit_group 94 #define SYS_clock_gettime 113 #define SYS_faccessat 48 #define SYS_socket 198 #define SYS_connect 203 #define SYS_brk 214 #define SYS_timer_create 107 #define SYS_timer_settime 110 #define SYS_timer_delete 111 //--to #define SYS_exit 2147483647 #define SYS_read 2147483647 #define SYS_write 2147483647 #define SYS_openat 2147483647 #define SYS_close 2147483647 #define SYS_pipe2 2147483647 #define SYS_nanosleep 2147483647 #define SYS_mmap 2147483647 #define SYS_munmap 2147483647 #define SYS_setitimer 2147483647 #define SYS_clone 2147483647 #define SYS_sched_yield 2147483647 #define SYS_rt_sigreturn 2147483647 #define SYS_rt_sigaction 2147483647 #define SYS_rt_sigprocmask 2147483647 #define SYS_sigaltstack 2147483647 #define SYS_madvise 2147483647 #define SYS_mincore 2147483647 #define SYS_getpid 2147483647 #define SYS_gettid 2147483647 #define SYS_kill 2147483647 #define SYS_tgkill 2147483647 #define SYS_futex 2147483647 #define SYS_sched_getaffinity 2147483647 #define SYS_exit_group 2147483647 #define SYS_clock_gettime 2147483647 #define SYS_faccessat 2147483647 #define SYS_socket 2147483647 #define SYS_connect 2147483647 #define SYS_brk 2147483647 #define SYS_timer_create 2147483647 #define SYS_timer_settime 2147483647 #define SYS_timer_delete 2147483647 //--from TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0-4 MOVW code+0(FP), R0 MOVD $SYS_exit_group, R8 SVC RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_exit(SB) RET //--from TEXT runtime·open(SB),NOSPLIT|NOFRAME,$0-20 MOVD $AT_FDCWD, R0 MOVD name+0(FP), R1 MOVW mode+8(FP), R2 MOVW perm+12(FP), R3 MOVD $SYS_openat, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_open(SB) RET //--from TEXT runtime·closefd(SB),NOSPLIT|NOFRAME,$0-12 MOVW fd+0(FP), R0 MOVD $SYS_close, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT,$0-12 MOVW 0(R0), R0 BL hitsumabushi_closefd(SB) RET //--from TEXT runtime·write1(SB),NOSPLIT|NOFRAME,$0-28 MOVD fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_write, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_write1(SB) RET //--from TEXT runtime·read(SB),NOSPLIT|NOFRAME,$0-28 MOVW fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_read, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_read(SB) RET //--from TEXT runtime·usleep(SB),NOSPLIT,$24-4 MOVWU usec+0(FP), R3 MOVD R3, R5 MOVW $1000000, R4 UDIV R4, R3 MOVD R3, 8(RSP) MUL R3, R4 SUB R4, R5 MOVW $1000, R4 MUL R4, R5 MOVD R5, 16(RSP) // nanosleep(&ts, 0) ADD $8, RSP, R0 MOVD $0, R1 MOVD $SYS_nanosleep, R8 SVC RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_usleep(SB) RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVD $SYS_gettid, R8 SVC MOVW R0, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_gettid(SB) MOVW R0, 0(R19) // return value RET //--from TEXT runtime·raise(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R19 MOVD $SYS_gettid, R8 SVC MOVW R0, R1 // arg 2 tid MOVW R19, R0 // arg 1 pid MOVW sig+0(FP), R2 // arg 3 MOVD $SYS_tgkill, R8 SVC RET //--to //--from TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R0 // arg 1 pid MOVW sig+0(FP), R1 // arg 2 MOVD $SYS_kill, R8 SVC RET //--to //--from TEXT runtime·walltime(SB),NOSPLIT,$24-12 MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $16, R1 BIC $15, R1 // Align for C code MOVD R1, RSP MOVW $CLOCK_REALTIME, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) MOVD R3, sec+0(FP) MOVW R5, nsec+8(FP) RET //--to TEXT runtime·walltime1_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_walltime1(SB) RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$24-8 MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $32, R1 BIC $15, R1 MOVD R1, RSP MOVW $CLOCK_MONOTONIC, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) // sec is in R3, nsec in R5 // return nsec in R3 MOVD $1000000000, R4 MUL R4, R3 ADD R5, R3 MOVD R3, ret+0(FP) RET //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_nanotime1(SB) MOVD R0, 0(R19) // return value RET //--from TEXT runtime·futex(SB),NOSPLIT|NOFRAME,$0 MOVD addr+0(FP), R0 MOVW op+8(FP), R1 MOVW val+12(FP), R2 MOVD ts+16(FP), R3 MOVD addr2+24(FP), R4 MOVW val3+32(FP), R5 MOVD $SYS_futex, R8 SVC MOVW R0, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 16(R0), R3 MOVD 24(R0), R4 MOVW 32(R0), R5 MOVD 0(R0), R0 BL hitsumabushi_futex(SB) RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT|NOFRAME,$0 MOVD new+0(FP), R0 MOVD old+8(FP), R1 MOVD $SYS_sigaltstack, R8 SVC CMN $4095, R0 BCC ok MOVD $0, R0 MOVD R0, (R0) // crash ok: RET //--to //--from TEXT runtime·osyield(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_sched_yield, R8 SVC RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT,$0 BL hitsumabushi_osyield(SB) RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT|NOFRAME,$0 MOVD pid+0(FP), R0 MOVD len+8(FP), R1 MOVD buf+16(FP), R2 MOVD $SYS_sched_getaffinity, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVD 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_sched_getaffinity(SB) RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 0(R0), R0 BL hitsumabushi_sysAllocOS(SB) MOVD R0, 8(R19) // return value RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUnusedOS(SB) RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUsedOS(SB) RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysHugePageOS(SB) RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFreeOS(SB) RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFaultOS(SB) RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysReserveOS(SB) MOVD R0, 16(R19) // return value RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysMapOS(SB) RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVW 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_fcntl(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·fstat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 0(R0), R0 BL hitsumabushi_fstat(SB) MOVW R0, 16(R19) // return value RET TEXT runtime·lseek_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_lseek(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·renameat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_renameat(SB) MOVW R0, 32(R19) // return value RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_fstatat(SB) MOVW R0, 32(R19) // return value RET ================================================ FILE: 1.21_linux/runtime/time_linux_amd64.s.patch ================================================ //--from //go:build !faketime //--to //go:build ignore ================================================ FILE: 1.21_linux/runtime/timeasm.go.patch ================================================ //--from //go:build !faketime && (windows || (linux && amd64)) //--to //go:build !faketime && windows ================================================ FILE: 1.21_linux/runtime/timestub.go.patch ================================================ //--from //go:build !faketime && !windows && !(linux && amd64) //--to //go:build !faketime && !windows ================================================ FILE: 1.21_linux/runtime/timestub2.go.patch ================================================ //--from //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !wasip1 && !windows && !(linux && amd64) //--to //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !wasip1 && !windows //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func walltime() (sec int64, nsec int32) //--to func walltime() (sec int64, nsec int32) { walltime1(&sec, &nsec) return } //go:nosplit //go:cgo_unsafe_args func walltime1(sec *int64, nsec *int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(walltime1_trampoline)), unsafe.Pointer(&sec)) } func walltime1_trampoline(sec *int64, nsec *int32) ================================================ FILE: 1.21_linux/runtime/traceback_test.go.patch ================================================ //--from func TestTracebackInlined(t *testing.T) { //--to func TestTracebackInlined(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.21_linux/strconv/fp_test.go.patch ================================================ //--from func TestFp(t *testing.T) { //--to func TestFp(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.21_linux/sync/atomic/atomic_test.go.patch ================================================ //--from func TestStoreLoadSeqCst32(t *testing.T) { //--to func TestStoreLoadSeqCst32(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") //--from func TestStoreLoadSeqCst64(t *testing.T) { //--to func TestStoreLoadSeqCst64(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") //--from func TestNilDeref(t *testing.T) { //--to func TestNilDeref(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.21_linux/syscall/hitsumabushi_stubs_linux_amd64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_FSTATAT = 0xffffffffffffffff // Stub: on amd64 Go uses SYS_NEWFSTATAT instead ) ================================================ FILE: 1.21_linux/syscall/hitsumabushi_stubs_linux_arm64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_NEWFSTATAT = 0xffffffffffffffff // Stub: on arm64 Go uses SYS_FSTATAT instead ) ================================================ FILE: 1.21_linux/syscall/rlimit.go.patch ================================================ //--from func init() { var lim Rlimit if err := Getrlimit(RLIMIT_NOFILE, &lim); err == nil && lim.Cur != lim.Max { origRlimitNofile.Store(lim) lim.Cur = lim.Max adjustFileLimit(&lim) setrlimit(RLIMIT_NOFILE, &lim) } } //--to func init() { } ================================================ FILE: 1.21_linux/syscall/syscall_linux.go.patch ================================================ //--from func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { return RawSyscall6(trap, a1, a2, a3, 0, 0, 0) } //--to func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { println("not implemented syscall at RawSyscall", trap) panic("syscall.RawSyscall") return 0, 0, ENOSYS } //--from func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() // N.B. Calling RawSyscall here is unsafe with atomic coverage // instrumentation and race mode. // // Coverage instrumentation will add a sync/atomic call to RawSyscall. // Race mode will add race instrumentation to sync/atomic. Race // instrumentation requires a P, which we no longer have. // // RawSyscall6 is fine because it is implemented in assembly and thus // has no coverage instrumentation. // // This is typically not a problem in the runtime because cmd/go avoids // adding coverage instrumentation to the runtime in race mode. r1, r2, err = RawSyscall6(trap, a1, a2, a3, 0, 0, 0) runtime_exitsyscall() return } //--to func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FCNTL: r = fcntl1(a1, a2, a3) case SYS_FSTAT: r = fstat1(a1, unsafe.Pointer(a2)) case SYS_READ: r = runtime_read(uintptr(a1), unsafe.Pointer(a2), int32(a3)) case SYS_WRITE: r = write1(a1, unsafe.Pointer(a2), int32(a3)) case SYS_LSEEK: r = lseek1(a1, int64(a2), int32(a3)) case SYS_CLOSE: r = runtime_closefd(int32(a1)) case SYS_MKDIRAT: println("syscall mkdirat() is not implemented") // Default to permission denied. TODO: implement this return 0, 0, EPERM case SYS_GETDENTS64: println("syscall getdents64() is not implemented") // Default to empty directory. TODO: implement this return 0, 0, 0 default: println("unimplemented syscall at runtime.Syscall", trap) panic("syscall.Syscall") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //go:linkname open runtime.open func open(name *byte, mode, perm int32) int32 //go:linkname write1 runtime.write1 func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname fcntl1 runtime.fcntl1 func fcntl1(fd uintptr, a uintptr, b uintptr) int32 //go:linkname fstat1 runtime.fstat1 func fstat1(fd uintptr, p unsafe.Pointer) int32 //go:linkname lseek1 runtime.lseek1 func lseek1(fd uintptr, offset int64, whence int32) int32 //go:linkname runtime_read runtime.read func runtime_read(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname runtime_closefd runtime.closefd func runtime_closefd(fd int32) int32 //go:linkname runtime_fstatat runtime.fstatat func runtime_fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 //go:linkname runtime_renameat runtime.renameat func runtime_renameat(fd1 uintptr, name1 unsafe.Pointer, fd2 uintptr, name2 unsafe.Pointer) int32 //--from func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() r1, r2, err = RawSyscall6(trap, a1, a2, a3, a4, a5, a6) runtime_exitsyscall() return } //--to func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FSTATAT, SYS_NEWFSTATAT: r = runtime_fstatat(uintptr(a1), unsafe.Pointer(a2), unsafe.Pointer(a3), int32(a4)) case SYS_RENAMEAT: r = runtime_renameat(uintptr(a1), unsafe.Pointer(a2), uintptr(a3), unsafe.Pointer(a4)) default: println("unimplemented syscall at runtime.Syscall6", trap) panic("syscall.Syscall6") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //--from func Open(path string, mode int, perm uint32) (fd int, err error) { return openat(_AT_FDCWD, path, mode|O_LARGEFILE, perm) } //--to func Open(path string, mode int, perm uint32) (fd int, err error) { p0, err := BytePtrFromString(path) if err != nil { return -1, errnoErr(EINVAL) } fd = int(open(p0, int32(mode|O_LARGEFILE), int32(perm))) if fd < 0 { return -1, errnoErr(ENOENT) } return } ================================================ FILE: 1.21_linux/testing/run_example.go ================================================ package testing func runExample(eg InternalExample) (ok bool) { // Do nothing. // TODO: Implement os.Pipe2 and use this here. return true } ================================================ FILE: 1.21_linux/time/format_test.go.patch ================================================ //--from func TestParseInLocation(t *testing.T) { //--to func TestParseInLocation(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationZipFile(t *testing.T) { //--to func TestLoadLocationZipFile(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.21_linux/time/internal_test.go.patch ================================================ //--from func initTestingZone() { // For hermeticity, use only tzinfo source from the test's GOROOT, // not the system sources and not whatever GOROOT may happen to be // set in the process's environment (if any). // This test runs in GOROOT/src/time, so GOROOT is "../..", // but it is theoretically possible sources := []string{"../../lib/time/zoneinfo.zip"} z, err := loadLocation("America/Los_Angeles", sources) if err != nil { panic("cannot load America/Los_Angeles for testing: " + err.Error() + "; you may want to use -tags=timetzdata") } z.name = "Local" localLoc = *z } //--to func initTestingZone() { // Data from the playground. // https://go.dev/play/p/VGXU57KZZ-x // name is replaced with "Local". // cachStart, cacheEnd, and cacheZone are removed. localLoc = Location{name:"Local",zone:[]zone{zone{name:"LMT", offset:-28378, isDST:false}, zone{name:"PDT", offset:-25200, isDST:true}, zone{name:"PST", offset:-28800, isDST:false}, zone{name:"PWT", offset:-25200, isDST:true}, zone{name:"PPT", offset:-25200, isDST:true}}, tx:[]zoneTrans{zoneTrans{when:-576460752303423488, index:0x0, isstd:false, isutc:false}, zoneTrans{when:-2717640000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1633269600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-1615129200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1601820000, index:0x1, isstd:true, isutc:true}, zoneTrans{when:-1583679600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-880207200, index:0x3, isstd:false, isutc:false}, zoneTrans{when:-769395600, index:0x4, isstd:false, isutc:false}, zoneTrans{when:-765385200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-687967140, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-662655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-620838000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-608137200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-589388400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-576082800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-557938800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-544633200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-526489200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-513183600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-495039600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-481734000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-463590000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-450284400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-431535600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-418230000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-400086000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-386780400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-368636400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-355330800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-337186800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-323881200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-305737200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-292431600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-273682800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-260982000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-242233200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-226508400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-210783600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-195058800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-179334000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-163609200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-147884400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-131554800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-116434800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-100105200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-84376800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-68655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-52927200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-37206000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-21477600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-5756400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:9972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:25693200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:41421600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:57747600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:73476000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:89197200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:104925600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:120646800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:126698400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:152096400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:162381600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:183546000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:199274400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:215600400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:230724000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:247050000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:262778400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:278499600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:294228000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:309949200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:325677600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:341398800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:357127200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:372848400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:388576800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:404902800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:420026400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:436352400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:452080800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:467802000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:483530400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:499251600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:514980000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:530701200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:544615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:562150800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:576064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:594205200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:607514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:625654800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:638964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:657104400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:671018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:688554000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:702468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:720003600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:733917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:752058000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:765367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:783507600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:796816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:814957200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:828871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:846406800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:860320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:877856400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:891770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:909306000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:923220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:941360400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:954669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:972810000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:986119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1004259600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1018173600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1035709200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1049623200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1067158800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1081072800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1099213200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1112522400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1130662800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1143972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1162112400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1173607200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1194166800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1205056800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1225616400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1236506400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1257066000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1268560800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1289120400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1300010400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1320570000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1331460000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1352019600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1362909600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1383469200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1394359200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1414918800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1425808800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1446368400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1457863200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1478422800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1489312800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1509872400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1520762400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1541322000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1552212000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1572771600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1583661600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1604221200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1615716000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1636275600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1647165600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1667725200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1678615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1699174800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1710064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1730624400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1741514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1762074000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1772964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1793523600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1805018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1825578000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1836468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1857027600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1867917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1888477200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1899367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1919926800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1930816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1951376400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1962871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1983430800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1994320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2014880400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2025770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2046330000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2057220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2077779600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2088669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2109229200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2120119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2140678800, index:0x2, isstd:false, isutc:false}}, extend:"PST8PDT,M3.2.0,M11.1.0"} } ================================================ FILE: 1.21_linux/time/sleep_test.go.patch ================================================ //--from func TestSleep(t *testing.T) { //--to func TestSleep(t *testing.T) { t.Skip("Interrupt (syscall.Kill) is not supported in this environment") //--from func TestIssue5745(t *testing.T) { //--to func TestIssue5745(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.21_linux/time/time_test.go.patch ================================================ //--from func TestLoadFixed(t *testing.T) { //--to func TestLoadFixed(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestTimeIsDST(t *testing.T) { //--to func TestTimeIsDST(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestTimeWithZoneTransition(t *testing.T) { //--to func TestTimeWithZoneTransition(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestMarshalBinaryVersion2(t *testing.T) { //--to func TestMarshalBinaryVersion2(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.21_linux/time/tzdata_test.go.patch ================================================ //--from func TestEmbeddedTZData(t *testing.T) { //--to func TestEmbeddedTZData(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.21_linux/time/zoneinfo_test.go.patch ================================================ //--from func TestEnvVarUsage(t *testing.T) { //--to func TestEnvVarUsage(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestBadLocationErrMsg(t *testing.T) { //--to func TestBadLocationErrMsg(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestVersion3(t *testing.T) { //--to func TestVersion3(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestFirstZone(t *testing.T) { //--to func TestFirstZone(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationFromTZData(t *testing.T) { //--to func TestLoadLocationFromTZData(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestEarlyLocation(t *testing.T) { //--to func TestEarlyLocation(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationFromTZDataSlim(t *testing.T) { //--to func TestLoadLocationFromTZDataSlim(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.21_linux/time/zoneinfo_unix.go.patch ================================================ //--from import ( "syscall" ) //--to //--from func initLocal() { // consult $TZ to find the time zone to use. // no $TZ means use the system default /etc/localtime. // $TZ="" means use UTC. // $TZ="foo" or $TZ=":foo" if foo is an absolute path, then the file pointed // by foo will be used to initialize timezone; otherwise, file // /usr/share/zoneinfo/foo will be used. tz, ok := syscall.Getenv("TZ") switch { case !ok: z, err := loadLocation("localtime", []string{"/etc"}) if err == nil { localLoc = *z localLoc.name = "Local" return } case tz != "": if tz[0] == ':' { tz = tz[1:] } if tz != "" && tz[0] == '/' { if z, err := loadLocation(tz, []string{""}); err == nil { localLoc = *z if tz == "/etc/localtime" { localLoc.name = "Local" } else { localLoc.name = tz } return } } else if tz != "" && tz != "UTC" { if z, err := loadLocation(tz, platformZoneSources); err == nil { localLoc = *z return } } } // Fall back to UTC. localLoc.name = "UTC" } //--to func initLocal() { localLoc.name = "UTC" } ================================================ FILE: 1.21_linux/time/zoneinfo_unix_test.go.patch ================================================ //--from func TestEnvTZUsage(t *testing.T) { //--to func TestEnvTZUsage(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.21_windows/runtime/abi_test.go.patch ================================================ //--from func TestFinalizerRegisterABI(t *testing.T) { //--to func TestFinalizerRegisterABI(t *testing.T) { t.Skip("creating a new process with os.Args[0] doesn't work in this environment") ================================================ FILE: 1.21_windows/runtime/cgo/gcc_windows_amd64.c.patch ================================================ //--from static void threadentry(void *v) { //--to static int getproccount() { static int proccount = 0; if (!proccount) { SYSTEM_INFO info; GetSystemInfo(&info); proccount = info.dwNumberOfProcessors; } return proccount; } static void threadentry(void *v) { SetThreadAffinityMask(GetCurrentThread(), (1<= 0x80 { isASCII = false break } } if !isASCII { var m uint32 isConsole := stdcall2(_GetConsoleMode, handle, uintptr(unsafe.Pointer(&m))) != 0 // If this is a console output, various non-unicode code pages can be in use. // Use the dedicated WriteConsole call to ensure unicode is printed correctly. if isConsole { return int32(writeConsole(handle, buf, n)) } } var written uint32 stdcall5(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--to func write1(fd uintptr, buf unsafe.Pointer, n int32) int32 { const ( _STD_OUTPUT_HANDLE = ^uintptr(10) // -11 _STD_ERROR_HANDLE = ^uintptr(11) // -12 ) var handle uintptr switch fd { case 1: handle = stdcall1(_GetStdHandle, _STD_OUTPUT_HANDLE) case 2: handle = stdcall1(_GetStdHandle, _STD_ERROR_HANDLE) default: // assume fd is real windows handle. handle = fd } if fd == 1 || fd == 2 { // Note that handle is not used anyway. return int32(writeConsole(handle, buf, n)) } var written uint32 stdcall5(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--from func writeConsoleUTF16(handle uintptr, b []uint16) { l := uint32(len(b)) if l == 0 { return } var written uint32 stdcall5(_WriteConsoleW, handle, uintptr(unsafe.Pointer(&b[0])), uintptr(l), uintptr(unsafe.Pointer(&written)), 0, ) return } //--to func writeConsoleUTF16(handle uintptr, b []uint16) { b = b[:len(b)+1] b[len(b)-1] = 0 l := uint32(len(b)) if l <= 1 { return } stdcall1(_OutputDebugStringW, uintptr(unsafe.Pointer(&b[0])), ) return } ================================================ FILE: 1.21_windows/runtime/runtime-gdb_test.go.patch ================================================ //--from package runtime_test //--to //go:build !windows package runtime_test ================================================ FILE: 1.21_windows/runtime/syscall_windows.go.patch ================================================ //--from func syscall_SyscallN(trap uintptr, args ...uintptr) (r1, r2, err uintptr) { //--to func syscall_SyscallN(trap uintptr, args ...uintptr) (r1, r2, err uintptr) { if trap == 0 { panic("trap must not be 0 at SyscallN") } ================================================ FILE: 1.21_windows/runtime/syscall_windows_test.go.patch ================================================ //--from func TestNumCPU(t *testing.T) { //--to func TestNumCPU(t *testing.T) { t.Skip("creating a new process with os.Args[0] doesn't work in this environment") ================================================ FILE: 1.21_windows/sync/mutex_test.go.patch ================================================ //--from func TestMutexMisuse(t *testing.T) { //--to func TestMutexMisuse(t *testing.T) { t.Skip("analyzing output is not supported in this environment") ================================================ FILE: 1.22_linux/internal/reflectlite/reflect_mirror_test.go.patch ================================================ //--from func TestMirrorWithReflect(t *testing.T) { //--to func TestMirrorWithReflect(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.22_linux/internal/syscall/unix/fcntl_unix.go.patch ================================================ //--from func Fcntl(fd int, cmd int, arg int) (int, error) { val, errno := fcntl(int32(fd), int32(cmd), int32(arg)) if val == -1 { return int(val), syscall.Errno(errno) } return int(val), nil } //--to func Fcntl(fd int, cmd int, arg int) (int, error) { return 0, syscall.ENOSYS } ================================================ FILE: 1.22_linux/internal/testenv/exec.go.patch ================================================ //--from func tryExec() error { //--to func tryExec() error { return fmt.Errorf("can't probe for exec support") ================================================ FILE: 1.22_linux/internal/testenv/testenv.go.patch ================================================ //--from func HasGoBuild() bool { //--to func HasGoBuild() bool { return false ================================================ FILE: 1.22_linux/internal/testenv/testenv_notunix.go.patch ================================================ //--from //go:build windows || plan9 || (js && wasm) || wasip1 //--to //go:build windows || plan9 || (js && wasm) || wasip1 || linux ================================================ FILE: 1.22_linux/internal/testenv/testenv_unix.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.22_linux/math/big/link_test.go.patch ================================================ //--from func TestLinkerGC(t *testing.T) { //--to func TestLinkerGC(t *testing.T) { t.Skip("go tools are not supported in this environment") ================================================ FILE: 1.22_linux/math/rand/default_test.go.patch ================================================ //--from func TestDefaultRace(t *testing.T) { //--to func TestDefaultRace(t *testing.T) { t.Skip("os.Getenv and creating processes are not supported in this environment") ================================================ FILE: 1.22_linux/runtime/align_test.go.patch ================================================ //--from func TestAtomicAlignment(t *testing.T) { //--to func TestAtomicAlignment(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.22_linux/runtime/callers_test.go.patch ================================================ //--from func TestCallersNilPointerPanic(t *testing.T) { //--to func TestCallersNilPointerPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestCallersDeferNilFuncPanic(t *testing.T) { //--to func TestCallersDeferNilFuncPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { //--to func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.22_linux/runtime/cgo/cgo.go.patch ================================================ //--from */ import "C" //--to #cgo !darwin LDFLAGS: -Wl,-unresolved-symbols=ignore-all #cgo darwin LDFLAGS: -Wl,-undefined,dynamic_lookup */ import "C" ================================================ FILE: 1.22_linux/runtime/cgo/gcc_linux_amd64.c.patch ================================================ //--from #include #include #include // strerror #include #include #include "libcgo.h" #include "libcgo_unix.h" //--to #include #include #include // strerror #include #include "libcgo.h" #include "libcgo_unix.h" //--from void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--to void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; pthread_t p; size_t size; int err; pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--from static void* threadentry(void *v) { //--to static void* threadentry(void *v) { extern void hitsumabushi_initializeThread(void); hitsumabushi_initializeThread(); ================================================ FILE: 1.22_linux/runtime/cgo/gcc_linux_arm64.c.patch ================================================ //--from void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--to void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 16 * 4096); // Hack for some special environments pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--from static void* threadentry(void *v) { //--to static void* threadentry(void *v) { // Note that threadentry will also be defined in gcc_linux.go in Go 1.22. extern void hitsumabushi_initializeThread(void); hitsumabushi_initializeThread(); ================================================ FILE: 1.22_linux/runtime/cgo/gcc_setenv.c.patch ================================================ //--from void x_cgo_setenv(char **arg) { _cgo_tsan_acquire(); setenv(arg[0], arg[1], 1); _cgo_tsan_release(); } //--to void x_cgo_setenv(char **arg) { } //--from void x_cgo_unsetenv(char **arg) { _cgo_tsan_acquire(); unsetenv(arg[0]); _cgo_tsan_release(); } //--to void x_cgo_unsetenv(char **arg) { } ================================================ FILE: 1.22_linux/runtime/cgo/gcc_sigaction.c.patch ================================================ //--from //go:build linux && (amd64 || arm64 || ppc64le) //--to //go:build linux && (arm64 || ppc64le) ================================================ FILE: 1.22_linux/runtime/cgo/hitsumabushi_clock_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp) { return clock_gettime(clk_id, tp); } ================================================ FILE: 1.22_linux/runtime/cgo/hitsumabushi_cpu_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int32_t hitsumabushi_getproccount() { return 1; } ================================================ FILE: 1.22_linux/runtime/cgo/hitsumabushi_filesystem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include #include #include "libcgo.h" #include "libcgo_unix.h" static const int kFDOffset = 100; typedef struct { const void* content; size_t content_size; size_t current; int32_t fd; } pseudo_file; // TODO: Do we need to protect this by mutex? static pseudo_file pseudo_files[100]; static pthread_mutex_t* pseudo_file_mutex() { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; return &mutex; } static int32_t open_pseudo_file(const void* content, size_t content_size) { pthread_mutex_lock(pseudo_file_mutex()); int index = 0; int found = 0; for (int i = 0; i < sizeof(pseudo_files) / sizeof(pseudo_file); i++) { if (pseudo_files[i].fd == 0) { index = i; found = 1; break; } } if (!found) { // Too many pseudo files are opened. pthread_mutex_unlock(pseudo_file_mutex()); return -1; } int32_t fd = index + kFDOffset; pseudo_files[index].content = content; pseudo_files[index].content_size = content_size; pseudo_files[index].current = 0; pseudo_files[index].fd = fd; pthread_mutex_unlock(pseudo_file_mutex()); return fd; } static size_t read_pseudo_file(int32_t fd, void *p, int32_t n) { pthread_mutex_lock(pseudo_file_mutex()); int32_t index = fd - kFDOffset; pseudo_file *file = &pseudo_files[index]; size_t rest = file->content_size - file->current; if (rest < n) { n = rest; } memcpy(p, file->content + file->current, n); pseudo_files[index].current += n; pthread_mutex_unlock(pseudo_file_mutex()); return n; } static void close_pseudo_file(int32_t fd) { pthread_mutex_lock(pseudo_file_mutex()); int32_t index = fd - kFDOffset; pseudo_files[index].content = NULL; pseudo_files[index].content_size = 0; pseudo_files[index].current = 0; pseudo_files[index].fd = 0; pthread_mutex_unlock(pseudo_file_mutex()); } int32_t hitsumabushi_closefd(int32_t fd) { if (fd >= kFDOffset) { close_pseudo_file(fd); return 0; } fprintf(stderr, "syscall close(%d) is not implemented\n", fd); return 0; } int32_t hitsumabushi_open(char *name, int32_t mode, int32_t perm) { if (strcmp(name, "/proc/self/auxv") == 0) { static const char auxv[] = "\x06\x00\x00\x00\x00\x00\x00\x00" // _AT_PAGESZ tag (6) "\x00\x10\x00\x00\x00\x00\x00\x00" // 4096 bytes per page "\x00\x00\x00\x00\x00\x00\x00\x00" // Dummy bytes "\x00\x00\x00\x00\x00\x00\x00\x00"; // Dummy bytes return open_pseudo_file(auxv, sizeof(auxv) / sizeof(char)); } if (strcmp(name, "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size") == 0) { static const char hpage_pmd_size[] = "\x30\x5c"; // '0', '\n' return open_pseudo_file(hpage_pmd_size, sizeof(hpage_pmd_size) / sizeof(char)); } fprintf(stderr, "syscall open(%s, %d, %d) is not implemented\n", name, mode, perm); const static int kENOENT = 0x2; return kENOENT; } int32_t hitsumabushi_read(int32_t fd, void *p, int32_t n) { if (fd >= kFDOffset) { return read_pseudo_file(fd, p, n); } fprintf(stderr, "syscall read(%d, %p, %d) is not implemented\n", fd, p, n); const static int kEBADF = 0x9; return kEBADF; } int32_t hitsumabushi_write1(uintptr_t fd, void *p, int32_t n) { static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; int32_t ret = 0; pthread_mutex_lock(&m); switch (fd) { case 1: ret = fwrite(p, 1, n, stdout); fflush(stdout); break; case 2: ret = fwrite(p, 1, n, stderr); fflush(stderr); break; default: fprintf(stderr, "syscall write(%lu, %p, %d) is not implemented\n", fd, p, n); ret = -EBADF; break; } pthread_mutex_unlock(&m); return ret; } int32_t hitsumabushi_lseek(uintptr_t fd, off_t offset, int32_t whence) { fprintf(stderr, "syscall lseek(%lu, %lu, %d) is not implemented\n", fd, offset, whence); return -ENOSYS; } int32_t hitsumabushi_fcntl(int32_t fd, int32_t cmd, int32_t arg) { if (fd == 0 || fd == 1 || fd == 2) { if (cmd == F_GETFL) { return 0; } } fprintf(stderr, "syscall fcntl(%d, %d, %d) is not implemented\n", fd, cmd, arg); return -EBADF; } int32_t hitsumabushi_fstat(int32_t fd, struct stat *stat) { fprintf(stderr, "syscall fstat(%d, %p) is not implemented\n", fd, stat); return -ENOSYS; } int32_t hitsumabushi_renameat(int32_t fd1, char* name1, int32_t fd2, char* name2) { fprintf(stderr, "syscall renameat(%d, %s, %d, %s) is not implemented\n", fd1, name1, fd2, name2); return -ENOSYS; } int32_t hitsumabushi_fstatat(int32_t fd, char* name, struct stat* p, int32_t flags) { fprintf(stderr, "syscall fstatat(%d, %s, %p, %d) is not implemented\n", fd, name, p, flags); return -ENOSYS; } ================================================ FILE: 1.22_linux/runtime/cgo/hitsumabushi_futex_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include #include #include #include static const int kPseudoFutexWait = 0; static const int kPseudoFutexWake = 1; static void pseudo_futex(uint32_t *uaddr, int mode, uint32_t val, const struct timespec *reltime) { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; struct timespec abstime; if (reltime) { // We are not sure CLOCK_REALTIME is correct or not here. // However, this time limit is actually not used as the condition variable is shared by // all the threads. Before the time limit reaches, the thread wakes up in 99.9999...% cases. clock_gettime(CLOCK_REALTIME, &abstime); abstime.tv_sec += reltime->tv_sec; abstime.tv_nsec += reltime->tv_nsec; if (1000000000 <= abstime.tv_nsec) { abstime.tv_sec += 1; abstime.tv_nsec -= 1000000000; } } int ret = pthread_mutex_lock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_lock failed: %d\n", ret); abort(); } switch (mode) { case kPseudoFutexWait: if (reltime) { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_timedwait(&cond, &mutex, &abstime); if (ret && ret != ETIMEDOUT) { fprintf(stderr, "pthread_cond_timedwait failed: %d\n", ret); abort(); } } } else { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_wait(&cond, &mutex); if (ret) { fprintf(stderr, "pthread_cond_wait failed: %d\n", ret); abort(); } } } break; case kPseudoFutexWake: if (val != 1) { fprintf(stderr, "val for waking must be 1 but %d\n", val); abort(); } // TODO: broadcasting is not efficient. Use a mutex for each uaddr. int ret = pthread_cond_broadcast(&cond); if (ret) { fprintf(stderr, "pthread_cond_broadcast failed: %d\n", ret); abort(); } break; } ret = pthread_mutex_unlock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_unlock failed: %d\n", ret); abort(); } } int32_t hitsumabushi_futex(uint32_t *uaddr, int32_t futex_op, uint32_t val, const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3) { enum { kFutexWaitPrivate = 128, kFutexWakePrivate = 129, }; switch (futex_op) { case kFutexWaitPrivate: pseudo_futex(uaddr, kPseudoFutexWait, val, timeout); break; case kFutexWakePrivate: pseudo_futex(uaddr, kPseudoFutexWake, val, NULL); break; } // This function should return the number of awaken threads, but now it is impossible. // Just return 0. return 0; } ================================================ FILE: 1.22_linux/runtime/cgo/hitsumabushi_mem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include void* hitsumabushi_sysReserveOS(void* v, uintptr_t n); void* hitsumabushi_sysAllocOS(uintptr_t n) { return hitsumabushi_sysReserveOS(NULL, n); } void hitsumabushi_sysUnusedOS(void* v, uintptr_t n) { } void hitsumabushi_sysUsedOS(void* v, uintptr_t n) { } void hitsumabushi_sysHugePageOS(void* v, uintptr_t n) { } void hitsumabushi_sysFreeOS(void* v, uintptr_t n) { } void hitsumabushi_sysFaultOS(void* v, uintptr_t n) { } void* hitsumabushi_sysReserveOS(void* v, uintptr_t n) { if (v) { return NULL; } return calloc(n, 1); } void hitsumabushi_sysMapOS(void* v, uintptr_t n) { } ================================================ FILE: 1.22_linux/runtime/cgo/hitsumabushi_syscalls_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include // for usleep #include // for size_t #include "libcgo.h" #include "libcgo_unix.h" typedef unsigned int gid_t; extern int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp); extern int32_t hitsumabushi_getproccount(); void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { abort(); return NULL; } int munmap(void *addr, size_t length) { abort(); return 0; } int pthread_sigmask(int how, void *set, void *oldset) { // Do nothing. return 0; } int setegid(gid_t gid) { // Do nothing. return 0; } int seteuid(uid_t gid) { // Do nothing. return 0; } int setgid(gid_t gid) { // Do nothing. return 0; } int setgroups(size_t size, const gid_t *list) { // Do nothing. return 0; } int setregid(gid_t rgid, gid_t egid) { // Do nothing. return 0; } int setreuid(uid_t ruid, uid_t euid) { // Do nothing. return 0; } int setresgid(gid_t rgid, gid_t egid, gid_t sgid) { // Do nothing. return 0; } int setresuid(uid_t ruid, uid_t euid, uid_t suid) { // Do nothing. return 0; } int setuid(uid_t gid) { // Do nothing. return 0; } int sigaction(int signum, void *act, void *oldact) { // Do nothing. return 0; } int sigaddset(void *set, int signum) { // Do nothing. return 0; } int sigemptyset(void *set) { // Do nothing. return 0; } int sigfillset(void *set) { // Do nothing. return 0; } int sigismember(void *set, int signum) { // Do nothing. return 0; } uint32_t hitsumabushi_gettid() { uint64_t tid64 = (uint64_t)(pthread_self()); uint32_t tid = (uint32_t)(tid64 >> 32) ^ (uint32_t)(tid64); return tid; } int64_t hitsumabushi_nanotime1() { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_MONOTONIC, &tp); return (int64_t)(tp.tv_sec) * 1000000000ll + (int64_t)tp.tv_nsec; } int32_t hitsumabushi_osyield() { return sched_yield(); } int32_t hitsumabushi_sched_getaffinity(pid_t pid, size_t cpusetsize, void *mask) { int32_t numcpu = hitsumabushi_getproccount(); for (int32_t i = 0; i < numcpu; i += 8) ((unsigned char*)mask)[i / 8] = (unsigned char)((1u << (numcpu - i)) - 1); // https://man7.org/linux/man-pages/man2/sched_setaffinity.2.html // > On success, the raw sched_getaffinity() system call returns the // > number of bytes placed copied into the mask buffer; return (numcpu + 7) / 8; } void hitsumabushi_usleep(useconds_t usec) { usleep(usec); } void hitsumabushi_walltime1(int64_t* sec, int32_t* nsec) { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_REALTIME, &tp); *sec = tp.tv_sec; *nsec = tp.tv_nsec; } void hitsumabushi_exit(int32_t code) { exit(code); } ================================================ FILE: 1.22_linux/runtime/cgo/hitsumabushi_thread_linux.c ================================================ void hitsumabushi_initializeThread(void) { } ================================================ FILE: 1.22_linux/runtime/cgo/linux_syscall.c.patch ================================================ //--from #include #include #include #include #include "libcgo.h" //--to #include #include #include #include "libcgo.h" //--from void _cgo_libc_setegid(argset_t* x) { SET_RETVAL(setegid((gid_t) x->args[0])); } //--to void _cgo_libc_setegid(argset_t* x) { } //--from void _cgo_libc_seteuid(argset_t* x) { SET_RETVAL(seteuid((uid_t) x->args[0])); } //--to void _cgo_libc_seteuid(argset_t* x) { } //--from void _cgo_libc_setgid(argset_t* x) { SET_RETVAL(setgid((gid_t) x->args[0])); } //--to void _cgo_libc_setgid(argset_t* x) { } //--from void _cgo_libc_setgroups(argset_t* x) { SET_RETVAL(setgroups((size_t) x->args[0], (const gid_t *) x->args[1])); } //--to void _cgo_libc_setgroups(argset_t* x) { } //--from void _cgo_libc_setregid(argset_t* x) { SET_RETVAL(setregid((gid_t) x->args[0], (gid_t) x->args[1])); } //--to void _cgo_libc_setregid(argset_t* x) { } //--from void _cgo_libc_setresgid(argset_t* x) { SET_RETVAL(setresgid((gid_t) x->args[0], (gid_t) x->args[1], (gid_t) x->args[2])); } //--to void _cgo_libc_setresgid(argset_t* x) { } //--from void _cgo_libc_setreuid(argset_t* x) { SET_RETVAL(setreuid((uid_t) x->args[0], (uid_t) x->args[1])); } //--to void _cgo_libc_setreuid(argset_t* x) { } //--from void _cgo_libc_setuid(argset_t* x) { SET_RETVAL(setuid((uid_t) x->args[0])); } //--to void _cgo_libc_setuid(argset_t* x) { } ================================================ FILE: 1.22_linux/runtime/cgo/sigaction.go.patch ================================================ //--from //go:build (linux && amd64) || (freebsd && amd64) || (linux && arm64) || (linux && ppc64le) //--to //go:build (freebsd && amd64) || (linux && arm64) || (linux && ppc64le) ================================================ FILE: 1.22_linux/runtime/crash_test.go.patch ================================================ //--from func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { //--to func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { t.Skip("buildTestProg is not supported in this environment") //--from func TestPanicInlined(t *testing.T) { //--to func TestPanicInlined(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.22_linux/runtime/crash_unix_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.22_linux/runtime/debug/heapdump_test.go.patch ================================================ //--from func TestWriteHeapDumpNonempty(t *testing.T) { //--to func TestWriteHeapDumpNonempty(t *testing.T) { t.Skip("file is not supported in this environment") //--from func TestWriteHeapDumpFinalizers(t *testing.T) { //--to func TestWriteHeapDumpFinalizers(t *testing.T) { t.Skip("file is not supported in this environment") //--from func TestWriteHeapDumpTypeName(t *testing.T) { //--to func TestWriteHeapDumpTypeName(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.22_linux/runtime/debug/panic_test.go.patch ================================================ //--from func TestPanicOnFault(t *testing.T) { //--to func TestPanicOnFault(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.22_linux/runtime/debug_test.go.patch ================================================ //--from //go:build (amd64 || arm64 || ppc64le) && linux && !race //--to //go:build ignore ================================================ FILE: 1.22_linux/runtime/export_unix_test.go ================================================ // Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build unix package runtime const ( O_WRONLY = _O_WRONLY O_CREAT = _O_CREAT O_TRUNC = _O_TRUNC ) ================================================ FILE: 1.22_linux/runtime/fds_unix.go.patch ================================================ //--from func checkfds() { //--to func checkfds() { return ================================================ FILE: 1.22_linux/runtime/internal/syscall/asm_linux_amd64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0 // a6 already in R9. // a5 already in R8. MOVQ SI, R10 // a4 MOVQ DI, DX // a3 MOVQ CX, SI // a2 MOVQ BX, DI // a1 // num already in AX. SYSCALL CMPQ AX, $0xfffffffffffff001 JLS ok NEGQ AX MOVQ AX, CX // errno MOVQ $-1, AX // r1 MOVQ $0, BX // r2 RET ok: // r1 already in AX. MOVQ DX, BX // r2 MOVQ $0, CX // errno RET //--to ================================================ FILE: 1.22_linux/runtime/internal/syscall/asm_linux_arm64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0-80 MOVD num+0(FP), R8 // syscall entry MOVD a1+8(FP), R0 MOVD a2+16(FP), R1 MOVD a3+24(FP), R2 MOVD a4+32(FP), R3 MOVD a5+40(FP), R4 MOVD a6+48(FP), R5 SVC CMN $4095, R0 BCC ok MOVD $-1, R4 MOVD R4, r1+56(FP) MOVD ZR, r2+64(FP) NEG R0, R0 MOVD R0, errno+72(FP) RET ok: MOVD R0, r1+56(FP) MOVD R1, r2+64(FP) MOVD ZR, errno+72(FP) RET //--to ================================================ FILE: 1.22_linux/runtime/internal/syscall/syscall_linux.go.patch ================================================ //--from func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) //--to func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { println("not implemented syscall at Syscall6", num) panic("syscall.Syscall6") return 0, 0, 0x26 // ENOSYS } //--from func syscall_RawSyscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { return Syscall6(num, a1, a2, a3, a4, a5, a6) } //--to func syscall_RawSyscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { println("not implemented syscall at RawSyscall6", num) panic("syscall.RawSyscall6") return 0, 0, 0x26 // ENOSYS } ================================================ FILE: 1.22_linux/runtime/internal/syscall/syscall_linux_test.go.patch ================================================ //--from import ( "runtime/internal/syscall" "testing" ) //--to import ( "testing" ) //--from func TestEpollctlErrorSign(t *testing.T) { v := syscall.EpollCtl(-1, 1, -1, &syscall.EpollEvent{}) const EBADF = 0x09 if v != EBADF { t.Errorf("epollctl = %v, want %v", v, EBADF) } } //--to func TestEpollctlErrorSign(t *testing.T) { t.Skip("Epollctl is not supported in this environment") } ================================================ FILE: 1.22_linux/runtime/mem_linux.go ================================================ // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This implementation is the most fundamental and minimal allocations like Wasm. // Malloced memory regions are never freed. package runtime import ( "internal/abi" "unsafe" ) // Don't split the stack as this method may be invoked without a valid G, which // prevents us from allocating more stack. // //go:nosplit //go:cgo_unsafe_args func sysAllocOS(n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysAllocOS_trampoline)), unsafe.Pointer(&n)) return } func sysAllocOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit //go:cgo_unsafe_args func sysUnusedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUnusedOS_trampoline)), unsafe.Pointer(&v)) } func sysUnusedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysUsedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUsedOS_trampoline)), unsafe.Pointer(&v)) } func sysUsedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysHugePageOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysHugePageOS_trampoline)), unsafe.Pointer(&v)) } func sysHugePageOS_trampoline(n uintptr, size uintptr) func sysNoHugePageOS(v unsafe.Pointer, n uintptr) { } func sysHugePageCollapseOS(v unsafe.Pointer, n uintptr) { } // Don't split the stack as this function may be invoked without a valid G, // which prevents us from allocating more stack. // //go:nosplit //go:cgo_unsafe_args func sysFreeOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFreeOS_trampoline)), unsafe.Pointer(&v)) } func sysFreeOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysFaultOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFaultOS_trampoline)), unsafe.Pointer(&v)) } func sysFaultOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysReserveOS(v unsafe.Pointer, n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysReserveOS_trampoline)), unsafe.Pointer(&v)) return } func sysReserveOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit //go:cgo_unsafe_args func sysMapOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysMapOS_trampoline)), unsafe.Pointer(&v)) } func sysMapOS_trampoline(n uintptr, size uintptr) ================================================ FILE: 1.22_linux/runtime/memmove_linux_amd64_test.go.patch ================================================ //--from func TestMemmoveOverflow(t *testing.T) { //--to func TestMemmoveOverflow(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.22_linux/runtime/metrics_test.go.patch ================================================ //--from name: "runtime/debug.WriteHeapDump", fn: func(t *testing.T) { //--to name: "runtime/debug.WriteHeapDump", fn: func(t *testing.T) { t.Skip("debug.WriteHeapDump is not supported in this environment") ================================================ FILE: 1.22_linux/runtime/nbpipe_pipe2.go.patch ================================================ //--from //go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris //--to //go:build dragonfly || freebsd || netbsd || openbsd || solaris ================================================ FILE: 1.22_linux/runtime/nbpipe_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.22_linux/runtime/netpoll_epoll.go.patch ================================================ //--from //go:build linux //--to //go:build ignore ================================================ FILE: 1.22_linux/runtime/netpoll_fake.go.patch ================================================ //--from //go:build js && wasm //--to //go:build linux ================================================ FILE: 1.22_linux/runtime/norace_linux_test.go.patch ================================================ //--from func TestNewOSProc0(t *testing.T) { //--to func TestNewOSProc0(t *testing.T) { t.Skip("newosproc0 is not supported in this environment") ================================================ FILE: 1.22_linux/runtime/os_linux.go.patch ================================================ //--from import ( "internal/abi" "internal/goarch" "runtime/internal/atomic" "runtime/internal/syscall" "unsafe" ) //--to import ( "internal/abi" "runtime/internal/atomic" "runtime/internal/syscall" "unsafe" ) //--from //go:noescape func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 //--to //go:nosplit //go:cgo_unsafe_args func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 { ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(futex_trampoline)), unsafe.Pointer(&addr)) return ret } func futex_trampoline(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 //--from func sysargs(argc int32, argv **byte) { n := argc + 1 // skip over argv, envp to get to auxv for argv_index(argv, n) != nil { n++ } // skip NULL separator n++ // now argv+n is auxv auxvp := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*goarch.PtrSize)) if pairs := sysauxv(auxvp[:]); pairs != 0 { auxv = auxvp[: pairs*2 : pairs*2] return } // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } n = read(fd, noescape(unsafe.Pointer(&auxvreadbuf[0])), int32(unsafe.Sizeof(auxvreadbuf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. auxvreadbuf[len(auxvreadbuf)-2] = _AT_NULL pairs := sysauxv(auxvreadbuf[:]) auxv = auxvreadbuf[: pairs*2 : pairs*2] } //--to func sysargs(argc int32, argv **byte) { // argc/argv is not reliable on some machines. // Skip analysing them. // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } n := read(fd, noescape(unsafe.Pointer(&auxvreadbuf[0])), int32(unsafe.Sizeof(auxvreadbuf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. auxvreadbuf[len(auxvreadbuf)-2] = _AT_NULL pairs := sysauxv(auxvreadbuf[:]) auxv = auxvreadbuf[: pairs*2 : pairs*2] } //--from var urandom_dev = []byte("/dev/urandom\x00") func readRandom(r []byte) int { fd := open(&urandom_dev[0], 0 /* O_RDONLY */, 0) n := read(fd, unsafe.Pointer(&r[0]), int32(len(r))) closefd(fd) return int(n) } //--to //go:nosplit func readRandom(r []byte) int { return 0 } //--from func gettid() uint32 //--to //go:nosplit //go:cgo_unsafe_args func gettid() (tid uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(gettid_trampoline)), unsafe.Pointer(&tid)) return } func gettid_trampoline() uint32 //--from //go:noescape func sigaltstack(new, old *stackt) //--to func sigaltstack(new, old *stackt) { // Do nothing. } //--from func sigprocmask(how int32, new, old *sigset) { rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--to func sigprocmask(how int32, new, old *sigset) { // Do nothing. // rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--from func raise(sig uint32) //--to func raise(sig uint32) { // Do nothing } //--from func raiseproc(sig uint32) //--to func raiseproc(sig uint32) { // Do nothing } //--from //go:noescape func sched_getaffinity(pid, len uintptr, buf *byte) int32 //--to //go:nosplit //go:cgo_unsafe_args func sched_getaffinity(pid, len uintptr, buf *byte) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(sched_getaffinity_trampoline)), unsafe.Pointer(&pid)) } func sched_getaffinity_trampoline(pid, len uintptr, buf *byte) int32 //--from func osyield() //--to //go:nosplit //go:cgo_unsafe_args func osyield() { libcCall(unsafe.Pointer(abi.FuncPCABI0(osyield_trampoline)), nil) } func osyield_trampoline() //--from func sysSigaction(sig uint32, new, old *sigactiont) { //--to func sysSigaction(sig uint32, new, old *sigactiont) { // Do nothing. return //--from func signalM(mp *m, sig int) { tgkill(getpid(), int(mp.procid), sig) } //--to func signalM(mp *m, sig int) { // Do nothiing. } //--from func runPerThreadSyscall() { gp := getg() if gp.m.needPerThreadSyscall.Load() == 0 { return } args := perThreadSyscall r1, r2, errno := syscall.Syscall6(args.trap, args.a1, args.a2, args.a3, args.a4, args.a5, args.a6) if GOARCH == "ppc64" || GOARCH == "ppc64le" { // TODO(https://go.dev/issue/51192 ): ppc64 doesn't use r2. r2 = 0 } if errno != 0 || r1 != args.r1 || r2 != args.r2 { print("trap:", args.trap, ", a123456=[", args.a1, ",", args.a2, ",", args.a3, ",", args.a4, ",", args.a5, ",", args.a6, "]\n") print("results: got {r1=", r1, ",r2=", r2, ",errno=", errno, "}, want {r1=", args.r1, ",r2=", args.r2, ",errno=0}\n") fatal("AllThreadsSyscall6 results differ between threads; runtime corrupted") } gp.m.needPerThreadSyscall.Store(0) } //--to func runPerThreadSyscall() { // Do nothing. // needPerThreadSyscall should never be 1 as syscall_runtime_doAllThreadsSyscall is not available with Cgo. } //--append //go:linkname hitsumabushi_closefd hitsumabushi_closefd //go:cgo_import_static hitsumabushi_closefd var hitsumabushi_closefd byte //go:linkname hitsumabushi_exit hitsumabushi_exit //go:cgo_import_static hitsumabushi_exit var hitsumabushi_exit byte //go:linkname hitsumabushi_gettid hitsumabushi_gettid //go:cgo_import_static hitsumabushi_gettid var hitsumabushi_gettid byte //go:linkname hitsumabushi_nanotime1 hitsumabushi_nanotime1 //go:cgo_import_static hitsumabushi_nanotime1 var hitsumabushi_nanotime1 byte //go:linkname hitsumabushi_open hitsumabushi_open //go:cgo_import_static hitsumabushi_open var hitsumabushi_open byte //go:linkname hitsumabushi_osyield hitsumabushi_osyield //go:cgo_import_static hitsumabushi_osyield var hitsumabushi_osyield byte //go:linkname hitsumabushi_read hitsumabushi_read //go:cgo_import_static hitsumabushi_read var hitsumabushi_read byte //go:linkname hitsumabushi_sched_getaffinity hitsumabushi_sched_getaffinity //go:cgo_import_static hitsumabushi_sched_getaffinity var hitsumabushi_sched_getaffinity byte //go:linkname hitsumabushi_usleep hitsumabushi_usleep //go:cgo_import_static hitsumabushi_usleep var hitsumabushi_usleep byte //go:linkname hitsumabushi_walltime1 hitsumabushi_walltime1 //go:cgo_import_static hitsumabushi_walltime1 var hitsumabushi_walltime1 byte //go:linkname hitsumabushi_write1 hitsumabushi_write1 //go:cgo_import_static hitsumabushi_write1 var hitsumabushi_write1 byte //go:nosplit //go:cgo_unsafe_args func fcntl1(fd, cmd, arg int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fcntl_trampoline)), unsafe.Pointer(&fd)) } func fcntl_trampoline() //go:nosplit //go:cgo_unsafe_args func fstat1(fd int, stat unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstat_trampoline)), unsafe.Pointer(&fd)) } func fstat_trampoline(fd int, stat unsafe.Pointer) int32 //go:nosplit //go:cgo_unsafe_args func lseek1(fd int, offset int64, whence int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(lseek_trampoline)), unsafe.Pointer(&fd)) } func lseek_trampoline() //go:nosplit //go:cgo_unsafe_args func renameat(fd1 int, name1 unsafe.Pointer, fd2 int, name2 unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(renameat_trampoline)), unsafe.Pointer(&fd1)) } func renameat_trampoline() //go:nosplit //go:cgo_unsafe_args func fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstatat_trampoline)), unsafe.Pointer(&fd)) } func fstatat_trampoline() ================================================ FILE: 1.22_linux/runtime/panicnil_test.go.patch ================================================ //--from func TestPanicNil(t *testing.T) { //--to func TestPanicNil(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.22_linux/runtime/proc_test.go.patch ================================================ //--from func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) testGoroutineParallelism2(t, false, true) testGoroutineParallelism2(t, true, true) } //--to func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) //testGoroutineParallelism2(t, false, true) //testGoroutineParallelism2(t, true, true) } ================================================ FILE: 1.22_linux/runtime/rand_test.go.patch ================================================ //--from func TestReadRandom(t *testing.T) { //--to func TestReadRandom(t *testing.T) { t.Skip("readRandom is not available in this environment") ================================================ FILE: 1.22_linux/runtime/runtime1.go.patch ================================================ //--from func argv_index(argv **byte, i int32) *byte { return *(**byte)(add(unsafe.Pointer(argv), uintptr(i)*goarch.PtrSize)) } //--to func argv_index(argv **byte, i int32) *byte { return nil } //--from func args(c int32, v **byte) { argc = c argv = v sysargs(c, v) } //--to func args(c int32, v **byte) { // In the original code, physPageSize is determined at sysargs. // Hitsumabushi gives an initial value for physPageSize at its declaration, so sysargs doesn't have to be called. } //--append // Expose the entry point for some special environments. //go:cgo_export_static _rt0_amd64_linux_lib //go:cgo_export_dynamic _rt0_amd64_linux_lib ================================================ FILE: 1.22_linux/runtime/runtime_linux_test.go.patch ================================================ //--from func TestMincoreErrorSign(t *testing.T) { //--to func TestMincoreErrorSign(t *testing.T) { t.Skip("mincore is not supported in this environment") ================================================ FILE: 1.22_linux/runtime/runtime_mmap_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.22_linux/runtime/runtime_test.go.patch ================================================ //--from func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { //--to func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { t.Skip("catching faults is not supported in this environment") ================================================ FILE: 1.22_linux/runtime/runtime_unix_test.go.patch ================================================ //--from //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || plan9 //--to //go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || plan9 ================================================ FILE: 1.22_linux/runtime/stack_test.go.patch ================================================ //--from func TestDeferLeafSigpanic(t *testing.T) { //--to func TestDeferLeafSigpanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestStackWrapperStackPanic(t *testing.T) { //--to func TestStackWrapperStackPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.22_linux/runtime/stubs2.go.patch ================================================ //--from import ( "runtime/internal/atomic" "unsafe" ) //--to import ( "internal/abi" "runtime/internal/atomic" "unsafe" ) //--from func read(fd int32, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func read(fd int32, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(read_trampoline)), unsafe.Pointer(&fd)) } func read_trampoline(fd int32, p unsafe.Pointer, n int32) int32 //--from func closefd(fd int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func closefd(fd int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(closefd_trampoline)), unsafe.Pointer(&fd)) } func closefd_trampoline(fd int32) int32 //--from func exit(code int32) //--to //go:nosplit //go:cgo_unsafe_args func exit(code int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(exit_trampoline)), unsafe.Pointer(&code)) } func exit_trampoline(code int32) //--from func usleep(usec uint32) //--to //go:nosplit //go:cgo_unsafe_args func usleep(usec uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } func usleep_trampoline(usec uint32) //--from //go:nosplit func usleep_no_g(usec uint32) { usleep(usec) } //--to //go:nosplit //go:cgo_unsafe_args func usleep_no_g(usec uint32) { asmcgocall_no_g(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } //--from //go:noescape func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func write1(fd uintptr, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(write1_trampoline)), unsafe.Pointer(&fd)) } func write1_trampoline(fd uintptr, p unsafe.Pointer, n int32) int32 //--from //go:noescape func open(name *byte, mode, perm int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func open(name *byte, mode, perm int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(open_trampoline)), unsafe.Pointer(&name)) } func open_trampoline(name *byte, mode, perm int32) int32 ================================================ FILE: 1.22_linux/runtime/stubs3.go.patch ================================================ //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func nanotime1() int64 //--to //go:nosplit //go:cgo_unsafe_args func nanotime1() (now int64) { libcCall(unsafe.Pointer(abi.FuncPCABI0(nanotime1_trampoline)), unsafe.Pointer(&now)) return } func nanotime1_trampoline() int64 ================================================ FILE: 1.22_linux/runtime/sys_libc.go.patch ================================================ //--from //go:build darwin || (openbsd && !mips64) //--to //go:build darwin || (openbsd && !mips64) || linux ================================================ FILE: 1.22_linux/runtime/sys_linux_amd64.s.patch ================================================ //--from TEXT runtime·open(SB),NOSPLIT,$0-20 // This uses openat instead of open, because Android O blocks open. MOVL $AT_FDCWD, DI // AT_FDCWD, so this acts like open MOVQ name+0(FP), SI MOVL mode+8(FP), DX MOVL perm+12(FP), R10 MOVL $SYS_openat, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVL 8(DI), SI // arg 2 flags MOVL 12(DI), DX // arg 3 mode MOVQ 0(DI), DI // arg 1 pathname XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_open(SB) MOVQ AX, 16(BX) POPQ BP RET //--from TEXT runtime·futex(SB),NOSPLIT,$0 MOVQ addr+0(FP), DI MOVL op+8(FP), SI MOVL val+12(FP), DX MOVQ ts+16(FP), R10 MOVQ addr2+24(FP), R8 MOVL val3+32(FP), R9 MOVL $SYS_futex, AX SYSCALL MOVL AX, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 addr MOVL 8(BX), SI // arg 2 op MOVL 12(BX), DX // arg 3 val MOVQ 16(BX), CX // arg 4 ts MOVQ 24(BX), R8 // arg 5 addr2 MOVL 32(BX), R9 // arg 6 val3 CALL hitsumabushi_futex(SB) MOVL AX, 40(BX) POPQ BP RET //--from TEXT runtime·exit(SB),NOSPLIT,$0-4 MOVL code+0(FP), DI MOVL $SYS_exit_group, AX SYSCALL RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 exit status CALL hitsumabushi_exit(SB) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·read(SB),NOSPLIT,$0-28 MOVL fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_read, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 0(BX), DI // arg 1 fd MOVQ 8(BX), SI // arg 2 buf MOVQ 16(BX), DX // arg 3 count CALL hitsumabushi_read(SB) MOVQ AX, 24(BX) // return value POPQ BP RET //--from TEXT runtime·closefd(SB),NOSPLIT,$0-12 MOVL fd+0(FP), DI MOVL $SYS_close, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 fd CALL hitsumabushi_closefd(SB) POPQ BP RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVL $SYS_gettid, AX SYSCALL MOVL AX, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_gettid(SB) POPQ BP RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT,$0 MOVQ new+0(FP), DI MOVQ old+8(FP), SI MOVQ $SYS_sigaltstack, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $0xf1, 0xf1 // crash RET //--to TEXT runtime·sigaltstack_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 old MOVQ 0(DI), DI // arg 1 new CALL hitsumabushi_sigaltstack(SB) TESTQ AX, AX JEQ 2(PC) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·raise(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, R12 MOVL $SYS_gettid, AX SYSCALL MOVL AX, SI // arg 2 tid MOVL R12, DI // arg 1 pid MOVL sig+0(FP), DX // arg 3 MOVL $SYS_tgkill, AX SYSCALL RET //--to TEXT runtime·raise_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 signal CALL hitsumabushi_raise(SB) POPQ BP RET //--from TEXT runtime·raiseproc(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, DI // arg 1 pid MOVL sig+0(FP), SI // arg 2 MOVL $SYS_kill, AX SYSCALL RET //--to TEXT runtime·raiseproc_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), BX // signal CALL hitsumabushi_getpid(SB) MOVL AX, DI // arg 1 pid MOVL BX, SI // arg 2 signal CALL hitsumabushi_kill(SB) POPQ BP RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0 MOVQ pid+0(FP), DI MOVQ len+8(FP), SI MOVQ buf+16(FP), DX MOVL $SYS_sched_getaffinity, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 len MOVQ 16(DI), DX // arg 3 buf MOVQ 0(DI), DI // arg 1 pid CALL hitsumabushi_sched_getaffinity(SB) POPQ BP RET //--from TEXT runtime·osyield(SB),NOSPLIT,$0 MOVL $SYS_sched_yield, AX SYSCALL RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_osyield(SB) POPQ BP RET //--from TEXT runtime·usleep(SB),NOSPLIT,$16 MOVL $0, DX MOVL usec+0(FP), AX MOVL $1000000, CX DIVL CX MOVQ AX, 0(SP) MOVL $1000, AX // usec to nsec MULL DX MOVQ AX, 8(SP) // nanosleep(&ts, 0) MOVQ SP, DI MOVL $0, SI MOVL $SYS_nanosleep, AX SYSCALL RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 usec CALL hitsumabushi_usleep(SB) POPQ BP RET //--from TEXT runtime·write1(SB),NOSPLIT,$0-28 MOVQ fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_write, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 p MOVQ 16(DI), DX // arg 3 n MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_write1(SB) POPQ BP RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$16-8 // We don't know how much stack space the VDSO code will need, // so switch to g0. // In particular, a kernel configured with CONFIG_OPTIMIZE_INLINING=n // and hardening can use a full page of stack space in gettime_sym // due to stack probes inserted to avoid stack/heap collisions. // See issue #20427. MOVQ SP, R12 // Save old SP; R12 unchanged by C code. MOVQ g_m(R14), BX // BX unchanged by C code. // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVQ m_vdsoPC(BX), CX MOVQ m_vdsoSP(BX), DX MOVQ CX, 0(SP) MOVQ DX, 8(SP) LEAQ ret+0(FP), DX MOVQ -8(DX), CX MOVQ CX, m_vdsoPC(BX) MOVQ DX, m_vdsoSP(BX) CMPQ R14, m_curg(BX) // Only switch if on curg. JNE noswitch MOVQ m_g0(BX), DX MOVQ (g_sched+gobuf_sp)(DX), SP // Set SP to g0 stack noswitch: SUBQ $16, SP // Space for results ANDQ $~15, SP // Align for C code MOVL $1, DI // CLOCK_MONOTONIC LEAQ 0(SP), SI MOVQ runtime·vdsoClockgettimeSym(SB), AX CMPQ AX, $0 JEQ fallback CALL AX ret: MOVQ 0(SP), AX // sec MOVQ 8(SP), DX // nsec MOVQ R12, SP // Restore real SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVQ 8(SP), CX MOVQ CX, m_vdsoSP(BX) MOVQ 0(SP), CX MOVQ CX, m_vdsoPC(BX) // sec is in AX, nsec in DX // return nsec in AX IMULQ $1000000000, AX ADDQ DX, AX MOVQ AX, ret+0(FP) RET fallback: MOVQ $SYS_clock_gettime, AX SYSCALL JMP ret //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ DI, BX // BX is callee-saved MOVQ SP, BP CALL hitsumabushi_nanotime1(SB) MOVQ AX, 0(BX) POPQ BP RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(DI), DI CALL hitsumabushi_sysAllocOS(SB) MOVQ AX, 8(BX) POPQ BP RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUnusedOS(SB) POPQ BP RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUsedOS(SB) POPQ BP RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysHugePageOS(SB) POPQ BP RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFreeOS(SB) POPQ BP RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFaultOS(SB) POPQ BP RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysReserveOS(SB) MOVQ AX, 16(BX) POPQ BP RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysMapOS(SB) POPQ BP RET TEXT runtime·walltime1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_walltime1(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 cmd MOVQ 16(DI), DX // arg 3 arg MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_fcntl(SB) POPQ BP RET TEXT runtime·fstat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 stat MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_fstat(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·lseek_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 offset MOVQ 16(DI), DX // arg 3 whence MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_lseek(SB) MOVQ AX, 24(BX) // return value POPQ BP RET TEXT runtime·renameat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_renameat(SB) MOVL AX, 32(BX) POPQ BP RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_fstatat(SB) MOVL AX, 32(BX) POPQ BP RET ================================================ FILE: 1.22_linux/runtime/sys_linux_arm64.s.patch ================================================ //--from #define SYS_exit 93 #define SYS_read 63 #define SYS_write 64 #define SYS_openat 56 #define SYS_close 57 #define SYS_pipe2 59 #define SYS_nanosleep 101 #define SYS_mmap 222 #define SYS_munmap 215 #define SYS_setitimer 103 #define SYS_clone 220 #define SYS_sched_yield 124 #define SYS_rt_sigreturn 139 #define SYS_rt_sigaction 134 #define SYS_rt_sigprocmask 135 #define SYS_sigaltstack 132 #define SYS_madvise 233 #define SYS_mincore 232 #define SYS_getpid 172 #define SYS_gettid 178 #define SYS_kill 129 #define SYS_tgkill 131 #define SYS_futex 98 #define SYS_sched_getaffinity 123 #define SYS_exit_group 94 #define SYS_clock_gettime 113 #define SYS_faccessat 48 #define SYS_socket 198 #define SYS_connect 203 #define SYS_brk 214 #define SYS_timer_create 107 #define SYS_timer_settime 110 #define SYS_timer_delete 111 //--to #define SYS_exit 2147483647 #define SYS_read 2147483647 #define SYS_write 2147483647 #define SYS_openat 2147483647 #define SYS_close 2147483647 #define SYS_pipe2 2147483647 #define SYS_nanosleep 2147483647 #define SYS_mmap 2147483647 #define SYS_munmap 2147483647 #define SYS_setitimer 2147483647 #define SYS_clone 2147483647 #define SYS_sched_yield 2147483647 #define SYS_rt_sigreturn 2147483647 #define SYS_rt_sigaction 2147483647 #define SYS_rt_sigprocmask 2147483647 #define SYS_sigaltstack 2147483647 #define SYS_madvise 2147483647 #define SYS_mincore 2147483647 #define SYS_getpid 2147483647 #define SYS_gettid 2147483647 #define SYS_kill 2147483647 #define SYS_tgkill 2147483647 #define SYS_futex 2147483647 #define SYS_sched_getaffinity 2147483647 #define SYS_exit_group 2147483647 #define SYS_clock_gettime 2147483647 #define SYS_faccessat 2147483647 #define SYS_socket 2147483647 #define SYS_connect 2147483647 #define SYS_brk 2147483647 #define SYS_timer_create 2147483647 #define SYS_timer_settime 2147483647 #define SYS_timer_delete 2147483647 //--from TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0-4 MOVW code+0(FP), R0 MOVD $SYS_exit_group, R8 SVC RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_exit(SB) RET //--from TEXT runtime·open(SB),NOSPLIT|NOFRAME,$0-20 MOVD $AT_FDCWD, R0 MOVD name+0(FP), R1 MOVW mode+8(FP), R2 MOVW perm+12(FP), R3 MOVD $SYS_openat, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_open(SB) RET //--from TEXT runtime·closefd(SB),NOSPLIT|NOFRAME,$0-12 MOVW fd+0(FP), R0 MOVD $SYS_close, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT,$0-12 MOVW 0(R0), R0 BL hitsumabushi_closefd(SB) RET //--from TEXT runtime·write1(SB),NOSPLIT|NOFRAME,$0-28 MOVD fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_write, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_write1(SB) RET //--from TEXT runtime·read(SB),NOSPLIT|NOFRAME,$0-28 MOVW fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_read, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_read(SB) RET //--from TEXT runtime·usleep(SB),NOSPLIT,$24-4 MOVWU usec+0(FP), R3 MOVD R3, R5 MOVW $1000000, R4 UDIV R4, R3 MOVD R3, 8(RSP) MUL R3, R4 SUB R4, R5 MOVW $1000, R4 MUL R4, R5 MOVD R5, 16(RSP) // nanosleep(&ts, 0) ADD $8, RSP, R0 MOVD $0, R1 MOVD $SYS_nanosleep, R8 SVC RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_usleep(SB) RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVD $SYS_gettid, R8 SVC MOVW R0, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_gettid(SB) MOVW R0, 0(R19) // return value RET //--from TEXT runtime·raise(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R19 MOVD $SYS_gettid, R8 SVC MOVW R0, R1 // arg 2 tid MOVW R19, R0 // arg 1 pid MOVW sig+0(FP), R2 // arg 3 MOVD $SYS_tgkill, R8 SVC RET //--to //--from TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R0 // arg 1 pid MOVW sig+0(FP), R1 // arg 2 MOVD $SYS_kill, R8 SVC RET //--to //--from TEXT runtime·walltime(SB),NOSPLIT,$24-12 MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $16, R1 BIC $15, R1 // Align for C code MOVD R1, RSP MOVW $CLOCK_REALTIME, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) MOVD R3, sec+0(FP) MOVW R5, nsec+8(FP) RET //--to TEXT runtime·walltime1_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_walltime1(SB) RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$24-8 MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $32, R1 BIC $15, R1 MOVD R1, RSP MOVW $CLOCK_MONOTONIC, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) // sec is in R3, nsec in R5 // return nsec in R3 MOVD $1000000000, R4 MUL R4, R3 ADD R5, R3 MOVD R3, ret+0(FP) RET //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_nanotime1(SB) MOVD R0, 0(R19) // return value RET //--from TEXT runtime·futex(SB),NOSPLIT|NOFRAME,$0 MOVD addr+0(FP), R0 MOVW op+8(FP), R1 MOVW val+12(FP), R2 MOVD ts+16(FP), R3 MOVD addr2+24(FP), R4 MOVW val3+32(FP), R5 MOVD $SYS_futex, R8 SVC MOVW R0, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 16(R0), R3 MOVD 24(R0), R4 MOVW 32(R0), R5 MOVD 0(R0), R0 BL hitsumabushi_futex(SB) RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT|NOFRAME,$0 MOVD new+0(FP), R0 MOVD old+8(FP), R1 MOVD $SYS_sigaltstack, R8 SVC CMN $4095, R0 BCC ok MOVD $0, R0 MOVD R0, (R0) // crash ok: RET //--to //--from TEXT runtime·osyield(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_sched_yield, R8 SVC RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT,$0 BL hitsumabushi_osyield(SB) RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT|NOFRAME,$0 MOVD pid+0(FP), R0 MOVD len+8(FP), R1 MOVD buf+16(FP), R2 MOVD $SYS_sched_getaffinity, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVD 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_sched_getaffinity(SB) RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 0(R0), R0 BL hitsumabushi_sysAllocOS(SB) MOVD R0, 8(R19) // return value RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUnusedOS(SB) RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUsedOS(SB) RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysHugePageOS(SB) RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFreeOS(SB) RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFaultOS(SB) RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysReserveOS(SB) MOVD R0, 16(R19) // return value RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysMapOS(SB) RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVW 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_fcntl(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·fstat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 0(R0), R0 BL hitsumabushi_fstat(SB) MOVW R0, 16(R19) // return value RET TEXT runtime·lseek_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_lseek(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·renameat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_renameat(SB) MOVW R0, 32(R19) // return value RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_fstatat(SB) MOVW R0, 32(R19) // return value RET ================================================ FILE: 1.22_linux/runtime/time_linux_amd64.s.patch ================================================ //--from //go:build !faketime //--to //go:build ignore ================================================ FILE: 1.22_linux/runtime/timeasm.go.patch ================================================ //--from //go:build !faketime && (windows || (linux && amd64)) //--to //go:build !faketime && windows ================================================ FILE: 1.22_linux/runtime/timestub.go.patch ================================================ //--from //go:build !faketime && !windows && !(linux && amd64) //--to //go:build !faketime && !windows ================================================ FILE: 1.22_linux/runtime/timestub2.go.patch ================================================ //--from //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !wasip1 && !windows && !(linux && amd64) //--to //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !wasip1 && !windows //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func walltime() (sec int64, nsec int32) //--to func walltime() (sec int64, nsec int32) { walltime1(&sec, &nsec) return } //go:nosplit //go:cgo_unsafe_args func walltime1(sec *int64, nsec *int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(walltime1_trampoline)), unsafe.Pointer(&sec)) } func walltime1_trampoline(sec *int64, nsec *int32) ================================================ FILE: 1.22_linux/runtime/traceback_test.go.patch ================================================ //--from func TestTracebackInlined(t *testing.T) { //--to func TestTracebackInlined(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.22_linux/strconv/fp_test.go.patch ================================================ //--from func TestFp(t *testing.T) { //--to func TestFp(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.22_linux/sync/atomic/atomic_test.go.patch ================================================ //--from func TestStoreLoadSeqCst32(t *testing.T) { //--to func TestStoreLoadSeqCst32(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") //--from func TestStoreLoadSeqCst64(t *testing.T) { //--to func TestStoreLoadSeqCst64(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") //--from func TestNilDeref(t *testing.T) { //--to func TestNilDeref(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.22_linux/syscall/hitsumabushi_stubs_linux_amd64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_FSTATAT = 0xffffffffffffffff // Stub: on amd64 Go uses SYS_NEWFSTATAT instead ) ================================================ FILE: 1.22_linux/syscall/hitsumabushi_stubs_linux_arm64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_NEWFSTATAT = 0xffffffffffffffff // Stub: on arm64 Go uses SYS_FSTATAT instead ) ================================================ FILE: 1.22_linux/syscall/rlimit.go.patch ================================================ //--from func init() { var lim Rlimit if err := Getrlimit(RLIMIT_NOFILE, &lim); err == nil && lim.Cur != lim.Max { origRlimitNofile.Store(&lim) nlim := lim nlim.Cur = nlim.Max adjustFileLimit(&nlim) setrlimit(RLIMIT_NOFILE, &nlim) } } //--to func init() { } ================================================ FILE: 1.22_linux/syscall/syscall_linux.go.patch ================================================ //--from func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { return RawSyscall6(trap, a1, a2, a3, 0, 0, 0) } //--to func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { println("not implemented syscall at RawSyscall", trap) panic("syscall.RawSyscall") return 0, 0, ENOSYS } //--from func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() // N.B. Calling RawSyscall here is unsafe with atomic coverage // instrumentation and race mode. // // Coverage instrumentation will add a sync/atomic call to RawSyscall. // Race mode will add race instrumentation to sync/atomic. Race // instrumentation requires a P, which we no longer have. // // RawSyscall6 is fine because it is implemented in assembly and thus // has no coverage instrumentation. // // This is typically not a problem in the runtime because cmd/go avoids // adding coverage instrumentation to the runtime in race mode. r1, r2, err = RawSyscall6(trap, a1, a2, a3, 0, 0, 0) runtime_exitsyscall() return } //--to func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FCNTL: r = fcntl1(a1, a2, a3) case SYS_FSTAT: r = fstat1(a1, unsafe.Pointer(a2)) case SYS_READ: r = runtime_read(uintptr(a1), unsafe.Pointer(a2), int32(a3)) case SYS_WRITE: r = write1(a1, unsafe.Pointer(a2), int32(a3)) case SYS_LSEEK: r = lseek1(a1, int64(a2), int32(a3)) case SYS_CLOSE: r = runtime_closefd(int32(a1)) case SYS_MKDIRAT: println("syscall mkdirat() is not implemented") // Default to permission denied. TODO: implement this return 0, 0, EPERM case SYS_GETDENTS64: println("syscall getdents64() is not implemented") // Default to empty directory. TODO: implement this return 0, 0, 0 default: println("unimplemented syscall at runtime.Syscall", trap) panic("syscall.Syscall") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //go:linkname open runtime.open func open(name *byte, mode, perm int32) int32 //go:linkname write1 runtime.write1 func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname fcntl1 runtime.fcntl1 func fcntl1(fd uintptr, a uintptr, b uintptr) int32 //go:linkname fstat1 runtime.fstat1 func fstat1(fd uintptr, p unsafe.Pointer) int32 //go:linkname lseek1 runtime.lseek1 func lseek1(fd uintptr, offset int64, whence int32) int32 //go:linkname runtime_read runtime.read func runtime_read(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname runtime_closefd runtime.closefd func runtime_closefd(fd int32) int32 //go:linkname runtime_fstatat runtime.fstatat func runtime_fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 //go:linkname runtime_renameat runtime.renameat func runtime_renameat(fd1 uintptr, name1 unsafe.Pointer, fd2 uintptr, name2 unsafe.Pointer) int32 //--from func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() r1, r2, err = RawSyscall6(trap, a1, a2, a3, a4, a5, a6) runtime_exitsyscall() return } //--to func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FSTATAT, SYS_NEWFSTATAT: r = runtime_fstatat(uintptr(a1), unsafe.Pointer(a2), unsafe.Pointer(a3), int32(a4)) case SYS_RENAMEAT: r = runtime_renameat(uintptr(a1), unsafe.Pointer(a2), uintptr(a3), unsafe.Pointer(a4)) default: println("unimplemented syscall at runtime.Syscall6", trap) panic("syscall.Syscall6") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //--from func Open(path string, mode int, perm uint32) (fd int, err error) { return openat(_AT_FDCWD, path, mode|O_LARGEFILE, perm) } //--to func Open(path string, mode int, perm uint32) (fd int, err error) { p0, err := BytePtrFromString(path) if err != nil { return -1, errnoErr(EINVAL) } fd = int(open(p0, int32(mode|O_LARGEFILE), int32(perm))) if fd < 0 { return -1, errnoErr(ENOENT) } return } ================================================ FILE: 1.22_linux/testing/run_example.go ================================================ package testing func runExample(eg InternalExample) (ok bool) { // Do nothing. // TODO: Implement os.Pipe2 and use this here. return true } ================================================ FILE: 1.22_linux/time/format_test.go.patch ================================================ //--from func TestParseInLocation(t *testing.T) { //--to func TestParseInLocation(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationZipFile(t *testing.T) { //--to func TestLoadLocationZipFile(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.22_linux/time/internal_test.go.patch ================================================ //--from func initTestingZone() { // For hermeticity, use only tzinfo source from the test's GOROOT, // not the system sources and not whatever GOROOT may happen to be // set in the process's environment (if any). // This test runs in GOROOT/src/time, so GOROOT is "../..", // but it is theoretically possible sources := []string{"../../lib/time/zoneinfo.zip"} z, err := loadLocation("America/Los_Angeles", sources) if err != nil { panic("cannot load America/Los_Angeles for testing: " + err.Error() + "; you may want to use -tags=timetzdata") } z.name = "Local" localLoc = *z } //--to func initTestingZone() { // Data from the playground. // https://go.dev/play/p/VGXU57KZZ-x // name is replaced with "Local". // cachStart, cacheEnd, and cacheZone are removed. localLoc = Location{name:"Local",zone:[]zone{zone{name:"LMT", offset:-28378, isDST:false}, zone{name:"PDT", offset:-25200, isDST:true}, zone{name:"PST", offset:-28800, isDST:false}, zone{name:"PWT", offset:-25200, isDST:true}, zone{name:"PPT", offset:-25200, isDST:true}}, tx:[]zoneTrans{zoneTrans{when:-576460752303423488, index:0x0, isstd:false, isutc:false}, zoneTrans{when:-2717640000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1633269600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-1615129200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1601820000, index:0x1, isstd:true, isutc:true}, zoneTrans{when:-1583679600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-880207200, index:0x3, isstd:false, isutc:false}, zoneTrans{when:-769395600, index:0x4, isstd:false, isutc:false}, zoneTrans{when:-765385200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-687967140, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-662655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-620838000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-608137200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-589388400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-576082800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-557938800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-544633200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-526489200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-513183600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-495039600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-481734000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-463590000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-450284400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-431535600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-418230000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-400086000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-386780400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-368636400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-355330800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-337186800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-323881200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-305737200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-292431600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-273682800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-260982000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-242233200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-226508400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-210783600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-195058800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-179334000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-163609200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-147884400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-131554800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-116434800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-100105200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-84376800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-68655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-52927200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-37206000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-21477600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-5756400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:9972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:25693200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:41421600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:57747600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:73476000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:89197200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:104925600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:120646800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:126698400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:152096400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:162381600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:183546000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:199274400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:215600400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:230724000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:247050000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:262778400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:278499600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:294228000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:309949200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:325677600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:341398800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:357127200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:372848400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:388576800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:404902800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:420026400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:436352400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:452080800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:467802000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:483530400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:499251600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:514980000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:530701200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:544615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:562150800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:576064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:594205200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:607514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:625654800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:638964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:657104400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:671018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:688554000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:702468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:720003600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:733917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:752058000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:765367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:783507600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:796816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:814957200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:828871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:846406800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:860320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:877856400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:891770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:909306000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:923220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:941360400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:954669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:972810000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:986119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1004259600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1018173600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1035709200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1049623200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1067158800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1081072800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1099213200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1112522400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1130662800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1143972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1162112400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1173607200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1194166800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1205056800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1225616400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1236506400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1257066000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1268560800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1289120400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1300010400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1320570000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1331460000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1352019600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1362909600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1383469200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1394359200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1414918800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1425808800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1446368400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1457863200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1478422800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1489312800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1509872400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1520762400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1541322000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1552212000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1572771600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1583661600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1604221200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1615716000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1636275600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1647165600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1667725200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1678615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1699174800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1710064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1730624400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1741514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1762074000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1772964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1793523600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1805018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1825578000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1836468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1857027600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1867917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1888477200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1899367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1919926800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1930816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1951376400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1962871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1983430800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1994320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2014880400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2025770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2046330000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2057220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2077779600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2088669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2109229200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2120119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2140678800, index:0x2, isstd:false, isutc:false}}, extend:"PST8PDT,M3.2.0,M11.1.0"} } ================================================ FILE: 1.22_linux/time/sleep_test.go.patch ================================================ //--from func TestSleep(t *testing.T) { //--to func TestSleep(t *testing.T) { t.Skip("Interrupt (syscall.Kill) is not supported in this environment") //--from func TestIssue5745(t *testing.T) { //--to func TestIssue5745(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.22_linux/time/time_test.go.patch ================================================ //--from func TestLoadFixed(t *testing.T) { //--to func TestLoadFixed(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestTimeIsDST(t *testing.T) { //--to func TestTimeIsDST(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestTimeWithZoneTransition(t *testing.T) { //--to func TestTimeWithZoneTransition(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestMarshalBinaryVersion2(t *testing.T) { //--to func TestMarshalBinaryVersion2(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.22_linux/time/tzdata_test.go.patch ================================================ //--from func TestEmbeddedTZData(t *testing.T) { //--to func TestEmbeddedTZData(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.22_linux/time/zoneinfo_test.go.patch ================================================ //--from func TestEnvVarUsage(t *testing.T) { //--to func TestEnvVarUsage(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestBadLocationErrMsg(t *testing.T) { //--to func TestBadLocationErrMsg(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestVersion3(t *testing.T) { //--to func TestVersion3(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestFirstZone(t *testing.T) { //--to func TestFirstZone(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationFromTZData(t *testing.T) { //--to func TestLoadLocationFromTZData(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestEarlyLocation(t *testing.T) { //--to func TestEarlyLocation(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationFromTZDataSlim(t *testing.T) { //--to func TestLoadLocationFromTZDataSlim(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.22_linux/time/zoneinfo_unix.go.patch ================================================ //--from import ( "syscall" ) //--to //--from func initLocal() { // consult $TZ to find the time zone to use. // no $TZ means use the system default /etc/localtime. // $TZ="" means use UTC. // $TZ="foo" or $TZ=":foo" if foo is an absolute path, then the file pointed // by foo will be used to initialize timezone; otherwise, file // /usr/share/zoneinfo/foo will be used. tz, ok := syscall.Getenv("TZ") switch { case !ok: z, err := loadLocation("localtime", []string{"/etc"}) if err == nil { localLoc = *z localLoc.name = "Local" return } case tz != "": if tz[0] == ':' { tz = tz[1:] } if tz != "" && tz[0] == '/' { if z, err := loadLocation(tz, []string{""}); err == nil { localLoc = *z if tz == "/etc/localtime" { localLoc.name = "Local" } else { localLoc.name = tz } return } } else if tz != "" && tz != "UTC" { if z, err := loadLocation(tz, platformZoneSources); err == nil { localLoc = *z return } } } // Fall back to UTC. localLoc.name = "UTC" } //--to func initLocal() { localLoc.name = "UTC" } ================================================ FILE: 1.22_linux/time/zoneinfo_unix_test.go.patch ================================================ //--from func TestEnvTZUsage(t *testing.T) { //--to func TestEnvTZUsage(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.22_windows/internal/testenv/exec.go.patch ================================================ //--from func tryExec() error { //--to func tryExec() error { return fmt.Errorf("can't probe for exec support") ================================================ FILE: 1.22_windows/internal/testenv/testenv.go.patch ================================================ //--from func HasGoBuild() bool { //--to func HasGoBuild() bool { return false ================================================ FILE: 1.22_windows/runtime/cgo/gcc_windows_amd64.c.patch ================================================ //--from static void threadentry(void *v) { //--to static int getproccount() { static int proccount = 0; if (!proccount) { SYSTEM_INFO info; GetSystemInfo(&info); proccount = info.dwNumberOfProcessors; } return proccount; } static void threadentry(void *v) { SetThreadAffinityMask(GetCurrentThread(), (1< //--to //--append #define fprintf dummy_fprintf // TODO: Use OutputDebugMessage. #define dummy_fprintf(stream, format, ...) ================================================ FILE: 1.22_windows/runtime/os_windows.go.patch ================================================ //--from //go:cgo_import_dynamic runtime._GetConsoleMode GetConsoleMode%2 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._SetConsoleCtrlHandler SetConsoleCtrlHandler%2 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._WerGetFlags WerGetFlags%2 "kernel32.dll" //go:cgo_import_dynamic runtime._WerSetFlags WerSetFlags%1 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._WriteConsoleW WriteConsoleW%5 "kernel32.dll" //--to //go:cgo_import_dynamic runtime._OutputDebugStringW OutputDebugStringW%1 "kernel32.dll" //--from _GetConsoleMode, //--to //--from _SetConsoleCtrlHandler, //--to //--from _WerGetFlags, _WerSetFlags, //--to //--from _WriteConsoleW, //--to _OutputDebugStringW, //--from _timeBeginPeriod, _timeEndPeriod, //--to //--from m32 := windowsLoadSystemLib(winmmdll[:]) if m32 == 0 { throw("winmm.dll not found") } _timeBeginPeriod = windowsFindfunc(m32, []byte("timeBeginPeriod\000")) _timeEndPeriod = windowsFindfunc(m32, []byte("timeEndPeriod\000")) if _timeBeginPeriod == nil || _timeEndPeriod == nil { throw("timeBegin/EndPeriod not found") } //--to //--from // We call these all the way here, late in init, so that malloc works // for the callback functions these generate. var fn any = ctrlHandler ctrlHandlerPC := compileCallback(*efaceOf(&fn), true) stdcall2(_SetConsoleCtrlHandler, ctrlHandlerPC, 1) //--to //--from func osRelax(relax bool) uint32 { if haveHighResTimer { // If the high resolution timer is available, the runtime uses the timer // to sleep for short durations. This means there's no need to adjust // the global clock frequency. return 0 } if relax { return uint32(stdcall1(_timeEndPeriod, 1)) } else { return uint32(stdcall1(_timeBeginPeriod, 1)) } } //--to func osRelax(relax bool) uint32 { if haveHighResTimer { // If the high resolution timer is available, the runtime uses the timer // to sleep for short durations. This means there's no need to adjust // the global clock frequency. return 0 } throw("not reached") return 0 } //--from func write1(fd uintptr, buf unsafe.Pointer, n int32) int32 { const ( _STD_OUTPUT_HANDLE = ^uintptr(10) // -11 _STD_ERROR_HANDLE = ^uintptr(11) // -12 ) var handle uintptr switch fd { case 1: handle = stdcall1(_GetStdHandle, _STD_OUTPUT_HANDLE) case 2: handle = stdcall1(_GetStdHandle, _STD_ERROR_HANDLE) default: // assume fd is real windows handle. handle = fd } isASCII := true b := (*[1 << 30]byte)(buf)[:n] for _, x := range b { if x >= 0x80 { isASCII = false break } } if !isASCII { var m uint32 isConsole := stdcall2(_GetConsoleMode, handle, uintptr(unsafe.Pointer(&m))) != 0 // If this is a console output, various non-unicode code pages can be in use. // Use the dedicated WriteConsole call to ensure unicode is printed correctly. if isConsole { return int32(writeConsole(handle, buf, n)) } } var written uint32 stdcall5(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--to func write1(fd uintptr, buf unsafe.Pointer, n int32) int32 { const ( _STD_OUTPUT_HANDLE = ^uintptr(10) // -11 _STD_ERROR_HANDLE = ^uintptr(11) // -12 ) var handle uintptr switch fd { case 1: handle = stdcall1(_GetStdHandle, _STD_OUTPUT_HANDLE) case 2: handle = stdcall1(_GetStdHandle, _STD_ERROR_HANDLE) default: // assume fd is real windows handle. handle = fd } if fd == 1 || fd == 2 { // Note that handle is not used anyway. return int32(writeConsole(handle, buf, n)) } var written uint32 stdcall5(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--from func writeConsoleUTF16(handle uintptr, b []uint16) { l := uint32(len(b)) if l == 0 { return } var written uint32 stdcall5(_WriteConsoleW, handle, uintptr(unsafe.Pointer(&b[0])), uintptr(l), uintptr(unsafe.Pointer(&written)), 0, ) return } //--to func writeConsoleUTF16(handle uintptr, b []uint16) { b = b[:len(b)+1] b[len(b)-1] = 0 l := uint32(len(b)) if l <= 1 { return } stdcall1(_OutputDebugStringW, uintptr(unsafe.Pointer(&b[0])), ) return } ================================================ FILE: 1.22_windows/runtime/signal_windows.go.patch ================================================ //--from func preventErrorDialogs() { errormode := stdcall0(_GetErrorMode) stdcall1(_SetErrorMode, errormode|_SEM_FAILCRITICALERRORS|_SEM_NOGPFAULTERRORBOX|_SEM_NOOPENFILEERRORBOX) // Disable WER fault reporting UI. // Do this even if WER is disabled as a whole, // as WER might be enabled later with setTraceback("wer") // and we still want the fault reporting UI to be disabled if this happens. var werflags uintptr stdcall2(_WerGetFlags, currentProcess, uintptr(unsafe.Pointer(&werflags))) stdcall1(_WerSetFlags, werflags|_WER_FAULT_REPORTING_NO_UI) } //--to func preventErrorDialogs() { errormode := stdcall0(_GetErrorMode) stdcall1(_SetErrorMode, errormode|_SEM_FAILCRITICALERRORS|_SEM_NOGPFAULTERRORBOX|_SEM_NOOPENFILEERRORBOX) } ================================================ FILE: 1.22_windows/runtime/syscall_windows.go.patch ================================================ //--from func syscall_SyscallN(trap uintptr, args ...uintptr) (r1, r2, err uintptr) { //--to func syscall_SyscallN(trap uintptr, args ...uintptr) (r1, r2, err uintptr) { if trap == 0 { panic("trap must not be 0 at SyscallN") } ================================================ FILE: 1.22_windows/runtime/syscall_windows_test.go.patch ================================================ //--from func TestNumCPU(t *testing.T) { //--to func TestNumCPU(t *testing.T) { t.Skip("creating a new process with os.Args[0] doesn't work in this environment") ================================================ FILE: 1.23_linux/internal/reflectlite/reflect_mirror_test.go.patch ================================================ //--from func TestMirrorWithReflect(t *testing.T) { //--to func TestMirrorWithReflect(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.23_linux/internal/runtime/syscall/asm_linux_amd64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0 // a6 already in R9. // a5 already in R8. MOVQ SI, R10 // a4 MOVQ DI, DX // a3 MOVQ CX, SI // a2 MOVQ BX, DI // a1 // num already in AX. SYSCALL CMPQ AX, $0xfffffffffffff001 JLS ok NEGQ AX MOVQ AX, CX // errno MOVQ $-1, AX // r1 MOVQ $0, BX // r2 RET ok: // r1 already in AX. MOVQ DX, BX // r2 MOVQ $0, CX // errno RET //--to ================================================ FILE: 1.23_linux/internal/runtime/syscall/asm_linux_arm64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0-80 MOVD num+0(FP), R8 // syscall entry MOVD a1+8(FP), R0 MOVD a2+16(FP), R1 MOVD a3+24(FP), R2 MOVD a4+32(FP), R3 MOVD a5+40(FP), R4 MOVD a6+48(FP), R5 SVC CMN $4095, R0 BCC ok MOVD $-1, R4 MOVD R4, r1+56(FP) MOVD ZR, r2+64(FP) NEG R0, R0 MOVD R0, errno+72(FP) RET ok: MOVD R0, r1+56(FP) MOVD R1, r2+64(FP) MOVD ZR, errno+72(FP) RET //--to ================================================ FILE: 1.23_linux/internal/runtime/syscall/syscall_linux.go.patch ================================================ //--from func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) //--to func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { println("not implemented syscall at Syscall6", num) panic("syscall.Syscall6") return 0, 0, 0x26 // ENOSYS } ================================================ FILE: 1.23_linux/internal/runtime/syscall/syscall_linux_test.go.patch ================================================ //--from import ( "internal/runtime/syscall" "testing" ) //--to import ( "testing" ) //--from func TestEpollctlErrorSign(t *testing.T) { v := syscall.EpollCtl(-1, 1, -1, &syscall.EpollEvent{}) const EBADF = 0x09 if v != EBADF { t.Errorf("epollctl = %v, want %v", v, EBADF) } } //--to func TestEpollctlErrorSign(t *testing.T) { t.Skip("Epollctl is not supported in this environment") } ================================================ FILE: 1.23_linux/internal/syscall/unix/fcntl_unix.go.patch ================================================ //--from func Fcntl(fd int, cmd int, arg int) (int, error) { val, errno := fcntl(int32(fd), int32(cmd), int32(arg)) if val == -1 { return int(val), syscall.Errno(errno) } return int(val), nil } //--to func Fcntl(fd int, cmd int, arg int) (int, error) { return 0, syscall.ENOSYS } ================================================ FILE: 1.23_linux/internal/testenv/exec.go.patch ================================================ //--from func tryExec() error { //--to func tryExec() error { return fmt.Errorf("can't probe for exec support") ================================================ FILE: 1.23_linux/internal/testenv/testenv.go.patch ================================================ //--from func HasGoBuild() bool { //--to func HasGoBuild() bool { return false ================================================ FILE: 1.23_linux/internal/testenv/testenv_notunix.go.patch ================================================ //--from //go:build windows || plan9 || (js && wasm) || wasip1 //--to //go:build windows || plan9 || (js && wasm) || wasip1 || linux ================================================ FILE: 1.23_linux/internal/testenv/testenv_unix.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.23_linux/math/big/link_test.go.patch ================================================ //--from func TestLinkerGC(t *testing.T) { //--to func TestLinkerGC(t *testing.T) { t.Skip("go tools are not supported in this environment") ================================================ FILE: 1.23_linux/math/rand/default_test.go.patch ================================================ //--from func TestDefaultRace(t *testing.T) { //--to func TestDefaultRace(t *testing.T) { t.Skip("os.Getenv and creating processes are not supported in this environment") ================================================ FILE: 1.23_linux/runtime/align_test.go.patch ================================================ //--from func TestAtomicAlignment(t *testing.T) { //--to func TestAtomicAlignment(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.23_linux/runtime/callers_test.go.patch ================================================ //--from func TestCallersNilPointerPanic(t *testing.T) { //--to func TestCallersNilPointerPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestCallersDeferNilFuncPanic(t *testing.T) { //--to func TestCallersDeferNilFuncPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { //--to func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.23_linux/runtime/cgo/cgo.go.patch ================================================ //--from */ import "C" //--to #cgo !darwin LDFLAGS: -Wl,-unresolved-symbols=ignore-all #cgo darwin LDFLAGS: -Wl,-undefined,dynamic_lookup */ import "C" ================================================ FILE: 1.23_linux/runtime/cgo/gcc_linux_amd64.c.patch ================================================ //--from #include #include #include // strerror #include #include #include "libcgo.h" #include "libcgo_unix.h" //--to #include #include #include // strerror #include #include "libcgo.h" #include "libcgo_unix.h" //--from void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--to void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; pthread_t p; size_t size; int err; pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--from static void* threadentry(void *v) { ThreadStart ts; //--to static void* threadentry(void *v) { ThreadStart ts; extern void hitsumabushi_initializeThread(void); hitsumabushi_initializeThread(); ================================================ FILE: 1.23_linux/runtime/cgo/gcc_linux_arm64.c.patch ================================================ //--from void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--to void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 16 * 4096); // Hack for some special environments pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--from static void* threadentry(void *v) { ThreadStart ts; //--to static void* threadentry(void *v) { ThreadStart ts; // Note that threadentry will also be defined in gcc_linux.go in Go 1.22. extern void hitsumabushi_initializeThread(void); hitsumabushi_initializeThread(); ================================================ FILE: 1.23_linux/runtime/cgo/gcc_setenv.c.patch ================================================ //--from void x_cgo_setenv(char **arg) { _cgo_tsan_acquire(); setenv(arg[0], arg[1], 1); _cgo_tsan_release(); } //--to void x_cgo_setenv(char **arg) { } //--from void x_cgo_unsetenv(char **arg) { _cgo_tsan_acquire(); unsetenv(arg[0]); _cgo_tsan_release(); } //--to void x_cgo_unsetenv(char **arg) { } ================================================ FILE: 1.23_linux/runtime/cgo/gcc_sigaction.c.patch ================================================ //--from //go:build linux && (amd64 || arm64 || ppc64le) //--to //go:build linux && (arm64 || ppc64le) ================================================ FILE: 1.23_linux/runtime/cgo/hitsumabushi_clock_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp) { return clock_gettime(clk_id, tp); } ================================================ FILE: 1.23_linux/runtime/cgo/hitsumabushi_cpu_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int32_t hitsumabushi_getproccount() { return 1; } ================================================ FILE: 1.23_linux/runtime/cgo/hitsumabushi_filesystem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include #include #include "libcgo.h" #include "libcgo_unix.h" static const int kFDOffset = 100; typedef struct { const void* content; size_t content_size; size_t current; int32_t fd; } pseudo_file; // TODO: Do we need to protect this by mutex? static pseudo_file pseudo_files[100]; static pthread_mutex_t* pseudo_file_mutex() { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; return &mutex; } static int32_t open_pseudo_file(const void* content, size_t content_size) { int index = 0; int found = 0; int32_t fd = 0; pthread_mutex_lock(pseudo_file_mutex()); for (int i = 0; i < sizeof(pseudo_files) / sizeof(pseudo_file); i++) { if (pseudo_files[i].fd == 0) { index = i; found = 1; break; } } if (!found) { // Too many pseudo files are opened. pthread_mutex_unlock(pseudo_file_mutex()); return -1; } fd = index + kFDOffset; pseudo_files[index].content = content; pseudo_files[index].content_size = content_size; pseudo_files[index].current = 0; pseudo_files[index].fd = fd; pthread_mutex_unlock(pseudo_file_mutex()); return fd; } static size_t read_pseudo_file(int32_t fd, void *p, int32_t n) { int32_t index = fd - kFDOffset; pseudo_file *file = NULL; size_t rest = 0; pthread_mutex_lock(pseudo_file_mutex()); file = &pseudo_files[index]; rest = file->content_size - file->current; if (rest < n) { n = rest; } memcpy(p, file->content + file->current, n); pseudo_files[index].current += n; pthread_mutex_unlock(pseudo_file_mutex()); return n; } static void close_pseudo_file(int32_t fd) { int32_t index = fd - kFDOffset; pthread_mutex_lock(pseudo_file_mutex()); pseudo_files[index].content = NULL; pseudo_files[index].content_size = 0; pseudo_files[index].current = 0; pseudo_files[index].fd = 0; pthread_mutex_unlock(pseudo_file_mutex()); } int32_t hitsumabushi_closefd(int32_t fd) { if (fd >= kFDOffset) { close_pseudo_file(fd); return 0; } fprintf(stderr, "syscall close(%d) is not implemented\n", fd); return 0; } int32_t hitsumabushi_open(char *name, int32_t mode, int32_t perm) { const static int kENOENT = 0x2; if (strcmp(name, "/proc/self/auxv") == 0) { static const char auxv[] = "\x06\x00\x00\x00\x00\x00\x00\x00" // _AT_PAGESZ tag (6) "\x00\x10\x00\x00\x00\x00\x00\x00" // 4096 bytes per page "\x00\x00\x00\x00\x00\x00\x00\x00" // Dummy bytes "\x00\x00\x00\x00\x00\x00\x00\x00"; // Dummy bytes return open_pseudo_file(auxv, sizeof(auxv) / sizeof(char)); } if (strcmp(name, "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size") == 0) { static const char hpage_pmd_size[] = "\x30\x5c"; // '0', '\n' return open_pseudo_file(hpage_pmd_size, sizeof(hpage_pmd_size) / sizeof(char)); } fprintf(stderr, "syscall open(%s, %d, %d) is not implemented\n", name, mode, perm); return kENOENT; } int32_t hitsumabushi_read(int32_t fd, void *p, int32_t n) { const static int kEBADF = 0x9; if (fd >= kFDOffset) { return read_pseudo_file(fd, p, n); } fprintf(stderr, "syscall read(%d, %p, %d) is not implemented\n", fd, p, n); return kEBADF; } int32_t hitsumabushi_write1(uintptr_t fd, void *p, int32_t n) { static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; int32_t ret = 0; pthread_mutex_lock(&m); switch (fd) { case 1: ret = fwrite(p, 1, n, stdout); fflush(stdout); break; case 2: ret = fwrite(p, 1, n, stderr); fflush(stderr); break; default: fprintf(stderr, "syscall write(%lu, %p, %d) is not implemented\n", fd, p, n); ret = -EBADF; break; } pthread_mutex_unlock(&m); return ret; } int32_t hitsumabushi_lseek(uintptr_t fd, off_t offset, int32_t whence) { fprintf(stderr, "syscall lseek(%lu, %lu, %d) is not implemented\n", fd, offset, whence); return -ENOSYS; } int32_t hitsumabushi_fcntl(int32_t fd, int32_t cmd, int32_t arg) { if (fd == 0 || fd == 1 || fd == 2) { if (cmd == F_GETFL) { return 0; } } fprintf(stderr, "syscall fcntl(%d, %d, %d) is not implemented\n", fd, cmd, arg); return -EBADF; } int32_t hitsumabushi_fstat(int32_t fd, struct stat *stat) { fprintf(stderr, "syscall fstat(%d, %p) is not implemented\n", fd, stat); return -ENOSYS; } int32_t hitsumabushi_renameat(int32_t fd1, char* name1, int32_t fd2, char* name2) { fprintf(stderr, "syscall renameat(%d, %s, %d, %s) is not implemented\n", fd1, name1, fd2, name2); return -ENOSYS; } int32_t hitsumabushi_fstatat(int32_t fd, char* name, struct stat* p, int32_t flags) { fprintf(stderr, "syscall fstatat(%d, %s, %p, %d) is not implemented\n", fd, name, p, flags); return -ENOSYS; } ================================================ FILE: 1.23_linux/runtime/cgo/hitsumabushi_futex_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include #include #include #include static const int kPseudoFutexWait = 0; static const int kPseudoFutexWake = 1; static void pseudo_futex(uint32_t *uaddr, int mode, uint32_t val, const struct timespec *reltime) { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; int ret = 0; struct timespec abstime; if (reltime) { // We are not sure CLOCK_REALTIME is correct or not here. // However, this time limit is actually not used as the condition variable is shared by // all the threads. Before the time limit reaches, the thread wakes up in 99.9999...% cases. clock_gettime(CLOCK_REALTIME, &abstime); abstime.tv_sec += reltime->tv_sec; abstime.tv_nsec += reltime->tv_nsec; if (1000000000 <= abstime.tv_nsec) { abstime.tv_sec += 1; abstime.tv_nsec -= 1000000000; } } ret = pthread_mutex_lock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_lock failed: %d\n", ret); abort(); } switch (mode) { case kPseudoFutexWait: if (reltime) { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_timedwait(&cond, &mutex, &abstime); if (ret && ret != ETIMEDOUT) { fprintf(stderr, "pthread_cond_timedwait failed: %d\n", ret); abort(); } } } else { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_wait(&cond, &mutex); if (ret) { fprintf(stderr, "pthread_cond_wait failed: %d\n", ret); abort(); } } } break; case kPseudoFutexWake: if (val != 1) { fprintf(stderr, "val for waking must be 1 but %d\n", val); abort(); } // TODO: broadcasting is not efficient. Use a mutex for each uaddr. ret = pthread_cond_broadcast(&cond); if (ret) { fprintf(stderr, "pthread_cond_broadcast failed: %d\n", ret); abort(); } break; } ret = pthread_mutex_unlock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_unlock failed: %d\n", ret); abort(); } } int32_t hitsumabushi_futex(uint32_t *uaddr, int32_t futex_op, uint32_t val, const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3) { enum { kFutexWaitPrivate = 128, kFutexWakePrivate = 129, }; switch (futex_op) { case kFutexWaitPrivate: pseudo_futex(uaddr, kPseudoFutexWait, val, timeout); break; case kFutexWakePrivate: pseudo_futex(uaddr, kPseudoFutexWake, val, NULL); break; } // This function should return the number of awaken threads, but now it is impossible. // Just return 0. return 0; } ================================================ FILE: 1.23_linux/runtime/cgo/hitsumabushi_mem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include void* hitsumabushi_sysReserveOS(void* v, uintptr_t n); void* hitsumabushi_sysAllocOS(uintptr_t n) { return hitsumabushi_sysReserveOS(NULL, n); } void hitsumabushi_sysUnusedOS(void* v, uintptr_t n) { } void hitsumabushi_sysUsedOS(void* v, uintptr_t n) { } void hitsumabushi_sysHugePageOS(void* v, uintptr_t n) { } void hitsumabushi_sysFreeOS(void* v, uintptr_t n) { } void hitsumabushi_sysFaultOS(void* v, uintptr_t n) { } void* hitsumabushi_sysReserveOS(void* v, uintptr_t n) { if (v) { return NULL; } return calloc(n, 1); } void hitsumabushi_sysMapOS(void* v, uintptr_t n) { } ================================================ FILE: 1.23_linux/runtime/cgo/hitsumabushi_syscalls_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include // for usleep #include // for size_t #include "libcgo.h" #include "libcgo_unix.h" typedef unsigned int gid_t; extern int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp); extern int32_t hitsumabushi_getproccount(); void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { abort(); return NULL; } int munmap(void *addr, size_t length) { abort(); return 0; } int pthread_sigmask(int how, void *set, void *oldset) { // Do nothing. return 0; } int setegid(gid_t gid) { // Do nothing. return 0; } int seteuid(uid_t gid) { // Do nothing. return 0; } int setgid(gid_t gid) { // Do nothing. return 0; } int setgroups(size_t size, const gid_t *list) { // Do nothing. return 0; } int setregid(gid_t rgid, gid_t egid) { // Do nothing. return 0; } int setreuid(uid_t ruid, uid_t euid) { // Do nothing. return 0; } int setresgid(gid_t rgid, gid_t egid, gid_t sgid) { // Do nothing. return 0; } int setresuid(uid_t ruid, uid_t euid, uid_t suid) { // Do nothing. return 0; } int setuid(uid_t gid) { // Do nothing. return 0; } int sigaction(int signum, void *act, void *oldact) { // Do nothing. return 0; } int sigaddset(void *set, int signum) { // Do nothing. return 0; } int sigemptyset(void *set) { // Do nothing. return 0; } int sigfillset(void *set) { // Do nothing. return 0; } int sigismember(void *set, int signum) { // Do nothing. return 0; } uint32_t hitsumabushi_gettid() { uint64_t tid64 = (uint64_t)(pthread_self()); uint32_t tid = (uint32_t)(tid64 >> 32) ^ (uint32_t)(tid64); return tid; } int64_t hitsumabushi_nanotime1() { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_MONOTONIC, &tp); return (int64_t)(tp.tv_sec) * 1000000000ll + (int64_t)tp.tv_nsec; } int32_t hitsumabushi_osyield() { return sched_yield(); } int32_t hitsumabushi_sched_getaffinity(pid_t pid, size_t cpusetsize, void *mask) { int32_t numcpu = hitsumabushi_getproccount(); for (int32_t i = 0; i < numcpu; i += 8) ((unsigned char*)mask)[i / 8] = (unsigned char)((1u << (numcpu - i)) - 1); // https://man7.org/linux/man-pages/man2/sched_setaffinity.2.html // > On success, the raw sched_getaffinity() system call returns the // > number of bytes placed copied into the mask buffer; return (numcpu + 7) / 8; } void hitsumabushi_usleep(useconds_t usec) { usleep(usec); } void hitsumabushi_walltime1(int64_t* sec, int32_t* nsec) { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_REALTIME, &tp); *sec = tp.tv_sec; *nsec = tp.tv_nsec; } void hitsumabushi_exit(int32_t code) { exit(code); } ================================================ FILE: 1.23_linux/runtime/cgo/hitsumabushi_thread_linux.c ================================================ void hitsumabushi_initializeThread(void) { } ================================================ FILE: 1.23_linux/runtime/cgo/linux_syscall.c.patch ================================================ //--from #include #include #include #include #include "libcgo.h" //--to #include #include #include #include "libcgo.h" //--from void _cgo_libc_setegid(argset_t* x) { SET_RETVAL(setegid((gid_t) x->args[0])); } //--to void _cgo_libc_setegid(argset_t* x) { } //--from void _cgo_libc_seteuid(argset_t* x) { SET_RETVAL(seteuid((uid_t) x->args[0])); } //--to void _cgo_libc_seteuid(argset_t* x) { } //--from void _cgo_libc_setgid(argset_t* x) { SET_RETVAL(setgid((gid_t) x->args[0])); } //--to void _cgo_libc_setgid(argset_t* x) { } //--from void _cgo_libc_setgroups(argset_t* x) { SET_RETVAL(setgroups((size_t) x->args[0], (const gid_t *) x->args[1])); } //--to void _cgo_libc_setgroups(argset_t* x) { } //--from void _cgo_libc_setregid(argset_t* x) { SET_RETVAL(setregid((gid_t) x->args[0], (gid_t) x->args[1])); } //--to void _cgo_libc_setregid(argset_t* x) { } //--from void _cgo_libc_setresgid(argset_t* x) { SET_RETVAL(setresgid((gid_t) x->args[0], (gid_t) x->args[1], (gid_t) x->args[2])); } //--to void _cgo_libc_setresgid(argset_t* x) { } //--from void _cgo_libc_setreuid(argset_t* x) { SET_RETVAL(setreuid((uid_t) x->args[0], (uid_t) x->args[1])); } //--to void _cgo_libc_setreuid(argset_t* x) { } //--from void _cgo_libc_setuid(argset_t* x) { SET_RETVAL(setuid((uid_t) x->args[0])); } //--to void _cgo_libc_setuid(argset_t* x) { } ================================================ FILE: 1.23_linux/runtime/cgo/sigaction.go.patch ================================================ //--from //go:build (linux && amd64) || (freebsd && amd64) || (linux && arm64) || (linux && ppc64le) //--to //go:build (freebsd && amd64) || (linux && arm64) || (linux && ppc64le) ================================================ FILE: 1.23_linux/runtime/crash_test.go.patch ================================================ //--from func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { //--to func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { t.Skip("buildTestProg is not supported in this environment") //--from func TestPanicInlined(t *testing.T) { //--to func TestPanicInlined(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.23_linux/runtime/crash_unix_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.23_linux/runtime/debug/heapdump_test.go.patch ================================================ //--from func TestWriteHeapDumpNonempty(t *testing.T) { //--to func TestWriteHeapDumpNonempty(t *testing.T) { t.Skip("file is not supported in this environment") //--from func TestWriteHeapDumpFinalizers(t *testing.T) { //--to func TestWriteHeapDumpFinalizers(t *testing.T) { t.Skip("file is not supported in this environment") //--from func TestWriteHeapDumpTypeName(t *testing.T) { //--to func TestWriteHeapDumpTypeName(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.23_linux/runtime/debug/panic_test.go.patch ================================================ //--from func TestPanicOnFault(t *testing.T) { //--to func TestPanicOnFault(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.23_linux/runtime/debug_test.go.patch ================================================ //--from //go:build (amd64 || arm64 || ppc64le) && linux && !race //--to //go:build ignore ================================================ FILE: 1.23_linux/runtime/export_unix_test.go ================================================ // Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build unix package runtime const ( O_WRONLY = _O_WRONLY O_CREAT = _O_CREAT O_TRUNC = _O_TRUNC ) ================================================ FILE: 1.23_linux/runtime/fds_unix.go.patch ================================================ //--from func checkfds() { //--to func checkfds() { return ================================================ FILE: 1.23_linux/runtime/mem_linux.go ================================================ // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This implementation is the most fundamental and minimal allocations like Wasm. // Malloced memory regions are never freed. package runtime import ( "internal/abi" "unsafe" ) // Don't split the stack as this method may be invoked without a valid G, which // prevents us from allocating more stack. // //go:nosplit //go:cgo_unsafe_args func sysAllocOS(n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysAllocOS_trampoline)), unsafe.Pointer(&n)) return } func sysAllocOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit //go:cgo_unsafe_args func sysUnusedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUnusedOS_trampoline)), unsafe.Pointer(&v)) } func sysUnusedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysUsedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUsedOS_trampoline)), unsafe.Pointer(&v)) } func sysUsedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysHugePageOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysHugePageOS_trampoline)), unsafe.Pointer(&v)) } func sysHugePageOS_trampoline(n uintptr, size uintptr) func sysNoHugePageOS(v unsafe.Pointer, n uintptr) { } func sysHugePageCollapseOS(v unsafe.Pointer, n uintptr) { } // Don't split the stack as this function may be invoked without a valid G, // which prevents us from allocating more stack. // //go:nosplit //go:cgo_unsafe_args func sysFreeOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFreeOS_trampoline)), unsafe.Pointer(&v)) } func sysFreeOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysFaultOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFaultOS_trampoline)), unsafe.Pointer(&v)) } func sysFaultOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysReserveOS(v unsafe.Pointer, n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysReserveOS_trampoline)), unsafe.Pointer(&v)) return } func sysReserveOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit //go:cgo_unsafe_args func sysMapOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysMapOS_trampoline)), unsafe.Pointer(&v)) } func sysMapOS_trampoline(n uintptr, size uintptr) ================================================ FILE: 1.23_linux/runtime/memmove_linux_amd64_test.go.patch ================================================ //--from func TestMemmoveOverflow(t *testing.T) { //--to func TestMemmoveOverflow(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.23_linux/runtime/metrics_test.go.patch ================================================ //--from name: "runtime/debug.WriteHeapDump", fn: func(t *testing.T) { //--to name: "runtime/debug.WriteHeapDump", fn: func(t *testing.T) { t.Skip("debug.WriteHeapDump is not supported in this environment") ================================================ FILE: 1.23_linux/runtime/nbpipe_pipe2.go.patch ================================================ //--from //go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris //--to //go:build dragonfly || freebsd || netbsd || openbsd || solaris ================================================ FILE: 1.23_linux/runtime/nbpipe_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.23_linux/runtime/netpoll_epoll.go.patch ================================================ //--from //go:build linux //--to //go:build ignore ================================================ FILE: 1.23_linux/runtime/netpoll_fake.go.patch ================================================ //--from //go:build js && wasm //--to //go:build linux ================================================ FILE: 1.23_linux/runtime/norace_linux_test.go.patch ================================================ //--from func TestNewOSProc0(t *testing.T) { //--to func TestNewOSProc0(t *testing.T) { t.Skip("newosproc0 is not supported in this environment") ================================================ FILE: 1.23_linux/runtime/os_linux.go.patch ================================================ //--from import ( "internal/abi" "internal/goarch" "internal/runtime/atomic" "internal/runtime/syscall" "unsafe" ) //--to import ( "internal/abi" "internal/runtime/atomic" "internal/runtime/syscall" "unsafe" ) //--from //go:noescape func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 //--to //go:nosplit //go:cgo_unsafe_args func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 { ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(futex_trampoline)), unsafe.Pointer(&addr)) return ret } func futex_trampoline(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 //--from func sysargs(argc int32, argv **byte) { n := argc + 1 // skip over argv, envp to get to auxv for argv_index(argv, n) != nil { n++ } // skip NULL separator n++ // now argv+n is auxv auxvp := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*goarch.PtrSize)) if pairs := sysauxv(auxvp[:]); pairs != 0 { auxv = auxvp[: pairs*2 : pairs*2] return } // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } n = read(fd, noescape(unsafe.Pointer(&auxvreadbuf[0])), int32(unsafe.Sizeof(auxvreadbuf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. auxvreadbuf[len(auxvreadbuf)-2] = _AT_NULL pairs := sysauxv(auxvreadbuf[:]) auxv = auxvreadbuf[: pairs*2 : pairs*2] } //--to func sysargs(argc int32, argv **byte) { // argc/argv is not reliable on some machines. // Skip analysing them. // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } n := read(fd, noescape(unsafe.Pointer(&auxvreadbuf[0])), int32(unsafe.Sizeof(auxvreadbuf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. auxvreadbuf[len(auxvreadbuf)-2] = _AT_NULL pairs := sysauxv(auxvreadbuf[:]) auxv = auxvreadbuf[: pairs*2 : pairs*2] } //--from var urandom_dev = []byte("/dev/urandom\x00") func readRandom(r []byte) int { fd := open(&urandom_dev[0], 0 /* O_RDONLY */, 0) n := read(fd, unsafe.Pointer(&r[0]), int32(len(r))) closefd(fd) return int(n) } //--to //go:nosplit func readRandom(r []byte) int { return 0 } //--from func gettid() uint32 //--to //go:nosplit //go:cgo_unsafe_args func gettid() (tid uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(gettid_trampoline)), unsafe.Pointer(&tid)) return } func gettid_trampoline() uint32 //--from //go:noescape func sigaltstack(new, old *stackt) //--to func sigaltstack(new, old *stackt) { // Do nothing. } //--from func sigprocmask(how int32, new, old *sigset) { rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--to func sigprocmask(how int32, new, old *sigset) { // Do nothing. // rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--from func raise(sig uint32) //--to func raise(sig uint32) { // Do nothing } //--from func raiseproc(sig uint32) //--to func raiseproc(sig uint32) { // Do nothing } //--from //go:noescape func sched_getaffinity(pid, len uintptr, buf *byte) int32 //--to //go:nosplit //go:cgo_unsafe_args func sched_getaffinity(pid, len uintptr, buf *byte) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(sched_getaffinity_trampoline)), unsafe.Pointer(&pid)) } func sched_getaffinity_trampoline(pid, len uintptr, buf *byte) int32 //--from func osyield() //--to //go:nosplit //go:cgo_unsafe_args func osyield() { libcCall(unsafe.Pointer(abi.FuncPCABI0(osyield_trampoline)), nil) } func osyield_trampoline() //--from func sysSigaction(sig uint32, new, old *sigactiont) { //--to func sysSigaction(sig uint32, new, old *sigactiont) { // Do nothing. return //--from func signalM(mp *m, sig int) { tgkill(getpid(), int(mp.procid), sig) } //--to func signalM(mp *m, sig int) { // Do nothiing. } //--from func runPerThreadSyscall() { gp := getg() if gp.m.needPerThreadSyscall.Load() == 0 { return } args := perThreadSyscall r1, r2, errno := syscall.Syscall6(args.trap, args.a1, args.a2, args.a3, args.a4, args.a5, args.a6) if GOARCH == "ppc64" || GOARCH == "ppc64le" { // TODO(https://go.dev/issue/51192 ): ppc64 doesn't use r2. r2 = 0 } if errno != 0 || r1 != args.r1 || r2 != args.r2 { print("trap:", args.trap, ", a123456=[", args.a1, ",", args.a2, ",", args.a3, ",", args.a4, ",", args.a5, ",", args.a6, "]\n") print("results: got {r1=", r1, ",r2=", r2, ",errno=", errno, "}, want {r1=", args.r1, ",r2=", args.r2, ",errno=0}\n") fatal("AllThreadsSyscall6 results differ between threads; runtime corrupted") } gp.m.needPerThreadSyscall.Store(0) } //--to func runPerThreadSyscall() { // Do nothing. // needPerThreadSyscall should never be 1 as syscall_runtime_doAllThreadsSyscall is not available with Cgo. } //--append //go:linkname hitsumabushi_closefd hitsumabushi_closefd //go:cgo_import_static hitsumabushi_closefd var hitsumabushi_closefd byte //go:linkname hitsumabushi_exit hitsumabushi_exit //go:cgo_import_static hitsumabushi_exit var hitsumabushi_exit byte //go:linkname hitsumabushi_gettid hitsumabushi_gettid //go:cgo_import_static hitsumabushi_gettid var hitsumabushi_gettid byte //go:linkname hitsumabushi_nanotime1 hitsumabushi_nanotime1 //go:cgo_import_static hitsumabushi_nanotime1 var hitsumabushi_nanotime1 byte //go:linkname hitsumabushi_open hitsumabushi_open //go:cgo_import_static hitsumabushi_open var hitsumabushi_open byte //go:linkname hitsumabushi_osyield hitsumabushi_osyield //go:cgo_import_static hitsumabushi_osyield var hitsumabushi_osyield byte //go:linkname hitsumabushi_read hitsumabushi_read //go:cgo_import_static hitsumabushi_read var hitsumabushi_read byte //go:linkname hitsumabushi_sched_getaffinity hitsumabushi_sched_getaffinity //go:cgo_import_static hitsumabushi_sched_getaffinity var hitsumabushi_sched_getaffinity byte //go:linkname hitsumabushi_usleep hitsumabushi_usleep //go:cgo_import_static hitsumabushi_usleep var hitsumabushi_usleep byte //go:linkname hitsumabushi_walltime1 hitsumabushi_walltime1 //go:cgo_import_static hitsumabushi_walltime1 var hitsumabushi_walltime1 byte //go:linkname hitsumabushi_write1 hitsumabushi_write1 //go:cgo_import_static hitsumabushi_write1 var hitsumabushi_write1 byte //go:nosplit //go:cgo_unsafe_args func fcntl1(fd, cmd, arg int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fcntl_trampoline)), unsafe.Pointer(&fd)) } func fcntl_trampoline() //go:nosplit //go:cgo_unsafe_args func fstat1(fd int, stat unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstat_trampoline)), unsafe.Pointer(&fd)) } func fstat_trampoline(fd int, stat unsafe.Pointer) int32 //go:nosplit //go:cgo_unsafe_args func lseek1(fd int, offset int64, whence int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(lseek_trampoline)), unsafe.Pointer(&fd)) } func lseek_trampoline() //go:nosplit //go:cgo_unsafe_args func renameat(fd1 int, name1 unsafe.Pointer, fd2 int, name2 unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(renameat_trampoline)), unsafe.Pointer(&fd1)) } func renameat_trampoline() //go:nosplit //go:cgo_unsafe_args func fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstatat_trampoline)), unsafe.Pointer(&fd)) } func fstatat_trampoline() ================================================ FILE: 1.23_linux/runtime/panicnil_test.go.patch ================================================ //--from func TestPanicNil(t *testing.T) { //--to func TestPanicNil(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.23_linux/runtime/proc_test.go.patch ================================================ //--from func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) testGoroutineParallelism2(t, false, true) testGoroutineParallelism2(t, true, true) } //--to func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) //testGoroutineParallelism2(t, false, true) //testGoroutineParallelism2(t, true, true) } ================================================ FILE: 1.23_linux/runtime/rand_test.go.patch ================================================ //--from func TestReadRandom(t *testing.T) { //--to func TestReadRandom(t *testing.T) { t.Skip("readRandom is not available in this environment") ================================================ FILE: 1.23_linux/runtime/runtime1.go.patch ================================================ //--from func argv_index(argv **byte, i int32) *byte { return *(**byte)(add(unsafe.Pointer(argv), uintptr(i)*goarch.PtrSize)) } //--to func argv_index(argv **byte, i int32) *byte { return nil } //--from func args(c int32, v **byte) { argc = c argv = v sysargs(c, v) } //--to func args(c int32, v **byte) { // In the original code, physPageSize is determined at sysargs. // Hitsumabushi gives an initial value for physPageSize at its declaration, so sysargs doesn't have to be called. } //--append // Expose the entry point for some special environments. //go:cgo_export_static _rt0_amd64_linux_lib //go:cgo_export_dynamic _rt0_amd64_linux_lib ================================================ FILE: 1.23_linux/runtime/runtime_linux_test.go.patch ================================================ //--from func TestMincoreErrorSign(t *testing.T) { //--to func TestMincoreErrorSign(t *testing.T) { t.Skip("mincore is not supported in this environment") ================================================ FILE: 1.23_linux/runtime/runtime_mmap_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.23_linux/runtime/runtime_test.go.patch ================================================ //--from func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { //--to func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { t.Skip("catching faults is not supported in this environment") ================================================ FILE: 1.23_linux/runtime/runtime_unix_test.go.patch ================================================ //--from //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || plan9 //--to //go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || plan9 ================================================ FILE: 1.23_linux/runtime/stack_test.go.patch ================================================ //--from func TestDeferLeafSigpanic(t *testing.T) { //--to func TestDeferLeafSigpanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestStackWrapperStackPanic(t *testing.T) { //--to func TestStackWrapperStackPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.23_linux/runtime/stubs2.go.patch ================================================ //--from import ( "internal/runtime/atomic" "unsafe" ) //--to import ( "internal/abi" "internal/runtime/atomic" "unsafe" ) //--from func read(fd int32, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func read(fd int32, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(read_trampoline)), unsafe.Pointer(&fd)) } func read_trampoline(fd int32, p unsafe.Pointer, n int32) int32 //--from func closefd(fd int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func closefd(fd int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(closefd_trampoline)), unsafe.Pointer(&fd)) } func closefd_trampoline(fd int32) int32 //--from func exit(code int32) //--to //go:nosplit //go:cgo_unsafe_args func exit(code int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(exit_trampoline)), unsafe.Pointer(&code)) } func exit_trampoline(code int32) //--from func usleep(usec uint32) //--to //go:nosplit //go:cgo_unsafe_args func usleep(usec uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } func usleep_trampoline(usec uint32) //--from //go:nosplit func usleep_no_g(usec uint32) { usleep(usec) } //--to //go:nosplit //go:cgo_unsafe_args func usleep_no_g(usec uint32) { asmcgocall_no_g(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } //--from //go:noescape func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func write1(fd uintptr, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(write1_trampoline)), unsafe.Pointer(&fd)) } func write1_trampoline(fd uintptr, p unsafe.Pointer, n int32) int32 //--from //go:noescape func open(name *byte, mode, perm int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func open(name *byte, mode, perm int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(open_trampoline)), unsafe.Pointer(&name)) } func open_trampoline(name *byte, mode, perm int32) int32 ================================================ FILE: 1.23_linux/runtime/stubs3.go.patch ================================================ //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func nanotime1() int64 //--to //go:nosplit //go:cgo_unsafe_args func nanotime1() (now int64) { libcCall(unsafe.Pointer(abi.FuncPCABI0(nanotime1_trampoline)), unsafe.Pointer(&now)) return } func nanotime1_trampoline() int64 ================================================ FILE: 1.23_linux/runtime/sys_libc.go.patch ================================================ //--from //go:build darwin || (openbsd && !mips64) //--to //go:build darwin || (openbsd && !mips64) || linux ================================================ FILE: 1.23_linux/runtime/sys_linux_amd64.s.patch ================================================ //--from TEXT runtime·open(SB),NOSPLIT,$0-20 // This uses openat instead of open, because Android O blocks open. MOVL $AT_FDCWD, DI // AT_FDCWD, so this acts like open MOVQ name+0(FP), SI MOVL mode+8(FP), DX MOVL perm+12(FP), R10 MOVL $SYS_openat, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVL 8(DI), SI // arg 2 flags MOVL 12(DI), DX // arg 3 mode MOVQ 0(DI), DI // arg 1 pathname XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_open(SB) MOVQ AX, 16(BX) POPQ BP RET //--from TEXT runtime·futex(SB),NOSPLIT,$0 MOVQ addr+0(FP), DI MOVL op+8(FP), SI MOVL val+12(FP), DX MOVQ ts+16(FP), R10 MOVQ addr2+24(FP), R8 MOVL val3+32(FP), R9 MOVL $SYS_futex, AX SYSCALL MOVL AX, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 addr MOVL 8(BX), SI // arg 2 op MOVL 12(BX), DX // arg 3 val MOVQ 16(BX), CX // arg 4 ts MOVQ 24(BX), R8 // arg 5 addr2 MOVL 32(BX), R9 // arg 6 val3 CALL hitsumabushi_futex(SB) MOVL AX, 40(BX) POPQ BP RET //--from TEXT runtime·exit(SB),NOSPLIT,$0-4 MOVL code+0(FP), DI MOVL $SYS_exit_group, AX SYSCALL RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 exit status CALL hitsumabushi_exit(SB) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·read(SB),NOSPLIT,$0-28 MOVL fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_read, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 0(BX), DI // arg 1 fd MOVQ 8(BX), SI // arg 2 buf MOVQ 16(BX), DX // arg 3 count CALL hitsumabushi_read(SB) MOVQ AX, 24(BX) // return value POPQ BP RET //--from TEXT runtime·closefd(SB),NOSPLIT,$0-12 MOVL fd+0(FP), DI MOVL $SYS_close, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 fd CALL hitsumabushi_closefd(SB) POPQ BP RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVL $SYS_gettid, AX SYSCALL MOVL AX, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_gettid(SB) POPQ BP RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT,$0 MOVQ new+0(FP), DI MOVQ old+8(FP), SI MOVQ $SYS_sigaltstack, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $0xf1, 0xf1 // crash RET //--to TEXT runtime·sigaltstack_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 old MOVQ 0(DI), DI // arg 1 new CALL hitsumabushi_sigaltstack(SB) TESTQ AX, AX JEQ 2(PC) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·raise(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, R12 MOVL $SYS_gettid, AX SYSCALL MOVL AX, SI // arg 2 tid MOVL R12, DI // arg 1 pid MOVL sig+0(FP), DX // arg 3 MOVL $SYS_tgkill, AX SYSCALL RET //--to TEXT runtime·raise_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 signal CALL hitsumabushi_raise(SB) POPQ BP RET //--from TEXT runtime·raiseproc(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, DI // arg 1 pid MOVL sig+0(FP), SI // arg 2 MOVL $SYS_kill, AX SYSCALL RET //--to TEXT runtime·raiseproc_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), BX // signal CALL hitsumabushi_getpid(SB) MOVL AX, DI // arg 1 pid MOVL BX, SI // arg 2 signal CALL hitsumabushi_kill(SB) POPQ BP RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0 MOVQ pid+0(FP), DI MOVQ len+8(FP), SI MOVQ buf+16(FP), DX MOVL $SYS_sched_getaffinity, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 len MOVQ 16(DI), DX // arg 3 buf MOVQ 0(DI), DI // arg 1 pid CALL hitsumabushi_sched_getaffinity(SB) POPQ BP RET //--from TEXT runtime·osyield(SB),NOSPLIT,$0 MOVL $SYS_sched_yield, AX SYSCALL RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_osyield(SB) POPQ BP RET //--from TEXT runtime·usleep(SB),NOSPLIT,$16 MOVL $0, DX MOVL usec+0(FP), AX MOVL $1000000, CX DIVL CX MOVQ AX, 0(SP) MOVL $1000, AX // usec to nsec MULL DX MOVQ AX, 8(SP) // nanosleep(&ts, 0) MOVQ SP, DI MOVL $0, SI MOVL $SYS_nanosleep, AX SYSCALL RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 usec CALL hitsumabushi_usleep(SB) POPQ BP RET //--from TEXT runtime·write1(SB),NOSPLIT,$0-28 MOVQ fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_write, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 p MOVQ 16(DI), DX // arg 3 n MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_write1(SB) POPQ BP RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$16-8 // We don't know how much stack space the VDSO code will need, // so switch to g0. // In particular, a kernel configured with CONFIG_OPTIMIZE_INLINING=n // and hardening can use a full page of stack space in gettime_sym // due to stack probes inserted to avoid stack/heap collisions. // See issue #20427. MOVQ SP, R12 // Save old SP; R12 unchanged by C code. MOVQ g_m(R14), BX // BX unchanged by C code. // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVQ m_vdsoPC(BX), CX MOVQ m_vdsoSP(BX), DX MOVQ CX, 0(SP) MOVQ DX, 8(SP) LEAQ ret+0(FP), DX MOVQ -8(DX), CX MOVQ CX, m_vdsoPC(BX) MOVQ DX, m_vdsoSP(BX) CMPQ R14, m_curg(BX) // Only switch if on curg. JNE noswitch MOVQ m_g0(BX), DX MOVQ (g_sched+gobuf_sp)(DX), SP // Set SP to g0 stack noswitch: SUBQ $16, SP // Space for results ANDQ $~15, SP // Align for C code MOVL $1, DI // CLOCK_MONOTONIC LEAQ 0(SP), SI MOVQ runtime·vdsoClockgettimeSym(SB), AX CMPQ AX, $0 JEQ fallback CALL AX ret: MOVQ 0(SP), AX // sec MOVQ 8(SP), DX // nsec MOVQ R12, SP // Restore real SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVQ 8(SP), CX MOVQ CX, m_vdsoSP(BX) MOVQ 0(SP), CX MOVQ CX, m_vdsoPC(BX) // sec is in AX, nsec in DX // return nsec in AX IMULQ $1000000000, AX ADDQ DX, AX MOVQ AX, ret+0(FP) RET fallback: MOVQ $SYS_clock_gettime, AX SYSCALL JMP ret //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ DI, BX // BX is callee-saved MOVQ SP, BP CALL hitsumabushi_nanotime1(SB) MOVQ AX, 0(BX) POPQ BP RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(DI), DI CALL hitsumabushi_sysAllocOS(SB) MOVQ AX, 8(BX) POPQ BP RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUnusedOS(SB) POPQ BP RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUsedOS(SB) POPQ BP RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysHugePageOS(SB) POPQ BP RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFreeOS(SB) POPQ BP RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFaultOS(SB) POPQ BP RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysReserveOS(SB) MOVQ AX, 16(BX) POPQ BP RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysMapOS(SB) POPQ BP RET TEXT runtime·walltime1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_walltime1(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 cmd MOVQ 16(DI), DX // arg 3 arg MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_fcntl(SB) POPQ BP RET TEXT runtime·fstat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 stat MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_fstat(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·lseek_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 offset MOVQ 16(DI), DX // arg 3 whence MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_lseek(SB) MOVQ AX, 24(BX) // return value POPQ BP RET TEXT runtime·renameat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_renameat(SB) MOVL AX, 32(BX) POPQ BP RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_fstatat(SB) MOVL AX, 32(BX) POPQ BP RET ================================================ FILE: 1.23_linux/runtime/sys_linux_arm64.s.patch ================================================ //--from #define SYS_exit 93 #define SYS_read 63 #define SYS_write 64 #define SYS_openat 56 #define SYS_close 57 #define SYS_pipe2 59 #define SYS_nanosleep 101 #define SYS_mmap 222 #define SYS_munmap 215 #define SYS_setitimer 103 #define SYS_clone 220 #define SYS_sched_yield 124 #define SYS_rt_sigreturn 139 #define SYS_rt_sigaction 134 #define SYS_rt_sigprocmask 135 #define SYS_sigaltstack 132 #define SYS_madvise 233 #define SYS_mincore 232 #define SYS_getpid 172 #define SYS_gettid 178 #define SYS_kill 129 #define SYS_tgkill 131 #define SYS_futex 98 #define SYS_sched_getaffinity 123 #define SYS_exit_group 94 #define SYS_clock_gettime 113 #define SYS_faccessat 48 #define SYS_socket 198 #define SYS_connect 203 #define SYS_brk 214 #define SYS_timer_create 107 #define SYS_timer_settime 110 #define SYS_timer_delete 111 //--to #define SYS_exit 2147483647 #define SYS_read 2147483647 #define SYS_write 2147483647 #define SYS_openat 2147483647 #define SYS_close 2147483647 #define SYS_pipe2 2147483647 #define SYS_nanosleep 2147483647 #define SYS_mmap 2147483647 #define SYS_munmap 2147483647 #define SYS_setitimer 2147483647 #define SYS_clone 2147483647 #define SYS_sched_yield 2147483647 #define SYS_rt_sigreturn 2147483647 #define SYS_rt_sigaction 2147483647 #define SYS_rt_sigprocmask 2147483647 #define SYS_sigaltstack 2147483647 #define SYS_madvise 2147483647 #define SYS_mincore 2147483647 #define SYS_getpid 2147483647 #define SYS_gettid 2147483647 #define SYS_kill 2147483647 #define SYS_tgkill 2147483647 #define SYS_futex 2147483647 #define SYS_sched_getaffinity 2147483647 #define SYS_exit_group 2147483647 #define SYS_clock_gettime 2147483647 #define SYS_faccessat 2147483647 #define SYS_socket 2147483647 #define SYS_connect 2147483647 #define SYS_brk 2147483647 #define SYS_timer_create 2147483647 #define SYS_timer_settime 2147483647 #define SYS_timer_delete 2147483647 //--from TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0-4 MOVW code+0(FP), R0 MOVD $SYS_exit_group, R8 SVC RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_exit(SB) RET //--from TEXT runtime·open(SB),NOSPLIT|NOFRAME,$0-20 MOVD $AT_FDCWD, R0 MOVD name+0(FP), R1 MOVW mode+8(FP), R2 MOVW perm+12(FP), R3 MOVD $SYS_openat, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_open(SB) RET //--from TEXT runtime·closefd(SB),NOSPLIT|NOFRAME,$0-12 MOVW fd+0(FP), R0 MOVD $SYS_close, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT,$0-12 MOVW 0(R0), R0 BL hitsumabushi_closefd(SB) RET //--from TEXT runtime·write1(SB),NOSPLIT|NOFRAME,$0-28 MOVD fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_write, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_write1(SB) RET //--from TEXT runtime·read(SB),NOSPLIT|NOFRAME,$0-28 MOVW fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_read, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_read(SB) RET //--from TEXT runtime·usleep(SB),NOSPLIT,$24-4 MOVWU usec+0(FP), R3 MOVD R3, R5 MOVW $1000000, R4 UDIV R4, R3 MOVD R3, 8(RSP) MUL R3, R4 SUB R4, R5 MOVW $1000, R4 MUL R4, R5 MOVD R5, 16(RSP) // nanosleep(&ts, 0) ADD $8, RSP, R0 MOVD $0, R1 MOVD $SYS_nanosleep, R8 SVC RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_usleep(SB) RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVD $SYS_gettid, R8 SVC MOVW R0, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_gettid(SB) MOVW R0, 0(R19) // return value RET //--from TEXT runtime·raise(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R19 MOVD $SYS_gettid, R8 SVC MOVW R0, R1 // arg 2 tid MOVW R19, R0 // arg 1 pid MOVW sig+0(FP), R2 // arg 3 MOVD $SYS_tgkill, R8 SVC RET //--to //--from TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R0 // arg 1 pid MOVW sig+0(FP), R1 // arg 2 MOVD $SYS_kill, R8 SVC RET //--to //--from TEXT runtime·walltime(SB),NOSPLIT,$24-12 MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $16, R1 BIC $15, R1 // Align for C code MOVD R1, RSP MOVW $CLOCK_REALTIME, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) MOVD R3, sec+0(FP) MOVW R5, nsec+8(FP) RET //--to TEXT runtime·walltime1_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_walltime1(SB) RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$24-8 MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $32, R1 BIC $15, R1 MOVD R1, RSP MOVW $CLOCK_MONOTONIC, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) // sec is in R3, nsec in R5 // return nsec in R3 MOVD $1000000000, R4 MUL R4, R3 ADD R5, R3 MOVD R3, ret+0(FP) RET //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_nanotime1(SB) MOVD R0, 0(R19) // return value RET //--from TEXT runtime·futex(SB),NOSPLIT|NOFRAME,$0 MOVD addr+0(FP), R0 MOVW op+8(FP), R1 MOVW val+12(FP), R2 MOVD ts+16(FP), R3 MOVD addr2+24(FP), R4 MOVW val3+32(FP), R5 MOVD $SYS_futex, R8 SVC MOVW R0, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 16(R0), R3 MOVD 24(R0), R4 MOVW 32(R0), R5 MOVD 0(R0), R0 BL hitsumabushi_futex(SB) RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT|NOFRAME,$0 MOVD new+0(FP), R0 MOVD old+8(FP), R1 MOVD $SYS_sigaltstack, R8 SVC CMN $4095, R0 BCC ok MOVD $0, R0 MOVD R0, (R0) // crash ok: RET //--to //--from TEXT runtime·osyield(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_sched_yield, R8 SVC RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT,$0 BL hitsumabushi_osyield(SB) RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT|NOFRAME,$0 MOVD pid+0(FP), R0 MOVD len+8(FP), R1 MOVD buf+16(FP), R2 MOVD $SYS_sched_getaffinity, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVD 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_sched_getaffinity(SB) RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 0(R0), R0 BL hitsumabushi_sysAllocOS(SB) MOVD R0, 8(R19) // return value RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUnusedOS(SB) RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUsedOS(SB) RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysHugePageOS(SB) RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFreeOS(SB) RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFaultOS(SB) RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysReserveOS(SB) MOVD R0, 16(R19) // return value RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysMapOS(SB) RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVW 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_fcntl(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·fstat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 0(R0), R0 BL hitsumabushi_fstat(SB) MOVW R0, 16(R19) // return value RET TEXT runtime·lseek_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_lseek(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·renameat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_renameat(SB) MOVW R0, 32(R19) // return value RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_fstatat(SB) MOVW R0, 32(R19) // return value RET ================================================ FILE: 1.23_linux/runtime/time_linux_amd64.s.patch ================================================ //--from //go:build !faketime //--to //go:build ignore ================================================ FILE: 1.23_linux/runtime/timeasm.go.patch ================================================ //--from //go:build !faketime && (windows || (linux && amd64)) //--to //go:build !faketime && windows ================================================ FILE: 1.23_linux/runtime/timestub.go.patch ================================================ //--from //go:build !faketime && !windows && !(linux && amd64) //--to //go:build !faketime && !windows ================================================ FILE: 1.23_linux/runtime/timestub2.go.patch ================================================ //--from //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !wasip1 && !windows && !(linux && amd64) //--to //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !wasip1 && !windows //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func walltime() (sec int64, nsec int32) //--to func walltime() (sec int64, nsec int32) { walltime1(&sec, &nsec) return } //go:nosplit //go:cgo_unsafe_args func walltime1(sec *int64, nsec *int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(walltime1_trampoline)), unsafe.Pointer(&sec)) } func walltime1_trampoline(sec *int64, nsec *int32) ================================================ FILE: 1.23_linux/runtime/traceback_test.go.patch ================================================ //--from func TestTracebackInlined(t *testing.T) { //--to func TestTracebackInlined(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.23_linux/strconv/fp_test.go.patch ================================================ //--from func TestFp(t *testing.T) { //--to func TestFp(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.23_linux/sync/atomic/atomic_test.go.patch ================================================ //--from func TestStoreLoadSeqCst32(t *testing.T) { //--to func TestStoreLoadSeqCst32(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") //--from func TestStoreLoadSeqCst64(t *testing.T) { //--to func TestStoreLoadSeqCst64(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") //--from func TestNilDeref(t *testing.T) { //--to func TestNilDeref(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.23_linux/syscall/hitsumabushi_stubs_linux_amd64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_FSTATAT = 0xffffffffffffffff // Stub: on amd64 Go uses SYS_NEWFSTATAT instead ) ================================================ FILE: 1.23_linux/syscall/hitsumabushi_stubs_linux_arm64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_NEWFSTATAT = 0xffffffffffffffff // Stub: on arm64 Go uses SYS_FSTATAT instead ) ================================================ FILE: 1.23_linux/syscall/rlimit.go.patch ================================================ //--from func init() { var lim Rlimit if err := Getrlimit(RLIMIT_NOFILE, &lim); err == nil && lim.Cur != lim.Max { origRlimitNofile.Store(&lim) nlim := lim nlim.Cur = nlim.Max adjustFileLimit(&nlim) setrlimit(RLIMIT_NOFILE, &nlim) } } //--to func init() { } ================================================ FILE: 1.23_linux/syscall/syscall_linux.go.patch ================================================ //--from func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() // N.B. Calling RawSyscall here is unsafe with atomic coverage // instrumentation and race mode. // // Coverage instrumentation will add a sync/atomic call to RawSyscall. // Race mode will add race instrumentation to sync/atomic. Race // instrumentation requires a P, which we no longer have. // // RawSyscall6 is fine because it is implemented in assembly and thus // has no coverage instrumentation. // // This is typically not a problem in the runtime because cmd/go avoids // adding coverage instrumentation to the runtime in race mode. r1, r2, err = RawSyscall6(trap, a1, a2, a3, 0, 0, 0) runtime_exitsyscall() return } //--to func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FCNTL: r = fcntl1(a1, a2, a3) case SYS_FSTAT: r = fstat1(a1, unsafe.Pointer(a2)) case SYS_READ: r = runtime_read(uintptr(a1), unsafe.Pointer(a2), int32(a3)) case SYS_WRITE: r = write1(a1, unsafe.Pointer(a2), int32(a3)) case SYS_LSEEK: r = lseek1(a1, int64(a2), int32(a3)) case SYS_CLOSE: r = runtime_closefd(int32(a1)) case SYS_MKDIRAT: println("syscall mkdirat() is not implemented") // Default to permission denied. TODO: implement this return 0, 0, EPERM case SYS_GETDENTS64: println("syscall getdents64() is not implemented") // Default to empty directory. TODO: implement this return 0, 0, 0 default: println("unimplemented syscall at runtime.Syscall", trap) panic("syscall.Syscall") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //go:linkname open runtime.open func open(name *byte, mode, perm int32) int32 //go:linkname write1 runtime.write1 func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname fcntl1 runtime.fcntl1 func fcntl1(fd uintptr, a uintptr, b uintptr) int32 //go:linkname fstat1 runtime.fstat1 func fstat1(fd uintptr, p unsafe.Pointer) int32 //go:linkname lseek1 runtime.lseek1 func lseek1(fd uintptr, offset int64, whence int32) int32 //go:linkname runtime_read runtime.read func runtime_read(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname runtime_closefd runtime.closefd func runtime_closefd(fd int32) int32 //go:linkname runtime_fstatat runtime.fstatat func runtime_fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 //go:linkname runtime_renameat runtime.renameat func runtime_renameat(fd1 uintptr, name1 unsafe.Pointer, fd2 uintptr, name2 unsafe.Pointer) int32 //--from func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() r1, r2, err = RawSyscall6(trap, a1, a2, a3, a4, a5, a6) runtime_exitsyscall() return } //--to func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FSTATAT, SYS_NEWFSTATAT: r = runtime_fstatat(uintptr(a1), unsafe.Pointer(a2), unsafe.Pointer(a3), int32(a4)) case SYS_RENAMEAT: r = runtime_renameat(uintptr(a1), unsafe.Pointer(a2), uintptr(a3), unsafe.Pointer(a4)) default: println("unimplemented syscall at runtime.Syscall6", trap) panic("syscall.Syscall6") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //--from func Open(path string, mode int, perm uint32) (fd int, err error) { return openat(_AT_FDCWD, path, mode|O_LARGEFILE, perm) } //--to func Open(path string, mode int, perm uint32) (fd int, err error) { p0, err := BytePtrFromString(path) if err != nil { return -1, errnoErr(EINVAL) } fd = int(open(p0, int32(mode|O_LARGEFILE), int32(perm))) if fd < 0 { return -1, errnoErr(ENOENT) } return } ================================================ FILE: 1.23_linux/testing/run_example.go ================================================ package testing func runExample(eg InternalExample) (ok bool) { // Do nothing. // TODO: Implement os.Pipe2 and use this here. return true } ================================================ FILE: 1.23_linux/time/format_test.go.patch ================================================ //--from func TestParseInLocation(t *testing.T) { //--to func TestParseInLocation(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationZipFile(t *testing.T) { //--to func TestLoadLocationZipFile(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.23_linux/time/internal_test.go.patch ================================================ //--from func initTestingZone() { // For hermeticity, use only tzinfo source from the test's GOROOT, // not the system sources and not whatever GOROOT may happen to be // set in the process's environment (if any). // This test runs in GOROOT/src/time, so GOROOT is "../..", // but it is theoretically possible sources := []string{"../../lib/time/zoneinfo.zip"} z, err := loadLocation("America/Los_Angeles", sources) if err != nil { panic("cannot load America/Los_Angeles for testing: " + err.Error() + "; you may want to use -tags=timetzdata") } z.name = "Local" localLoc = *z } //--to func initTestingZone() { // Data from the playground. // https://go.dev/play/p/VGXU57KZZ-x // name is replaced with "Local". // cachStart, cacheEnd, and cacheZone are removed. localLoc = Location{name:"Local",zone:[]zone{zone{name:"LMT", offset:-28378, isDST:false}, zone{name:"PDT", offset:-25200, isDST:true}, zone{name:"PST", offset:-28800, isDST:false}, zone{name:"PWT", offset:-25200, isDST:true}, zone{name:"PPT", offset:-25200, isDST:true}}, tx:[]zoneTrans{zoneTrans{when:-576460752303423488, index:0x0, isstd:false, isutc:false}, zoneTrans{when:-2717640000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1633269600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-1615129200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1601820000, index:0x1, isstd:true, isutc:true}, zoneTrans{when:-1583679600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-880207200, index:0x3, isstd:false, isutc:false}, zoneTrans{when:-769395600, index:0x4, isstd:false, isutc:false}, zoneTrans{when:-765385200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-687967140, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-662655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-620838000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-608137200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-589388400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-576082800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-557938800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-544633200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-526489200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-513183600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-495039600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-481734000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-463590000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-450284400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-431535600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-418230000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-400086000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-386780400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-368636400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-355330800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-337186800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-323881200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-305737200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-292431600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-273682800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-260982000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-242233200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-226508400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-210783600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-195058800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-179334000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-163609200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-147884400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-131554800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-116434800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-100105200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-84376800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-68655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-52927200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-37206000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-21477600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-5756400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:9972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:25693200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:41421600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:57747600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:73476000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:89197200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:104925600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:120646800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:126698400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:152096400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:162381600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:183546000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:199274400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:215600400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:230724000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:247050000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:262778400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:278499600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:294228000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:309949200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:325677600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:341398800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:357127200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:372848400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:388576800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:404902800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:420026400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:436352400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:452080800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:467802000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:483530400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:499251600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:514980000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:530701200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:544615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:562150800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:576064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:594205200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:607514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:625654800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:638964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:657104400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:671018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:688554000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:702468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:720003600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:733917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:752058000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:765367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:783507600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:796816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:814957200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:828871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:846406800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:860320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:877856400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:891770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:909306000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:923220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:941360400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:954669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:972810000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:986119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1004259600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1018173600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1035709200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1049623200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1067158800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1081072800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1099213200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1112522400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1130662800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1143972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1162112400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1173607200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1194166800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1205056800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1225616400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1236506400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1257066000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1268560800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1289120400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1300010400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1320570000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1331460000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1352019600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1362909600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1383469200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1394359200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1414918800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1425808800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1446368400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1457863200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1478422800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1489312800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1509872400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1520762400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1541322000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1552212000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1572771600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1583661600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1604221200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1615716000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1636275600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1647165600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1667725200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1678615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1699174800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1710064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1730624400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1741514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1762074000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1772964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1793523600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1805018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1825578000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1836468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1857027600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1867917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1888477200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1899367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1919926800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1930816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1951376400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1962871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1983430800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1994320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2014880400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2025770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2046330000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2057220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2077779600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2088669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2109229200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2120119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2140678800, index:0x2, isstd:false, isutc:false}}, extend:"PST8PDT,M3.2.0,M11.1.0"} } ================================================ FILE: 1.23_linux/time/sleep_test.go.patch ================================================ //--from func TestSleep(t *testing.T) { //--to func TestSleep(t *testing.T) { t.Skip("Interrupt (syscall.Kill) is not supported in this environment") //--from func TestIssue5745(t *testing.T) { //--to func TestIssue5745(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.23_linux/time/time_test.go.patch ================================================ //--from func TestLoadFixed(t *testing.T) { //--to func TestLoadFixed(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestTimeIsDST(t *testing.T) { //--to func TestTimeIsDST(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestTimeWithZoneTransition(t *testing.T) { //--to func TestTimeWithZoneTransition(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestMarshalBinaryVersion2(t *testing.T) { //--to func TestMarshalBinaryVersion2(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.23_linux/time/tzdata_test.go.patch ================================================ //--from func TestEmbeddedTZData(t *testing.T) { //--to func TestEmbeddedTZData(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.23_linux/time/zoneinfo_test.go.patch ================================================ //--from func TestEnvVarUsage(t *testing.T) { //--to func TestEnvVarUsage(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestBadLocationErrMsg(t *testing.T) { //--to func TestBadLocationErrMsg(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestVersion3(t *testing.T) { //--to func TestVersion3(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestFirstZone(t *testing.T) { //--to func TestFirstZone(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationFromTZData(t *testing.T) { //--to func TestLoadLocationFromTZData(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestEarlyLocation(t *testing.T) { //--to func TestEarlyLocation(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationFromTZDataSlim(t *testing.T) { //--to func TestLoadLocationFromTZDataSlim(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.23_linux/time/zoneinfo_unix.go.patch ================================================ //--from import ( "syscall" ) //--to //--from func initLocal() { // consult $TZ to find the time zone to use. // no $TZ means use the system default /etc/localtime. // $TZ="" means use UTC. // $TZ="foo" or $TZ=":foo" if foo is an absolute path, then the file pointed // by foo will be used to initialize timezone; otherwise, file // /usr/share/zoneinfo/foo will be used. tz, ok := syscall.Getenv("TZ") switch { case !ok: z, err := loadLocation("localtime", []string{"/etc"}) if err == nil { localLoc = *z localLoc.name = "Local" return } case tz != "": if tz[0] == ':' { tz = tz[1:] } if tz != "" && tz[0] == '/' { if z, err := loadLocation(tz, []string{""}); err == nil { localLoc = *z if tz == "/etc/localtime" { localLoc.name = "Local" } else { localLoc.name = tz } return } } else if tz != "" && tz != "UTC" { if z, err := loadLocation(tz, platformZoneSources); err == nil { localLoc = *z return } } } // Fall back to UTC. localLoc.name = "UTC" } //--to func initLocal() { localLoc.name = "UTC" } ================================================ FILE: 1.23_linux/time/zoneinfo_unix_test.go.patch ================================================ //--from func TestEnvTZUsage(t *testing.T) { //--to func TestEnvTZUsage(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.23_windows/internal/testenv/exec.go.patch ================================================ //--from func tryExec() error { //--to func tryExec() error { return fmt.Errorf("can't probe for exec support") ================================================ FILE: 1.23_windows/internal/testenv/testenv.go.patch ================================================ //--from func HasGoBuild() bool { //--to func HasGoBuild() bool { return false ================================================ FILE: 1.23_windows/runtime/cgo/gcc_windows_amd64.c.patch ================================================ //--from static void threadentry(void *v) { ThreadStart ts; //--to static int getproccount() { static int proccount = 0; if (!proccount) { SYSTEM_INFO info; GetSystemInfo(&info); proccount = info.dwNumberOfProcessors; } return proccount; } static void threadentry(void *v) { ThreadStart ts; SetThreadAffinityMask(GetCurrentThread(), (1< //--to //--append #define fprintf dummy_fprintf // TODO: Use OutputDebugMessage. #define dummy_fprintf(stream, format, ...) ================================================ FILE: 1.23_windows/runtime/os_windows.go.patch ================================================ //--from //go:cgo_import_dynamic runtime._GetConsoleMode GetConsoleMode%2 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._SetConsoleCtrlHandler SetConsoleCtrlHandler%2 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._WerGetFlags WerGetFlags%2 "kernel32.dll" //go:cgo_import_dynamic runtime._WerSetFlags WerSetFlags%1 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._WriteConsoleW WriteConsoleW%5 "kernel32.dll" //--to //go:cgo_import_dynamic runtime._OutputDebugStringW OutputDebugStringW%1 "kernel32.dll" //--from _GetConsoleMode, //--to //--from _SetConsoleCtrlHandler, //--to //--from _WerGetFlags, _WerSetFlags, //--to //--from _WriteConsoleW, //--to _OutputDebugStringW, //--from // We call these all the way here, late in init, so that malloc works // for the callback functions these generate. var fn any = ctrlHandler ctrlHandlerPC := compileCallback(*efaceOf(&fn), true) stdcall2(_SetConsoleCtrlHandler, ctrlHandlerPC, 1) //--to //--from func write1(fd uintptr, buf unsafe.Pointer, n int32) int32 { const ( _STD_OUTPUT_HANDLE = ^uintptr(10) // -11 _STD_ERROR_HANDLE = ^uintptr(11) // -12 ) var handle uintptr switch fd { case 1: handle = stdcall1(_GetStdHandle, _STD_OUTPUT_HANDLE) case 2: handle = stdcall1(_GetStdHandle, _STD_ERROR_HANDLE) default: // assume fd is real windows handle. handle = fd } isASCII := true b := (*[1 << 30]byte)(buf)[:n] for _, x := range b { if x >= 0x80 { isASCII = false break } } if !isASCII { var m uint32 isConsole := stdcall2(_GetConsoleMode, handle, uintptr(unsafe.Pointer(&m))) != 0 // If this is a console output, various non-unicode code pages can be in use. // Use the dedicated WriteConsole call to ensure unicode is printed correctly. if isConsole { return int32(writeConsole(handle, buf, n)) } } var written uint32 stdcall5(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--to func write1(fd uintptr, buf unsafe.Pointer, n int32) int32 { const ( _STD_OUTPUT_HANDLE = ^uintptr(10) // -11 _STD_ERROR_HANDLE = ^uintptr(11) // -12 ) var handle uintptr switch fd { case 1: handle = stdcall1(_GetStdHandle, _STD_OUTPUT_HANDLE) case 2: handle = stdcall1(_GetStdHandle, _STD_ERROR_HANDLE) default: // assume fd is real windows handle. handle = fd } if fd == 1 || fd == 2 { // Note that handle is not used anyway. return int32(writeConsole(handle, buf, n)) } var written uint32 stdcall5(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--from func writeConsoleUTF16(handle uintptr, b []uint16) { l := uint32(len(b)) if l == 0 { return } var written uint32 stdcall5(_WriteConsoleW, handle, uintptr(unsafe.Pointer(&b[0])), uintptr(l), uintptr(unsafe.Pointer(&written)), 0, ) return } //--to func writeConsoleUTF16(handle uintptr, b []uint16) { b = b[:len(b)+1] b[len(b)-1] = 0 l := uint32(len(b)) if l <= 1 { return } stdcall1(_OutputDebugStringW, uintptr(unsafe.Pointer(&b[0])), ) return } ================================================ FILE: 1.23_windows/runtime/signal_windows.go.patch ================================================ //--from func preventErrorDialogs() { errormode := stdcall0(_GetErrorMode) stdcall1(_SetErrorMode, errormode|_SEM_FAILCRITICALERRORS|_SEM_NOGPFAULTERRORBOX|_SEM_NOOPENFILEERRORBOX) // Disable WER fault reporting UI. // Do this even if WER is disabled as a whole, // as WER might be enabled later with setTraceback("wer") // and we still want the fault reporting UI to be disabled if this happens. var werflags uintptr stdcall2(_WerGetFlags, currentProcess, uintptr(unsafe.Pointer(&werflags))) stdcall1(_WerSetFlags, werflags|_WER_FAULT_REPORTING_NO_UI) } //--to func preventErrorDialogs() { errormode := stdcall0(_GetErrorMode) stdcall1(_SetErrorMode, errormode|_SEM_FAILCRITICALERRORS|_SEM_NOGPFAULTERRORBOX|_SEM_NOOPENFILEERRORBOX) } ================================================ FILE: 1.23_windows/runtime/syscall_windows.go.patch ================================================ //--from func syscall_SyscallN(fn uintptr, args ...uintptr) (r1, r2, err uintptr) { //--to func syscall_SyscallN(fn uintptr, args ...uintptr) (r1, r2, err uintptr) { if fn == 0 { panic("fn must not be 0 at SyscallN") } ================================================ FILE: 1.23_windows/runtime/syscall_windows_test.go.patch ================================================ //--from func TestNumCPU(t *testing.T) { //--to func TestNumCPU(t *testing.T) { t.Skip("creating a new process with os.Args[0] doesn't work in this environment") ================================================ FILE: 1.24_linux/internal/reflectlite/reflect_mirror_test.go.patch ================================================ //--from func TestMirrorWithReflect(t *testing.T) { //--to func TestMirrorWithReflect(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.24_linux/internal/runtime/syscall/asm_linux_amd64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0 // a6 already in R9. // a5 already in R8. MOVQ SI, R10 // a4 MOVQ DI, DX // a3 MOVQ CX, SI // a2 MOVQ BX, DI // a1 // num already in AX. SYSCALL CMPQ AX, $0xfffffffffffff001 JLS ok NEGQ AX MOVQ AX, CX // errno MOVQ $-1, AX // r1 MOVQ $0, BX // r2 RET ok: // r1 already in AX. MOVQ DX, BX // r2 MOVQ $0, CX // errno RET //--to ================================================ FILE: 1.24_linux/internal/runtime/syscall/asm_linux_arm64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0-80 MOVD num+0(FP), R8 // syscall entry MOVD a1+8(FP), R0 MOVD a2+16(FP), R1 MOVD a3+24(FP), R2 MOVD a4+32(FP), R3 MOVD a5+40(FP), R4 MOVD a6+48(FP), R5 SVC CMN $4095, R0 BCC ok MOVD $-1, R4 MOVD R4, r1+56(FP) MOVD ZR, r2+64(FP) NEG R0, R0 MOVD R0, errno+72(FP) RET ok: MOVD R0, r1+56(FP) MOVD R1, r2+64(FP) MOVD ZR, errno+72(FP) RET //--to ================================================ FILE: 1.24_linux/internal/runtime/syscall/syscall_linux.go.patch ================================================ //--from func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) //--to func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { println("not implemented syscall at Syscall6", num) panic("syscall.Syscall6") return 0, 0, 0x26 // ENOSYS } ================================================ FILE: 1.24_linux/internal/runtime/syscall/syscall_linux_test.go.patch ================================================ //--from import ( "internal/runtime/syscall" "testing" ) //--to import ( "testing" ) //--from func TestEpollctlErrorSign(t *testing.T) { v := syscall.EpollCtl(-1, 1, -1, &syscall.EpollEvent{}) const EBADF = 0x09 if v != EBADF { t.Errorf("epollctl = %v, want %v", v, EBADF) } } //--to func TestEpollctlErrorSign(t *testing.T) { t.Skip("Epollctl is not supported in this environment") } ================================================ FILE: 1.24_linux/internal/syscall/unix/fcntl_unix.go.patch ================================================ //--from func Fcntl(fd int, cmd int, arg int) (int, error) { val, errno := fcntl(int32(fd), int32(cmd), int32(arg)) if val == -1 { return int(val), syscall.Errno(errno) } return int(val), nil } //--to func Fcntl(fd int, cmd int, arg int) (int, error) { return 0, syscall.ENOSYS } ================================================ FILE: 1.24_linux/internal/testenv/exec.go.patch ================================================ //--from var tryExec = sync.OnceValue(func() error { //--to var tryExec = sync.OnceValue(func() error { return fmt.Errorf("can't probe for exec support") ================================================ FILE: 1.24_linux/internal/testenv/testenv.go.patch ================================================ //--from func HasGoBuild() bool { //--to func HasGoBuild() bool { return false ================================================ FILE: 1.24_linux/internal/testenv/testenv_notunix.go.patch ================================================ //--from //go:build windows || plan9 || (js && wasm) || wasip1 //--to //go:build windows || plan9 || (js && wasm) || wasip1 || linux ================================================ FILE: 1.24_linux/internal/testenv/testenv_unix.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.24_linux/math/big/link_test.go.patch ================================================ //--from func TestLinkerGC(t *testing.T) { //--to func TestLinkerGC(t *testing.T) { t.Skip("go tools are not supported in this environment") ================================================ FILE: 1.24_linux/math/rand/default_test.go.patch ================================================ //--from func TestDefaultRace(t *testing.T) { //--to func TestDefaultRace(t *testing.T) { t.Skip("os.Getenv and creating processes are not supported in this environment") ================================================ FILE: 1.24_linux/runtime/align_test.go.patch ================================================ //--from func TestAtomicAlignment(t *testing.T) { //--to func TestAtomicAlignment(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.24_linux/runtime/callers_test.go.patch ================================================ //--from func TestCallersNilPointerPanic(t *testing.T) { //--to func TestCallersNilPointerPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestCallersDeferNilFuncPanic(t *testing.T) { //--to func TestCallersDeferNilFuncPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { //--to func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.24_linux/runtime/cgo/cgo.go.patch ================================================ //--from */ import "C" //--to #cgo !darwin LDFLAGS: -Wl,-unresolved-symbols=ignore-all #cgo darwin LDFLAGS: -Wl,-undefined,dynamic_lookup */ import "C" ================================================ FILE: 1.24_linux/runtime/cgo/gcc_linux_amd64.c.patch ================================================ //--from #include #include #include // strerror #include #include #include "libcgo.h" #include "libcgo_unix.h" //--to #include #include #include // strerror #include #include "libcgo.h" #include "libcgo_unix.h" //--from void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--to void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; pthread_t p; size_t size; int err; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--from static void* threadentry(void *v) { ThreadStart ts; //--to static void* threadentry(void *v) { ThreadStart ts; extern void hitsumabushi_initializeThread(void); hitsumabushi_initializeThread(); ================================================ FILE: 1.24_linux/runtime/cgo/gcc_linux_arm64.c.patch ================================================ //--from void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--to void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setstacksize(&attr, 16 * 4096); // Hack for some special environments pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--from static void* threadentry(void *v) { ThreadStart ts; //--to static void* threadentry(void *v) { ThreadStart ts; // Note that threadentry will also be defined in gcc_linux.go in Go 1.22. extern void hitsumabushi_initializeThread(void); hitsumabushi_initializeThread(); ================================================ FILE: 1.24_linux/runtime/cgo/gcc_setenv.c.patch ================================================ //--from void x_cgo_setenv(char **arg) { _cgo_tsan_acquire(); setenv(arg[0], arg[1], 1); _cgo_tsan_release(); } //--to void x_cgo_setenv(char **arg) { } //--from void x_cgo_unsetenv(char **arg) { _cgo_tsan_acquire(); unsetenv(arg[0]); _cgo_tsan_release(); } //--to void x_cgo_unsetenv(char **arg) { } ================================================ FILE: 1.24_linux/runtime/cgo/gcc_sigaction.c.patch ================================================ //--from //go:build linux && (amd64 || arm64 || ppc64le) //--to //go:build linux && (arm64 || ppc64le) ================================================ FILE: 1.24_linux/runtime/cgo/hitsumabushi_clock_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp) { return clock_gettime(clk_id, tp); } ================================================ FILE: 1.24_linux/runtime/cgo/hitsumabushi_cpu_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int32_t hitsumabushi_getproccount() { return 1; } ================================================ FILE: 1.24_linux/runtime/cgo/hitsumabushi_filesystem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include #include #include "libcgo.h" #include "libcgo_unix.h" static const int kFDOffset = 100; typedef struct { const void* content; size_t content_size; size_t current; int32_t fd; } pseudo_file; // TODO: Do we need to protect this by mutex? static pseudo_file pseudo_files[100]; static pthread_mutex_t* pseudo_file_mutex() { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; return &mutex; } static int32_t open_pseudo_file(const void* content, size_t content_size) { int index = 0; int found = 0; int32_t fd = 0; pthread_mutex_lock(pseudo_file_mutex()); for (int i = 0; i < sizeof(pseudo_files) / sizeof(pseudo_file); i++) { if (pseudo_files[i].fd == 0) { index = i; found = 1; break; } } if (!found) { // Too many pseudo files are opened. pthread_mutex_unlock(pseudo_file_mutex()); return -1; } fd = index + kFDOffset; pseudo_files[index].content = content; pseudo_files[index].content_size = content_size; pseudo_files[index].current = 0; pseudo_files[index].fd = fd; pthread_mutex_unlock(pseudo_file_mutex()); return fd; } static size_t read_pseudo_file(int32_t fd, void *p, int32_t n) { int32_t index = fd - kFDOffset; pseudo_file *file = NULL; size_t rest = 0; pthread_mutex_lock(pseudo_file_mutex()); file = &pseudo_files[index]; rest = file->content_size - file->current; if (rest < n) { n = rest; } memcpy(p, file->content + file->current, n); pseudo_files[index].current += n; pthread_mutex_unlock(pseudo_file_mutex()); return n; } static void close_pseudo_file(int32_t fd) { int32_t index = fd - kFDOffset; pthread_mutex_lock(pseudo_file_mutex()); pseudo_files[index].content = NULL; pseudo_files[index].content_size = 0; pseudo_files[index].current = 0; pseudo_files[index].fd = 0; pthread_mutex_unlock(pseudo_file_mutex()); } int32_t hitsumabushi_closefd(int32_t fd) { if (fd >= kFDOffset) { close_pseudo_file(fd); return 0; } fprintf(stderr, "syscall close(%d) is not implemented\n", fd); return 0; } int32_t hitsumabushi_open(char *name, int32_t mode, int32_t perm) { const static int kENOENT = 0x2; if (strcmp(name, "/proc/self/auxv") == 0) { static const char auxv[] = "\x06\x00\x00\x00\x00\x00\x00\x00" // _AT_PAGESZ tag (6) "\x00\x10\x00\x00\x00\x00\x00\x00" // 4096 bytes per page "\x00\x00\x00\x00\x00\x00\x00\x00" // Dummy bytes "\x00\x00\x00\x00\x00\x00\x00\x00"; // Dummy bytes return open_pseudo_file(auxv, sizeof(auxv) / sizeof(char)); } if (strcmp(name, "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size") == 0) { static const char hpage_pmd_size[] = "\x30\x5c"; // '0', '\n' return open_pseudo_file(hpage_pmd_size, sizeof(hpage_pmd_size) / sizeof(char)); } fprintf(stderr, "syscall open(%s, %d, %d) is not implemented\n", name, mode, perm); return kENOENT; } int32_t hitsumabushi_read(int32_t fd, void *p, int32_t n) { const static int kEBADF = 0x9; if (fd >= kFDOffset) { return read_pseudo_file(fd, p, n); } fprintf(stderr, "syscall read(%d, %p, %d) is not implemented\n", fd, p, n); return kEBADF; } int32_t hitsumabushi_write1(uintptr_t fd, void *p, int32_t n) { static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; int32_t ret = 0; pthread_mutex_lock(&m); switch (fd) { case 1: ret = fwrite(p, 1, n, stdout); fflush(stdout); break; case 2: ret = fwrite(p, 1, n, stderr); fflush(stderr); break; default: fprintf(stderr, "syscall write(%lu, %p, %d) is not implemented\n", fd, p, n); ret = -EBADF; break; } pthread_mutex_unlock(&m); return ret; } int32_t hitsumabushi_lseek(uintptr_t fd, off_t offset, int32_t whence) { fprintf(stderr, "syscall lseek(%lu, %lu, %d) is not implemented\n", fd, offset, whence); return -ENOSYS; } int32_t hitsumabushi_fcntl(int32_t fd, int32_t cmd, int32_t arg) { if (fd == 0 || fd == 1 || fd == 2) { if (cmd == F_GETFL) { return 0; } } fprintf(stderr, "syscall fcntl(%d, %d, %d) is not implemented\n", fd, cmd, arg); return -EBADF; } int32_t hitsumabushi_fstat(int32_t fd, struct stat *stat) { fprintf(stderr, "syscall fstat(%d, %p) is not implemented\n", fd, stat); return -ENOSYS; } int32_t hitsumabushi_renameat(int32_t fd1, char* name1, int32_t fd2, char* name2) { fprintf(stderr, "syscall renameat(%d, %s, %d, %s) is not implemented\n", fd1, name1, fd2, name2); return -ENOSYS; } int32_t hitsumabushi_fstatat(int32_t fd, char* name, struct stat* p, int32_t flags) { fprintf(stderr, "syscall fstatat(%d, %s, %p, %d) is not implemented\n", fd, name, p, flags); return -ENOSYS; } ================================================ FILE: 1.24_linux/runtime/cgo/hitsumabushi_futex_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include #include #include #include static const int kPseudoFutexWait = 0; static const int kPseudoFutexWake = 1; static void pseudo_futex(uint32_t *uaddr, int mode, uint32_t val, const struct timespec *reltime) { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; int ret = 0; struct timespec abstime; if (reltime) { // We are not sure CLOCK_REALTIME is correct or not here. // However, this time limit is actually not used as the condition variable is shared by // all the threads. Before the time limit reaches, the thread wakes up in 99.9999...% cases. clock_gettime(CLOCK_REALTIME, &abstime); abstime.tv_sec += reltime->tv_sec; abstime.tv_nsec += reltime->tv_nsec; if (1000000000 <= abstime.tv_nsec) { abstime.tv_sec += 1; abstime.tv_nsec -= 1000000000; } } ret = pthread_mutex_lock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_lock failed: %d\n", ret); abort(); } switch (mode) { case kPseudoFutexWait: if (reltime) { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_timedwait(&cond, &mutex, &abstime); if (ret && ret != ETIMEDOUT) { fprintf(stderr, "pthread_cond_timedwait failed: %d\n", ret); abort(); } } } else { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_wait(&cond, &mutex); if (ret) { fprintf(stderr, "pthread_cond_wait failed: %d\n", ret); abort(); } } } break; case kPseudoFutexWake: if (val != 1) { fprintf(stderr, "val for waking must be 1 but %d\n", val); abort(); } // TODO: broadcasting is not efficient. Use a mutex for each uaddr. ret = pthread_cond_broadcast(&cond); if (ret) { fprintf(stderr, "pthread_cond_broadcast failed: %d\n", ret); abort(); } break; } ret = pthread_mutex_unlock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_unlock failed: %d\n", ret); abort(); } } int32_t hitsumabushi_futex(uint32_t *uaddr, int32_t futex_op, uint32_t val, const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3) { enum { kFutexWaitPrivate = 128, kFutexWakePrivate = 129, }; switch (futex_op) { case kFutexWaitPrivate: pseudo_futex(uaddr, kPseudoFutexWait, val, timeout); break; case kFutexWakePrivate: pseudo_futex(uaddr, kPseudoFutexWake, val, NULL); break; } // This function should return the number of awaken threads, but now it is impossible. // Just return 0. return 0; } ================================================ FILE: 1.24_linux/runtime/cgo/hitsumabushi_mem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include void* hitsumabushi_sysReserveOS(void* v, uintptr_t n); void* hitsumabushi_sysAllocOS(uintptr_t n) { return hitsumabushi_sysReserveOS(NULL, n); } void hitsumabushi_sysUnusedOS(void* v, uintptr_t n) { } void hitsumabushi_sysUsedOS(void* v, uintptr_t n) { } void hitsumabushi_sysHugePageOS(void* v, uintptr_t n) { } void hitsumabushi_sysFreeOS(void* v, uintptr_t n) { } void hitsumabushi_sysFaultOS(void* v, uintptr_t n) { } void* hitsumabushi_sysReserveOS(void* v, uintptr_t n) { if (v) { return NULL; } return calloc(n, 1); } void hitsumabushi_sysMapOS(void* v, uintptr_t n) { } ================================================ FILE: 1.24_linux/runtime/cgo/hitsumabushi_syscalls_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include // for usleep #include // for size_t #include "libcgo.h" #include "libcgo_unix.h" typedef unsigned int gid_t; extern int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp); extern int32_t hitsumabushi_getproccount(); void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { abort(); return NULL; } int munmap(void *addr, size_t length) { abort(); return 0; } int pthread_sigmask(int how, void *set, void *oldset) { // Do nothing. return 0; } int setegid(gid_t gid) { // Do nothing. return 0; } int seteuid(uid_t gid) { // Do nothing. return 0; } int setgid(gid_t gid) { // Do nothing. return 0; } int setgroups(size_t size, const gid_t *list) { // Do nothing. return 0; } int setregid(gid_t rgid, gid_t egid) { // Do nothing. return 0; } int setreuid(uid_t ruid, uid_t euid) { // Do nothing. return 0; } int setresgid(gid_t rgid, gid_t egid, gid_t sgid) { // Do nothing. return 0; } int setresuid(uid_t ruid, uid_t euid, uid_t suid) { // Do nothing. return 0; } int setuid(uid_t gid) { // Do nothing. return 0; } int sigaction(int signum, void *act, void *oldact) { // Do nothing. return 0; } int sigaddset(void *set, int signum) { // Do nothing. return 0; } int sigemptyset(void *set) { // Do nothing. return 0; } int sigfillset(void *set) { // Do nothing. return 0; } int sigismember(void *set, int signum) { // Do nothing. return 0; } uint32_t hitsumabushi_gettid() { uint64_t tid64 = (uint64_t)(pthread_self()); uint32_t tid = (uint32_t)(tid64 >> 32) ^ (uint32_t)(tid64); return tid; } int64_t hitsumabushi_nanotime1() { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_MONOTONIC, &tp); return (int64_t)(tp.tv_sec) * 1000000000ll + (int64_t)tp.tv_nsec; } int32_t hitsumabushi_osyield() { return sched_yield(); } int32_t hitsumabushi_sched_getaffinity(pid_t pid, size_t cpusetsize, void *mask) { int32_t numcpu = hitsumabushi_getproccount(); for (int32_t i = 0; i < numcpu; i += 8) ((unsigned char*)mask)[i / 8] = (unsigned char)((1u << (numcpu - i)) - 1); // https://man7.org/linux/man-pages/man2/sched_setaffinity.2.html // > On success, the raw sched_getaffinity() system call returns the // > number of bytes placed copied into the mask buffer; return (numcpu + 7) / 8; } void hitsumabushi_usleep(useconds_t usec) { usleep(usec); } void hitsumabushi_walltime1(int64_t* sec, int32_t* nsec) { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_REALTIME, &tp); *sec = tp.tv_sec; *nsec = tp.tv_nsec; } void hitsumabushi_exit(int32_t code) { exit(code); } ================================================ FILE: 1.24_linux/runtime/cgo/hitsumabushi_thread_linux.c ================================================ void hitsumabushi_initializeThread(void) { } ================================================ FILE: 1.24_linux/runtime/cgo/linux_syscall.c.patch ================================================ //--from #include #include #include #include #include "libcgo.h" //--to #include #include #include #include "libcgo.h" //--from void _cgo_libc_setegid(argset_t* x) { SET_RETVAL(setegid((gid_t) x->args[0])); } //--to void _cgo_libc_setegid(argset_t* x) { } //--from void _cgo_libc_seteuid(argset_t* x) { SET_RETVAL(seteuid((uid_t) x->args[0])); } //--to void _cgo_libc_seteuid(argset_t* x) { } //--from void _cgo_libc_setgid(argset_t* x) { SET_RETVAL(setgid((gid_t) x->args[0])); } //--to void _cgo_libc_setgid(argset_t* x) { } //--from void _cgo_libc_setgroups(argset_t* x) { SET_RETVAL(setgroups((size_t) x->args[0], (const gid_t *) x->args[1])); } //--to void _cgo_libc_setgroups(argset_t* x) { } //--from void _cgo_libc_setregid(argset_t* x) { SET_RETVAL(setregid((gid_t) x->args[0], (gid_t) x->args[1])); } //--to void _cgo_libc_setregid(argset_t* x) { } //--from void _cgo_libc_setresgid(argset_t* x) { SET_RETVAL(setresgid((gid_t) x->args[0], (gid_t) x->args[1], (gid_t) x->args[2])); } //--to void _cgo_libc_setresgid(argset_t* x) { } //--from void _cgo_libc_setreuid(argset_t* x) { SET_RETVAL(setreuid((uid_t) x->args[0], (uid_t) x->args[1])); } //--to void _cgo_libc_setreuid(argset_t* x) { } //--from void _cgo_libc_setuid(argset_t* x) { SET_RETVAL(setuid((uid_t) x->args[0])); } //--to void _cgo_libc_setuid(argset_t* x) { } ================================================ FILE: 1.24_linux/runtime/cgo/sigaction.go.patch ================================================ //--from //go:build (linux && amd64) || (freebsd && amd64) || (linux && arm64) || (linux && ppc64le) //--to //go:build (freebsd && amd64) || (linux && arm64) || (linux && ppc64le) ================================================ FILE: 1.24_linux/runtime/crash_test.go.patch ================================================ //--from func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { //--to func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { t.Skip("buildTestProg is not supported in this environment") //--from func TestPanicInlined(t *testing.T) { //--to func TestPanicInlined(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.24_linux/runtime/crash_unix_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.24_linux/runtime/debug/heapdump_test.go.patch ================================================ //--from func TestWriteHeapDumpNonempty(t *testing.T) { //--to func TestWriteHeapDumpNonempty(t *testing.T) { t.Skip("file is not supported in this environment") //--from func TestWriteHeapDumpFinalizers(t *testing.T) { //--to func TestWriteHeapDumpFinalizers(t *testing.T) { t.Skip("file is not supported in this environment") //--from func TestWriteHeapDumpTypeName(t *testing.T) { //--to func TestWriteHeapDumpTypeName(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.24_linux/runtime/debug/panic_test.go.patch ================================================ //--from func TestPanicOnFault(t *testing.T) { //--to func TestPanicOnFault(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.24_linux/runtime/debug_test.go.patch ================================================ //--from //go:build (amd64 || arm64 || loong64 || ppc64le) && linux && !race //--to //go:build ignore ================================================ FILE: 1.24_linux/runtime/export_unix_test.go ================================================ // Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build unix package runtime const ( O_WRONLY = _O_WRONLY O_CREAT = _O_CREAT O_TRUNC = _O_TRUNC ) ================================================ FILE: 1.24_linux/runtime/fds_unix.go.patch ================================================ //--from func checkfds() { //--to func checkfds() { return ================================================ FILE: 1.24_linux/runtime/mem_linux.go ================================================ // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This implementation is the most fundamental and minimal allocations like Wasm. // Malloced memory regions are never freed. package runtime import ( "internal/abi" "unsafe" ) // Don't split the stack as this method may be invoked without a valid G, which // prevents us from allocating more stack. // //go:nosplit //go:cgo_unsafe_args func sysAllocOS(n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysAllocOS_trampoline)), unsafe.Pointer(&n)) return } func sysAllocOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit //go:cgo_unsafe_args func sysUnusedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUnusedOS_trampoline)), unsafe.Pointer(&v)) } func sysUnusedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysUsedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUsedOS_trampoline)), unsafe.Pointer(&v)) } func sysUsedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysHugePageOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysHugePageOS_trampoline)), unsafe.Pointer(&v)) } func sysHugePageOS_trampoline(n uintptr, size uintptr) func sysNoHugePageOS(v unsafe.Pointer, n uintptr) { } func sysHugePageCollapseOS(v unsafe.Pointer, n uintptr) { } // Don't split the stack as this function may be invoked without a valid G, // which prevents us from allocating more stack. // //go:nosplit //go:cgo_unsafe_args func sysFreeOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFreeOS_trampoline)), unsafe.Pointer(&v)) } func sysFreeOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysFaultOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFaultOS_trampoline)), unsafe.Pointer(&v)) } func sysFaultOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysReserveOS(v unsafe.Pointer, n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysReserveOS_trampoline)), unsafe.Pointer(&v)) return } func sysReserveOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit //go:cgo_unsafe_args func sysMapOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysMapOS_trampoline)), unsafe.Pointer(&v)) } func sysMapOS_trampoline(n uintptr, size uintptr) ================================================ FILE: 1.24_linux/runtime/memmove_linux_amd64_test.go.patch ================================================ //--from func TestMemmoveOverflow(t *testing.T) { //--to func TestMemmoveOverflow(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.24_linux/runtime/metrics_test.go.patch ================================================ //--from name: "runtime/debug.WriteHeapDump", fn: func(t *testing.T) { //--to name: "runtime/debug.WriteHeapDump", fn: func(t *testing.T) { t.Skip("debug.WriteHeapDump is not supported in this environment") ================================================ FILE: 1.24_linux/runtime/nbpipe_pipe2.go.patch ================================================ //--from //go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris //--to //go:build dragonfly || freebsd || netbsd || openbsd || solaris ================================================ FILE: 1.24_linux/runtime/nbpipe_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.24_linux/runtime/netpoll_epoll.go.patch ================================================ //--from //go:build linux //--to //go:build ignore ================================================ FILE: 1.24_linux/runtime/netpoll_fake.go.patch ================================================ //--from //go:build js && wasm //--to //go:build linux ================================================ FILE: 1.24_linux/runtime/nosan_linux_test.go.patch ================================================ //--from func TestNewOSProc0(t *testing.T) { //--to func TestNewOSProc0(t *testing.T) { t.Skip("newosproc0 is not supported in this environment") ================================================ FILE: 1.24_linux/runtime/os_linux.go.patch ================================================ //--from import ( "internal/abi" "internal/goarch" "internal/runtime/atomic" "internal/runtime/syscall" "unsafe" ) //--to import ( "internal/abi" "internal/runtime/atomic" "internal/runtime/syscall" "unsafe" ) //--from //go:noescape func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 //--to //go:nosplit //go:cgo_unsafe_args func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 { ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(futex_trampoline)), unsafe.Pointer(&addr)) return ret } func futex_trampoline(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 //--from func sysargs(argc int32, argv **byte) { n := argc + 1 // skip over argv, envp to get to auxv for argv_index(argv, n) != nil { n++ } // skip NULL separator n++ // now argv+n is auxv auxvp := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*goarch.PtrSize)) if pairs := sysauxv(auxvp[:]); pairs != 0 { auxv = auxvp[: pairs*2 : pairs*2] return } // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } n = read(fd, noescape(unsafe.Pointer(&auxvreadbuf[0])), int32(unsafe.Sizeof(auxvreadbuf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. auxvreadbuf[len(auxvreadbuf)-2] = _AT_NULL pairs := sysauxv(auxvreadbuf[:]) auxv = auxvreadbuf[: pairs*2 : pairs*2] } //--to func sysargs(argc int32, argv **byte) { // argc/argv is not reliable on some machines. // Skip analysing them. // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } n := read(fd, noescape(unsafe.Pointer(&auxvreadbuf[0])), int32(unsafe.Sizeof(auxvreadbuf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. auxvreadbuf[len(auxvreadbuf)-2] = _AT_NULL pairs := sysauxv(auxvreadbuf[:]) auxv = auxvreadbuf[: pairs*2 : pairs*2] } //--from var urandom_dev = []byte("/dev/urandom\x00") func readRandom(r []byte) int { // Note that all supported Linux kernels should provide AT_RANDOM which // populates startupRand, so this fallback should be unreachable. fd := open(&urandom_dev[0], 0 /* O_RDONLY */, 0) n := read(fd, unsafe.Pointer(&r[0]), int32(len(r))) closefd(fd) return int(n) } //--to //go:nosplit func readRandom(r []byte) int { return 0 } //--from func gettid() uint32 //--to //go:nosplit //go:cgo_unsafe_args func gettid() (tid uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(gettid_trampoline)), unsafe.Pointer(&tid)) return } func gettid_trampoline() uint32 //--from //go:noescape func sigaltstack(new, old *stackt) //--to func sigaltstack(new, old *stackt) { // Do nothing. } //--from func sigprocmask(how int32, new, old *sigset) { rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--to func sigprocmask(how int32, new, old *sigset) { // Do nothing. // rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--from func raise(sig uint32) //--to func raise(sig uint32) { // Do nothing } //--from func raiseproc(sig uint32) //--to func raiseproc(sig uint32) { // Do nothing } //--from //go:noescape func sched_getaffinity(pid, len uintptr, buf *byte) int32 //--to //go:nosplit //go:cgo_unsafe_args func sched_getaffinity(pid, len uintptr, buf *byte) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(sched_getaffinity_trampoline)), unsafe.Pointer(&pid)) } func sched_getaffinity_trampoline(pid, len uintptr, buf *byte) int32 //--from func osyield() //--to //go:nosplit //go:cgo_unsafe_args func osyield() { libcCall(unsafe.Pointer(abi.FuncPCABI0(osyield_trampoline)), nil) } func osyield_trampoline() //--from func sysSigaction(sig uint32, new, old *sigactiont) { //--to func sysSigaction(sig uint32, new, old *sigactiont) { // Do nothing. return //--from func signalM(mp *m, sig int) { tgkill(getpid(), int(mp.procid), sig) } //--to func signalM(mp *m, sig int) { // Do nothiing. } //--from func runPerThreadSyscall() { gp := getg() if gp.m.needPerThreadSyscall.Load() == 0 { return } args := perThreadSyscall r1, r2, errno := syscall.Syscall6(args.trap, args.a1, args.a2, args.a3, args.a4, args.a5, args.a6) if GOARCH == "ppc64" || GOARCH == "ppc64le" { // TODO(https://go.dev/issue/51192 ): ppc64 doesn't use r2. r2 = 0 } if errno != 0 || r1 != args.r1 || r2 != args.r2 { print("trap:", args.trap, ", a123456=[", args.a1, ",", args.a2, ",", args.a3, ",", args.a4, ",", args.a5, ",", args.a6, "]\n") print("results: got {r1=", r1, ",r2=", r2, ",errno=", errno, "}, want {r1=", args.r1, ",r2=", args.r2, ",errno=0}\n") fatal("AllThreadsSyscall6 results differ between threads; runtime corrupted") } gp.m.needPerThreadSyscall.Store(0) } //--to func runPerThreadSyscall() { // Do nothing. // needPerThreadSyscall should never be 1 as syscall_runtime_doAllThreadsSyscall is not available with Cgo. } //--append //go:linkname hitsumabushi_closefd hitsumabushi_closefd //go:cgo_import_static hitsumabushi_closefd var hitsumabushi_closefd byte //go:linkname hitsumabushi_exit hitsumabushi_exit //go:cgo_import_static hitsumabushi_exit var hitsumabushi_exit byte //go:linkname hitsumabushi_gettid hitsumabushi_gettid //go:cgo_import_static hitsumabushi_gettid var hitsumabushi_gettid byte //go:linkname hitsumabushi_nanotime1 hitsumabushi_nanotime1 //go:cgo_import_static hitsumabushi_nanotime1 var hitsumabushi_nanotime1 byte //go:linkname hitsumabushi_open hitsumabushi_open //go:cgo_import_static hitsumabushi_open var hitsumabushi_open byte //go:linkname hitsumabushi_osyield hitsumabushi_osyield //go:cgo_import_static hitsumabushi_osyield var hitsumabushi_osyield byte //go:linkname hitsumabushi_read hitsumabushi_read //go:cgo_import_static hitsumabushi_read var hitsumabushi_read byte //go:linkname hitsumabushi_sched_getaffinity hitsumabushi_sched_getaffinity //go:cgo_import_static hitsumabushi_sched_getaffinity var hitsumabushi_sched_getaffinity byte //go:linkname hitsumabushi_usleep hitsumabushi_usleep //go:cgo_import_static hitsumabushi_usleep var hitsumabushi_usleep byte //go:linkname hitsumabushi_walltime1 hitsumabushi_walltime1 //go:cgo_import_static hitsumabushi_walltime1 var hitsumabushi_walltime1 byte //go:linkname hitsumabushi_write1 hitsumabushi_write1 //go:cgo_import_static hitsumabushi_write1 var hitsumabushi_write1 byte //go:nosplit //go:cgo_unsafe_args func fcntl1(fd, cmd, arg int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fcntl_trampoline)), unsafe.Pointer(&fd)) } func fcntl_trampoline() //go:nosplit //go:cgo_unsafe_args func fstat1(fd int, stat unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstat_trampoline)), unsafe.Pointer(&fd)) } func fstat_trampoline(fd int, stat unsafe.Pointer) int32 //go:nosplit //go:cgo_unsafe_args func lseek1(fd int, offset int64, whence int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(lseek_trampoline)), unsafe.Pointer(&fd)) } func lseek_trampoline() //go:nosplit //go:cgo_unsafe_args func renameat(fd1 int, name1 unsafe.Pointer, fd2 int, name2 unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(renameat_trampoline)), unsafe.Pointer(&fd1)) } func renameat_trampoline() //go:nosplit //go:cgo_unsafe_args func fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstatat_trampoline)), unsafe.Pointer(&fd)) } func fstatat_trampoline() ================================================ FILE: 1.24_linux/runtime/panicnil_test.go.patch ================================================ //--from func TestPanicNil(t *testing.T) { //--to func TestPanicNil(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.24_linux/runtime/proc_test.go.patch ================================================ //--from func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) testGoroutineParallelism2(t, false, true) testGoroutineParallelism2(t, true, true) } //--to func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) //testGoroutineParallelism2(t, false, true) //testGoroutineParallelism2(t, true, true) } ================================================ FILE: 1.24_linux/runtime/rand_test.go.patch ================================================ //--from func TestReadRandom(t *testing.T) { //--to func TestReadRandom(t *testing.T) { t.Skip("readRandom is not available in this environment") ================================================ FILE: 1.24_linux/runtime/runtime1.go.patch ================================================ //--from func argv_index(argv **byte, i int32) *byte { return *(**byte)(add(unsafe.Pointer(argv), uintptr(i)*goarch.PtrSize)) } //--to func argv_index(argv **byte, i int32) *byte { return nil } //--from func args(c int32, v **byte) { argc = c argv = v sysargs(c, v) } //--to func args(c int32, v **byte) { // In the original code, physPageSize is determined at sysargs. // Hitsumabushi gives an initial value for physPageSize at its declaration, so sysargs doesn't have to be called. } //--append // Expose the entry point for some special environments. //go:cgo_export_static _rt0_amd64_linux_lib //go:cgo_export_dynamic _rt0_amd64_linux_lib ================================================ FILE: 1.24_linux/runtime/runtime_linux_test.go.patch ================================================ //--from func TestMincoreErrorSign(t *testing.T) { //--to func TestMincoreErrorSign(t *testing.T) { t.Skip("mincore is not supported in this environment") ================================================ FILE: 1.24_linux/runtime/runtime_mmap_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.24_linux/runtime/runtime_test.go.patch ================================================ //--from func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { //--to func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { t.Skip("catching faults is not supported in this environment") ================================================ FILE: 1.24_linux/runtime/runtime_unix_test.go.patch ================================================ //--from //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || plan9 //--to //go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || plan9 ================================================ FILE: 1.24_linux/runtime/stack_test.go.patch ================================================ //--from func TestDeferLeafSigpanic(t *testing.T) { //--to func TestDeferLeafSigpanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestStackWrapperStackPanic(t *testing.T) { //--to func TestStackWrapperStackPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.24_linux/runtime/stubs2.go.patch ================================================ //--from import ( "internal/runtime/atomic" "unsafe" ) //--to import ( "internal/abi" "internal/runtime/atomic" "unsafe" ) //--from func read(fd int32, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func read(fd int32, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(read_trampoline)), unsafe.Pointer(&fd)) } func read_trampoline(fd int32, p unsafe.Pointer, n int32) int32 //--from func closefd(fd int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func closefd(fd int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(closefd_trampoline)), unsafe.Pointer(&fd)) } func closefd_trampoline(fd int32) int32 //--from func exit(code int32) //--to //go:nosplit //go:cgo_unsafe_args func exit(code int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(exit_trampoline)), unsafe.Pointer(&code)) } func exit_trampoline(code int32) //--from func usleep(usec uint32) //--to //go:nosplit //go:cgo_unsafe_args func usleep(usec uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } func usleep_trampoline(usec uint32) //--from //go:nosplit func usleep_no_g(usec uint32) { usleep(usec) } //--to //go:nosplit //go:cgo_unsafe_args func usleep_no_g(usec uint32) { asmcgocall_no_g(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } //--from //go:noescape func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func write1(fd uintptr, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(write1_trampoline)), unsafe.Pointer(&fd)) } func write1_trampoline(fd uintptr, p unsafe.Pointer, n int32) int32 //--from //go:noescape func open(name *byte, mode, perm int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func open(name *byte, mode, perm int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(open_trampoline)), unsafe.Pointer(&name)) } func open_trampoline(name *byte, mode, perm int32) int32 ================================================ FILE: 1.24_linux/runtime/stubs3.go.patch ================================================ //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func nanotime1() int64 //--to //go:nosplit //go:cgo_unsafe_args func nanotime1() (now int64) { libcCall(unsafe.Pointer(abi.FuncPCABI0(nanotime1_trampoline)), unsafe.Pointer(&now)) return } func nanotime1_trampoline() int64 ================================================ FILE: 1.24_linux/runtime/sys_libc.go.patch ================================================ //--from //go:build darwin || (openbsd && !mips64) //--to //go:build darwin || (openbsd && !mips64) || linux ================================================ FILE: 1.24_linux/runtime/sys_linux_amd64.s.patch ================================================ //--from TEXT runtime·open(SB),NOSPLIT,$0-20 // This uses openat instead of open, because Android O blocks open. MOVL $AT_FDCWD, DI // AT_FDCWD, so this acts like open MOVQ name+0(FP), SI MOVL mode+8(FP), DX MOVL perm+12(FP), R10 MOVL $SYS_openat, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVL 8(DI), SI // arg 2 flags MOVL 12(DI), DX // arg 3 mode MOVQ 0(DI), DI // arg 1 pathname XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_open(SB) MOVQ AX, 16(BX) POPQ BP RET //--from TEXT runtime·futex(SB),NOSPLIT,$0 MOVQ addr+0(FP), DI MOVL op+8(FP), SI MOVL val+12(FP), DX MOVQ ts+16(FP), R10 MOVQ addr2+24(FP), R8 MOVL val3+32(FP), R9 MOVL $SYS_futex, AX SYSCALL MOVL AX, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 addr MOVL 8(BX), SI // arg 2 op MOVL 12(BX), DX // arg 3 val MOVQ 16(BX), CX // arg 4 ts MOVQ 24(BX), R8 // arg 5 addr2 MOVL 32(BX), R9 // arg 6 val3 CALL hitsumabushi_futex(SB) MOVL AX, 40(BX) POPQ BP RET //--from TEXT runtime·exit(SB),NOSPLIT,$0-4 MOVL code+0(FP), DI MOVL $SYS_exit_group, AX SYSCALL RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 exit status CALL hitsumabushi_exit(SB) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·read(SB),NOSPLIT,$0-28 MOVL fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_read, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 0(BX), DI // arg 1 fd MOVQ 8(BX), SI // arg 2 buf MOVQ 16(BX), DX // arg 3 count CALL hitsumabushi_read(SB) MOVQ AX, 24(BX) // return value POPQ BP RET //--from TEXT runtime·closefd(SB),NOSPLIT,$0-12 MOVL fd+0(FP), DI MOVL $SYS_close, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 fd CALL hitsumabushi_closefd(SB) POPQ BP RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVL $SYS_gettid, AX SYSCALL MOVL AX, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_gettid(SB) POPQ BP RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT,$0 MOVQ new+0(FP), DI MOVQ old+8(FP), SI MOVQ $SYS_sigaltstack, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $0xf1, 0xf1 // crash RET //--to TEXT runtime·sigaltstack_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 old MOVQ 0(DI), DI // arg 1 new CALL hitsumabushi_sigaltstack(SB) TESTQ AX, AX JEQ 2(PC) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·raise(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, R12 MOVL $SYS_gettid, AX SYSCALL MOVL AX, SI // arg 2 tid MOVL R12, DI // arg 1 pid MOVL sig+0(FP), DX // arg 3 MOVL $SYS_tgkill, AX SYSCALL RET //--to TEXT runtime·raise_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 signal CALL hitsumabushi_raise(SB) POPQ BP RET //--from TEXT runtime·raiseproc(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, DI // arg 1 pid MOVL sig+0(FP), SI // arg 2 MOVL $SYS_kill, AX SYSCALL RET //--to TEXT runtime·raiseproc_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), BX // signal CALL hitsumabushi_getpid(SB) MOVL AX, DI // arg 1 pid MOVL BX, SI // arg 2 signal CALL hitsumabushi_kill(SB) POPQ BP RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0 MOVQ pid+0(FP), DI MOVQ len+8(FP), SI MOVQ buf+16(FP), DX MOVL $SYS_sched_getaffinity, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 len MOVQ 16(DI), DX // arg 3 buf MOVQ 0(DI), DI // arg 1 pid CALL hitsumabushi_sched_getaffinity(SB) POPQ BP RET //--from TEXT runtime·osyield(SB),NOSPLIT,$0 MOVL $SYS_sched_yield, AX SYSCALL RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_osyield(SB) POPQ BP RET //--from TEXT runtime·usleep(SB),NOSPLIT,$16 MOVL $0, DX MOVL usec+0(FP), AX MOVL $1000000, CX DIVL CX MOVQ AX, 0(SP) MOVL $1000, AX // usec to nsec MULL DX MOVQ AX, 8(SP) // nanosleep(&ts, 0) MOVQ SP, DI MOVL $0, SI MOVL $SYS_nanosleep, AX SYSCALL RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 usec CALL hitsumabushi_usleep(SB) POPQ BP RET //--from TEXT runtime·write1(SB),NOSPLIT,$0-28 MOVQ fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_write, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 p MOVQ 16(DI), DX // arg 3 n MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_write1(SB) POPQ BP RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$16-8 // We don't know how much stack space the VDSO code will need, // so switch to g0. // In particular, a kernel configured with CONFIG_OPTIMIZE_INLINING=n // and hardening can use a full page of stack space in gettime_sym // due to stack probes inserted to avoid stack/heap collisions. // See issue #20427. MOVQ SP, R12 // Save old SP; R12 unchanged by C code. MOVQ g_m(R14), BX // BX unchanged by C code. // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVQ m_vdsoPC(BX), CX MOVQ m_vdsoSP(BX), DX MOVQ CX, 0(SP) MOVQ DX, 8(SP) LEAQ ret+0(FP), DX MOVQ -8(DX), CX MOVQ CX, m_vdsoPC(BX) MOVQ DX, m_vdsoSP(BX) CMPQ R14, m_curg(BX) // Only switch if on curg. JNE noswitch MOVQ m_g0(BX), DX MOVQ (g_sched+gobuf_sp)(DX), SP // Set SP to g0 stack noswitch: SUBQ $16, SP // Space for results ANDQ $~15, SP // Align for C code MOVL $1, DI // CLOCK_MONOTONIC LEAQ 0(SP), SI MOVQ runtime·vdsoClockgettimeSym(SB), AX CMPQ AX, $0 JEQ fallback CALL AX ret: MOVQ 0(SP), AX // sec MOVQ 8(SP), DX // nsec MOVQ R12, SP // Restore real SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVQ 8(SP), CX MOVQ CX, m_vdsoSP(BX) MOVQ 0(SP), CX MOVQ CX, m_vdsoPC(BX) // sec is in AX, nsec in DX // return nsec in AX IMULQ $1000000000, AX ADDQ DX, AX MOVQ AX, ret+0(FP) RET fallback: MOVQ $SYS_clock_gettime, AX SYSCALL JMP ret //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ DI, BX // BX is callee-saved MOVQ SP, BP CALL hitsumabushi_nanotime1(SB) MOVQ AX, 0(BX) POPQ BP RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(DI), DI CALL hitsumabushi_sysAllocOS(SB) MOVQ AX, 8(BX) POPQ BP RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUnusedOS(SB) POPQ BP RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUsedOS(SB) POPQ BP RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysHugePageOS(SB) POPQ BP RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFreeOS(SB) POPQ BP RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFaultOS(SB) POPQ BP RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysReserveOS(SB) MOVQ AX, 16(BX) POPQ BP RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysMapOS(SB) POPQ BP RET TEXT runtime·walltime1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_walltime1(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 cmd MOVQ 16(DI), DX // arg 3 arg MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_fcntl(SB) POPQ BP RET TEXT runtime·fstat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 stat MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_fstat(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·lseek_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 offset MOVQ 16(DI), DX // arg 3 whence MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_lseek(SB) MOVQ AX, 24(BX) // return value POPQ BP RET TEXT runtime·renameat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_renameat(SB) MOVL AX, 32(BX) POPQ BP RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_fstatat(SB) MOVL AX, 32(BX) POPQ BP RET ================================================ FILE: 1.24_linux/runtime/sys_linux_arm64.s.patch ================================================ //--from #define SYS_exit 93 #define SYS_read 63 #define SYS_write 64 #define SYS_openat 56 #define SYS_close 57 #define SYS_pipe2 59 #define SYS_nanosleep 101 #define SYS_mmap 222 #define SYS_munmap 215 #define SYS_setitimer 103 #define SYS_clone 220 #define SYS_sched_yield 124 #define SYS_rt_sigreturn 139 #define SYS_rt_sigaction 134 #define SYS_rt_sigprocmask 135 #define SYS_sigaltstack 132 #define SYS_madvise 233 #define SYS_mincore 232 #define SYS_getpid 172 #define SYS_gettid 178 #define SYS_kill 129 #define SYS_tgkill 131 #define SYS_futex 98 #define SYS_sched_getaffinity 123 #define SYS_exit_group 94 #define SYS_clock_gettime 113 #define SYS_faccessat 48 #define SYS_socket 198 #define SYS_connect 203 #define SYS_brk 214 #define SYS_timer_create 107 #define SYS_timer_settime 110 #define SYS_timer_delete 111 //--to #define SYS_exit 2147483647 #define SYS_read 2147483647 #define SYS_write 2147483647 #define SYS_openat 2147483647 #define SYS_close 2147483647 #define SYS_pipe2 2147483647 #define SYS_nanosleep 2147483647 #define SYS_mmap 2147483647 #define SYS_munmap 2147483647 #define SYS_setitimer 2147483647 #define SYS_clone 2147483647 #define SYS_sched_yield 2147483647 #define SYS_rt_sigreturn 2147483647 #define SYS_rt_sigaction 2147483647 #define SYS_rt_sigprocmask 2147483647 #define SYS_sigaltstack 2147483647 #define SYS_madvise 2147483647 #define SYS_mincore 2147483647 #define SYS_getpid 2147483647 #define SYS_gettid 2147483647 #define SYS_kill 2147483647 #define SYS_tgkill 2147483647 #define SYS_futex 2147483647 #define SYS_sched_getaffinity 2147483647 #define SYS_exit_group 2147483647 #define SYS_clock_gettime 2147483647 #define SYS_faccessat 2147483647 #define SYS_socket 2147483647 #define SYS_connect 2147483647 #define SYS_brk 2147483647 #define SYS_timer_create 2147483647 #define SYS_timer_settime 2147483647 #define SYS_timer_delete 2147483647 //--from TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0-4 MOVW code+0(FP), R0 MOVD $SYS_exit_group, R8 SVC RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_exit(SB) RET //--from TEXT runtime·open(SB),NOSPLIT|NOFRAME,$0-20 MOVD $AT_FDCWD, R0 MOVD name+0(FP), R1 MOVW mode+8(FP), R2 MOVW perm+12(FP), R3 MOVD $SYS_openat, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_open(SB) RET //--from TEXT runtime·closefd(SB),NOSPLIT|NOFRAME,$0-12 MOVW fd+0(FP), R0 MOVD $SYS_close, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT,$0-12 MOVW 0(R0), R0 BL hitsumabushi_closefd(SB) RET //--from TEXT runtime·write1(SB),NOSPLIT|NOFRAME,$0-28 MOVD fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_write, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_write1(SB) RET //--from TEXT runtime·read(SB),NOSPLIT|NOFRAME,$0-28 MOVW fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_read, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_read(SB) RET //--from TEXT runtime·usleep(SB),NOSPLIT,$24-4 MOVWU usec+0(FP), R3 MOVD R3, R5 MOVW $1000000, R4 UDIV R4, R3 MOVD R3, 8(RSP) MUL R3, R4 SUB R4, R5 MOVW $1000, R4 MUL R4, R5 MOVD R5, 16(RSP) // nanosleep(&ts, 0) ADD $8, RSP, R0 MOVD $0, R1 MOVD $SYS_nanosleep, R8 SVC RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_usleep(SB) RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVD $SYS_gettid, R8 SVC MOVW R0, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_gettid(SB) MOVW R0, 0(R19) // return value RET //--from TEXT runtime·raise(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R19 MOVD $SYS_gettid, R8 SVC MOVW R0, R1 // arg 2 tid MOVW R19, R0 // arg 1 pid MOVW sig+0(FP), R2 // arg 3 MOVD $SYS_tgkill, R8 SVC RET //--to //--from TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R0 // arg 1 pid MOVW sig+0(FP), R1 // arg 2 MOVD $SYS_kill, R8 SVC RET //--to //--from TEXT runtime·walltime(SB),NOSPLIT,$24-12 MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $16, R1 BIC $15, R1 // Align for C code MOVD R1, RSP MOVW $CLOCK_REALTIME, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) MOVD R3, sec+0(FP) MOVW R5, nsec+8(FP) RET //--to TEXT runtime·walltime1_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_walltime1(SB) RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$24-8 MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $32, R1 BIC $15, R1 MOVD R1, RSP MOVW $CLOCK_MONOTONIC, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) // sec is in R3, nsec in R5 // return nsec in R3 MOVD $1000000000, R4 MUL R4, R3 ADD R5, R3 MOVD R3, ret+0(FP) RET //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_nanotime1(SB) MOVD R0, 0(R19) // return value RET //--from TEXT runtime·futex(SB),NOSPLIT|NOFRAME,$0 MOVD addr+0(FP), R0 MOVW op+8(FP), R1 MOVW val+12(FP), R2 MOVD ts+16(FP), R3 MOVD addr2+24(FP), R4 MOVW val3+32(FP), R5 MOVD $SYS_futex, R8 SVC MOVW R0, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 16(R0), R3 MOVD 24(R0), R4 MOVW 32(R0), R5 MOVD 0(R0), R0 BL hitsumabushi_futex(SB) RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT|NOFRAME,$0 MOVD new+0(FP), R0 MOVD old+8(FP), R1 MOVD $SYS_sigaltstack, R8 SVC CMN $4095, R0 BCC ok MOVD $0, R0 MOVD R0, (R0) // crash ok: RET //--to //--from TEXT runtime·osyield(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_sched_yield, R8 SVC RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT,$0 BL hitsumabushi_osyield(SB) RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT|NOFRAME,$0 MOVD pid+0(FP), R0 MOVD len+8(FP), R1 MOVD buf+16(FP), R2 MOVD $SYS_sched_getaffinity, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVD 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_sched_getaffinity(SB) RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 0(R0), R0 BL hitsumabushi_sysAllocOS(SB) MOVD R0, 8(R19) // return value RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUnusedOS(SB) RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUsedOS(SB) RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysHugePageOS(SB) RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFreeOS(SB) RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFaultOS(SB) RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysReserveOS(SB) MOVD R0, 16(R19) // return value RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysMapOS(SB) RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVW 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_fcntl(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·fstat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 0(R0), R0 BL hitsumabushi_fstat(SB) MOVW R0, 16(R19) // return value RET TEXT runtime·lseek_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_lseek(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·renameat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_renameat(SB) MOVW R0, 32(R19) // return value RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_fstatat(SB) MOVW R0, 32(R19) // return value RET ================================================ FILE: 1.24_linux/runtime/time_linux_amd64.s.patch ================================================ //--from //go:build !faketime //--to //go:build ignore ================================================ FILE: 1.24_linux/runtime/timeasm.go.patch ================================================ //--from //go:build !faketime && (windows || (linux && amd64)) //--to //go:build !faketime && windows ================================================ FILE: 1.24_linux/runtime/timestub.go.patch ================================================ //--from //go:build !faketime && !windows && !(linux && amd64) //--to //go:build !faketime && !windows ================================================ FILE: 1.24_linux/runtime/timestub2.go.patch ================================================ //--from //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !wasip1 && !windows && !(linux && amd64) //--to //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !wasip1 && !windows //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func walltime() (sec int64, nsec int32) //--to func walltime() (sec int64, nsec int32) { walltime1(&sec, &nsec) return } //go:nosplit //go:cgo_unsafe_args func walltime1(sec *int64, nsec *int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(walltime1_trampoline)), unsafe.Pointer(&sec)) } func walltime1_trampoline(sec *int64, nsec *int32) ================================================ FILE: 1.24_linux/runtime/traceback_test.go.patch ================================================ //--from func TestTracebackInlined(t *testing.T) { //--to func TestTracebackInlined(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.24_linux/strconv/fp_test.go.patch ================================================ //--from func TestFp(t *testing.T) { //--to func TestFp(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.24_linux/sync/atomic/atomic_test.go.patch ================================================ //--from func TestStoreLoadSeqCst32(t *testing.T) { //--to func TestStoreLoadSeqCst32(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") //--from func TestStoreLoadSeqCst64(t *testing.T) { //--to func TestStoreLoadSeqCst64(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") //--from func TestNilDeref(t *testing.T) { //--to func TestNilDeref(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.24_linux/syscall/hitsumabushi_stubs_linux_amd64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_FSTATAT = 0xffffffffffffffff // Stub: on amd64 Go uses SYS_NEWFSTATAT instead ) ================================================ FILE: 1.24_linux/syscall/hitsumabushi_stubs_linux_arm64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_NEWFSTATAT = 0xffffffffffffffff // Stub: on arm64 Go uses SYS_FSTATAT instead ) ================================================ FILE: 1.24_linux/syscall/rlimit.go.patch ================================================ //--from func init() { var lim Rlimit if err := Getrlimit(RLIMIT_NOFILE, &lim); err == nil && lim.Max > 0 && lim.Cur < lim.Max-1 { origRlimitNofile.Store(&lim) nlim := lim // We set Cur to Max - 1 so that we are more likely to // detect cases where another process uses prlimit // to change our resource limits. The theory is that // using prlimit to change to Cur == Max is more likely // than using prlimit to change to Cur == Max - 1. // The place we check for this is in exec_linux.go. nlim.Cur = nlim.Max - 1 adjustFileLimit(&nlim) setrlimit(RLIMIT_NOFILE, &nlim) } } //--to func init() { } ================================================ FILE: 1.24_linux/syscall/syscall_linux.go.patch ================================================ //--from func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() // N.B. Calling RawSyscall here is unsafe with atomic coverage // instrumentation and race mode. // // Coverage instrumentation will add a sync/atomic call to RawSyscall. // Race mode will add race instrumentation to sync/atomic. Race // instrumentation requires a P, which we no longer have. // // RawSyscall6 is fine because it is implemented in assembly and thus // has no coverage instrumentation. // // This is typically not a problem in the runtime because cmd/go avoids // adding coverage instrumentation to the runtime in race mode. r1, r2, err = RawSyscall6(trap, a1, a2, a3, 0, 0, 0) runtime_exitsyscall() return } //--to func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FCNTL: r = fcntl1(a1, a2, a3) case SYS_FSTAT: r = fstat1(a1, unsafe.Pointer(a2)) case SYS_READ: r = runtime_read(uintptr(a1), unsafe.Pointer(a2), int32(a3)) case SYS_WRITE: r = write1(a1, unsafe.Pointer(a2), int32(a3)) case SYS_LSEEK: r = lseek1(a1, int64(a2), int32(a3)) case SYS_CLOSE: r = runtime_closefd(int32(a1)) case SYS_MKDIRAT: println("syscall mkdirat() is not implemented") // Default to permission denied. TODO: implement this return 0, 0, EPERM case SYS_GETDENTS64: println("syscall getdents64() is not implemented") // Default to empty directory. TODO: implement this return 0, 0, 0 default: println("unimplemented syscall at runtime.Syscall", trap) panic("syscall.Syscall") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //go:linkname open runtime.open func open(name *byte, mode, perm int32) int32 //go:linkname write1 runtime.write1 func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname fcntl1 runtime.fcntl1 func fcntl1(fd uintptr, a uintptr, b uintptr) int32 //go:linkname fstat1 runtime.fstat1 func fstat1(fd uintptr, p unsafe.Pointer) int32 //go:linkname lseek1 runtime.lseek1 func lseek1(fd uintptr, offset int64, whence int32) int32 //go:linkname runtime_read runtime.read func runtime_read(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname runtime_closefd runtime.closefd func runtime_closefd(fd int32) int32 //go:linkname runtime_fstatat runtime.fstatat func runtime_fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 //go:linkname runtime_renameat runtime.renameat func runtime_renameat(fd1 uintptr, name1 unsafe.Pointer, fd2 uintptr, name2 unsafe.Pointer) int32 //--from func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() r1, r2, err = RawSyscall6(trap, a1, a2, a3, a4, a5, a6) runtime_exitsyscall() return } //--to func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FSTATAT, SYS_NEWFSTATAT: r = runtime_fstatat(uintptr(a1), unsafe.Pointer(a2), unsafe.Pointer(a3), int32(a4)) case SYS_RENAMEAT: r = runtime_renameat(uintptr(a1), unsafe.Pointer(a2), uintptr(a3), unsafe.Pointer(a4)) default: println("unimplemented syscall at runtime.Syscall6", trap) panic("syscall.Syscall6") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //--from func Open(path string, mode int, perm uint32) (fd int, err error) { return openat(_AT_FDCWD, path, mode|O_LARGEFILE, perm) } //--to func Open(path string, mode int, perm uint32) (fd int, err error) { p0, err := BytePtrFromString(path) if err != nil { return -1, errnoErr(EINVAL) } fd = int(open(p0, int32(mode|O_LARGEFILE), int32(perm))) if fd < 0 { return -1, errnoErr(ENOENT) } return } ================================================ FILE: 1.24_linux/testing/run_example.go ================================================ package testing func runExample(eg InternalExample) (ok bool) { // Do nothing. // TODO: Implement os.Pipe2 and use this here. return true } ================================================ FILE: 1.24_linux/time/format_test.go.patch ================================================ //--from func TestParseInLocation(t *testing.T) { //--to func TestParseInLocation(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationZipFile(t *testing.T) { //--to func TestLoadLocationZipFile(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.24_linux/time/internal_test.go.patch ================================================ //--from func initTestingZone() { // For hermeticity, use only tzinfo source from the test's GOROOT, // not the system sources and not whatever GOROOT may happen to be // set in the process's environment (if any). // This test runs in GOROOT/src/time, so GOROOT is "../..", // but it is theoretically possible sources := []string{"../../lib/time/zoneinfo.zip"} z, err := loadLocation("America/Los_Angeles", sources) if err != nil { panic("cannot load America/Los_Angeles for testing: " + err.Error() + "; you may want to use -tags=timetzdata") } z.name = "Local" localLoc = *z } //--to func initTestingZone() { // Data from the playground. // https://go.dev/play/p/VGXU57KZZ-x // name is replaced with "Local". // cachStart, cacheEnd, and cacheZone are removed. localLoc = Location{name:"Local",zone:[]zone{zone{name:"LMT", offset:-28378, isDST:false}, zone{name:"PDT", offset:-25200, isDST:true}, zone{name:"PST", offset:-28800, isDST:false}, zone{name:"PWT", offset:-25200, isDST:true}, zone{name:"PPT", offset:-25200, isDST:true}}, tx:[]zoneTrans{zoneTrans{when:-576460752303423488, index:0x0, isstd:false, isutc:false}, zoneTrans{when:-2717640000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1633269600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-1615129200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1601820000, index:0x1, isstd:true, isutc:true}, zoneTrans{when:-1583679600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-880207200, index:0x3, isstd:false, isutc:false}, zoneTrans{when:-769395600, index:0x4, isstd:false, isutc:false}, zoneTrans{when:-765385200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-687967140, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-662655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-620838000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-608137200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-589388400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-576082800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-557938800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-544633200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-526489200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-513183600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-495039600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-481734000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-463590000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-450284400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-431535600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-418230000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-400086000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-386780400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-368636400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-355330800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-337186800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-323881200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-305737200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-292431600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-273682800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-260982000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-242233200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-226508400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-210783600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-195058800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-179334000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-163609200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-147884400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-131554800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-116434800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-100105200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-84376800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-68655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-52927200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-37206000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-21477600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-5756400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:9972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:25693200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:41421600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:57747600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:73476000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:89197200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:104925600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:120646800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:126698400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:152096400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:162381600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:183546000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:199274400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:215600400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:230724000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:247050000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:262778400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:278499600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:294228000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:309949200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:325677600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:341398800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:357127200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:372848400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:388576800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:404902800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:420026400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:436352400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:452080800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:467802000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:483530400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:499251600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:514980000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:530701200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:544615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:562150800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:576064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:594205200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:607514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:625654800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:638964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:657104400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:671018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:688554000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:702468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:720003600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:733917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:752058000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:765367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:783507600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:796816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:814957200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:828871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:846406800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:860320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:877856400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:891770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:909306000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:923220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:941360400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:954669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:972810000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:986119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1004259600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1018173600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1035709200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1049623200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1067158800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1081072800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1099213200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1112522400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1130662800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1143972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1162112400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1173607200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1194166800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1205056800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1225616400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1236506400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1257066000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1268560800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1289120400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1300010400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1320570000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1331460000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1352019600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1362909600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1383469200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1394359200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1414918800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1425808800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1446368400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1457863200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1478422800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1489312800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1509872400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1520762400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1541322000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1552212000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1572771600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1583661600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1604221200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1615716000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1636275600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1647165600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1667725200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1678615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1699174800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1710064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1730624400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1741514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1762074000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1772964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1793523600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1805018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1825578000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1836468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1857027600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1867917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1888477200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1899367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1919926800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1930816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1951376400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1962871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1983430800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1994320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2014880400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2025770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2046330000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2057220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2077779600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2088669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2109229200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2120119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2140678800, index:0x2, isstd:false, isutc:false}}, extend:"PST8PDT,M3.2.0,M11.1.0"} } ================================================ FILE: 1.24_linux/time/sleep_test.go.patch ================================================ //--from func TestSleep(t *testing.T) { //--to func TestSleep(t *testing.T) { t.Skip("Interrupt (syscall.Kill) is not supported in this environment") //--from func TestIssue5745(t *testing.T) { //--to func TestIssue5745(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.24_linux/time/time_test.go.patch ================================================ //--from func TestLoadFixed(t *testing.T) { //--to func TestLoadFixed(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestTimeIsDST(t *testing.T) { //--to func TestTimeIsDST(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestTimeWithZoneTransition(t *testing.T) { //--to func TestTimeWithZoneTransition(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestMarshalBinaryVersion2(t *testing.T) { //--to func TestMarshalBinaryVersion2(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.24_linux/time/tzdata_test.go.patch ================================================ //--from func TestEmbeddedTZData(t *testing.T) { //--to func TestEmbeddedTZData(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.24_linux/time/zoneinfo_test.go.patch ================================================ //--from func TestEnvVarUsage(t *testing.T) { //--to func TestEnvVarUsage(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestBadLocationErrMsg(t *testing.T) { //--to func TestBadLocationErrMsg(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestVersion3(t *testing.T) { //--to func TestVersion3(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestFirstZone(t *testing.T) { //--to func TestFirstZone(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationFromTZData(t *testing.T) { //--to func TestLoadLocationFromTZData(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestEarlyLocation(t *testing.T) { //--to func TestEarlyLocation(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationFromTZDataSlim(t *testing.T) { //--to func TestLoadLocationFromTZDataSlim(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.24_linux/time/zoneinfo_unix.go.patch ================================================ //--from import ( "syscall" ) //--to //--from func initLocal() { // consult $TZ to find the time zone to use. // no $TZ means use the system default /etc/localtime. // $TZ="" means use UTC. // $TZ="foo" or $TZ=":foo" if foo is an absolute path, then the file pointed // by foo will be used to initialize timezone; otherwise, file // /usr/share/zoneinfo/foo will be used. tz, ok := syscall.Getenv("TZ") switch { case !ok: z, err := loadLocation("localtime", []string{"/etc"}) if err == nil { localLoc = *z localLoc.name = "Local" return } case tz != "": if tz[0] == ':' { tz = tz[1:] } if tz != "" && tz[0] == '/' { if z, err := loadLocation(tz, []string{""}); err == nil { localLoc = *z if tz == "/etc/localtime" { localLoc.name = "Local" } else { localLoc.name = tz } return } } else if tz != "" && tz != "UTC" { if z, err := loadLocation(tz, platformZoneSources); err == nil { localLoc = *z return } } } // Fall back to UTC. localLoc.name = "UTC" } //--to func initLocal() { localLoc.name = "UTC" } ================================================ FILE: 1.24_linux/time/zoneinfo_unix_test.go.patch ================================================ //--from func TestEnvTZUsage(t *testing.T) { //--to func TestEnvTZUsage(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.24_windows/internal/testenv/exec.go.patch ================================================ //--from var tryExec = sync.OnceValue(func() error { //--to var tryExec = sync.OnceValue(func() error { return fmt.Errorf("can't probe for exec support") ================================================ FILE: 1.24_windows/internal/testenv/testenv.go.patch ================================================ //--from func HasGoBuild() bool { //--to func HasGoBuild() bool { return false ================================================ FILE: 1.24_windows/runtime/cgo/gcc_windows_amd64.c.patch ================================================ //--from static void threadentry(void *v) { ThreadStart ts; //--to static int getproccount() { static int proccount = 0; if (!proccount) { SYSTEM_INFO info; GetSystemInfo(&info); proccount = info.dwNumberOfProcessors; } return proccount; } static void threadentry(void *v) { ThreadStart ts; SetThreadAffinityMask(GetCurrentThread(), (1< //--to //--append #define fprintf dummy_fprintf // TODO: Use OutputDebugMessage. #define dummy_fprintf(stream, format, ...) ================================================ FILE: 1.24_windows/runtime/os_windows.go.patch ================================================ //--from //go:cgo_import_dynamic runtime._GetConsoleMode GetConsoleMode%2 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._SetConsoleCtrlHandler SetConsoleCtrlHandler%2 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._WerGetFlags WerGetFlags%2 "kernel32.dll" //go:cgo_import_dynamic runtime._WerSetFlags WerSetFlags%1 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._WriteConsoleW WriteConsoleW%5 "kernel32.dll" //--to //go:cgo_import_dynamic runtime._OutputDebugStringW OutputDebugStringW%1 "kernel32.dll" //--from _GetConsoleMode, //--to //--from _SetConsoleCtrlHandler, //--to //--from _WerGetFlags, _WerSetFlags, //--to //--from _WriteConsoleW, //--to _OutputDebugStringW, //--from // We call these all the way here, late in init, so that malloc works // for the callback functions these generate. var fn any = ctrlHandler ctrlHandlerPC := compileCallback(*efaceOf(&fn), true) stdcall2(_SetConsoleCtrlHandler, ctrlHandlerPC, 1) //--to //--from func write1(fd uintptr, buf unsafe.Pointer, n int32) int32 { const ( _STD_OUTPUT_HANDLE = ^uintptr(10) // -11 _STD_ERROR_HANDLE = ^uintptr(11) // -12 ) var handle uintptr switch fd { case 1: handle = stdcall1(_GetStdHandle, _STD_OUTPUT_HANDLE) case 2: handle = stdcall1(_GetStdHandle, _STD_ERROR_HANDLE) default: // assume fd is real windows handle. handle = fd } isASCII := true b := (*[1 << 30]byte)(buf)[:n] for _, x := range b { if x >= 0x80 { isASCII = false break } } if !isASCII { var m uint32 isConsole := stdcall2(_GetConsoleMode, handle, uintptr(unsafe.Pointer(&m))) != 0 // If this is a console output, various non-unicode code pages can be in use. // Use the dedicated WriteConsole call to ensure unicode is printed correctly. if isConsole { return int32(writeConsole(handle, buf, n)) } } var written uint32 stdcall5(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--to func write1(fd uintptr, buf unsafe.Pointer, n int32) int32 { const ( _STD_OUTPUT_HANDLE = ^uintptr(10) // -11 _STD_ERROR_HANDLE = ^uintptr(11) // -12 ) var handle uintptr switch fd { case 1: handle = stdcall1(_GetStdHandle, _STD_OUTPUT_HANDLE) case 2: handle = stdcall1(_GetStdHandle, _STD_ERROR_HANDLE) default: // assume fd is real windows handle. handle = fd } if fd == 1 || fd == 2 { // Note that handle is not used anyway. return int32(writeConsole(handle, buf, n)) } var written uint32 stdcall5(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--from func writeConsoleUTF16(handle uintptr, b []uint16) { l := uint32(len(b)) if l == 0 { return } var written uint32 stdcall5(_WriteConsoleW, handle, uintptr(unsafe.Pointer(&b[0])), uintptr(l), uintptr(unsafe.Pointer(&written)), 0, ) return } //--to func writeConsoleUTF16(handle uintptr, b []uint16) { b = b[:len(b)+1] b[len(b)-1] = 0 l := uint32(len(b)) if l <= 1 { return } stdcall1(_OutputDebugStringW, uintptr(unsafe.Pointer(&b[0])), ) return } ================================================ FILE: 1.24_windows/runtime/signal_windows.go.patch ================================================ //--from func preventErrorDialogs() { errormode := stdcall0(_GetErrorMode) stdcall1(_SetErrorMode, errormode|_SEM_FAILCRITICALERRORS|_SEM_NOGPFAULTERRORBOX|_SEM_NOOPENFILEERRORBOX) // Disable WER fault reporting UI. // Do this even if WER is disabled as a whole, // as WER might be enabled later with setTraceback("wer") // and we still want the fault reporting UI to be disabled if this happens. var werflags uintptr stdcall2(_WerGetFlags, currentProcess, uintptr(unsafe.Pointer(&werflags))) stdcall1(_WerSetFlags, werflags|_WER_FAULT_REPORTING_NO_UI) } //--to func preventErrorDialogs() { errormode := stdcall0(_GetErrorMode) stdcall1(_SetErrorMode, errormode|_SEM_FAILCRITICALERRORS|_SEM_NOGPFAULTERRORBOX|_SEM_NOOPENFILEERRORBOX) } ================================================ FILE: 1.24_windows/runtime/syscall_windows.go.patch ================================================ //--from func syscall_SyscallN(fn uintptr, args ...uintptr) (r1, r2, err uintptr) { //--to func syscall_SyscallN(fn uintptr, args ...uintptr) (r1, r2, err uintptr) { if fn == 0 { panic("fn must not be 0 at SyscallN") } ================================================ FILE: 1.24_windows/runtime/syscall_windows_test.go.patch ================================================ //--from func TestNumCPU(t *testing.T) { //--to func TestNumCPU(t *testing.T) { t.Skip("creating a new process with os.Args[0] doesn't work in this environment") ================================================ FILE: 1.25_linux/internal/reflectlite/reflect_mirror_test.go.patch ================================================ //--from func TestMirrorWithReflect(t *testing.T) { //--to func TestMirrorWithReflect(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.25_linux/internal/runtime/cgroup/cgroup_linux.go.patch ================================================ //--from func FindCPURelativePath(out []byte, scratch []byte) (int, Version, error) { //--to func FindCPURelativePath(out []byte, scratch []byte) (int, Version, error) { return 0, 0, ErrNoCgroup //--from func FindCPUMountPoint(out []byte, scratch []byte) (int, error) { //--to func FindCPUMountPoint(out []byte, scratch []byte) (int, error) { return 0, ErrNoCgroup ================================================ FILE: 1.25_linux/internal/runtime/syscall/asm_linux_amd64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0 // a6 already in R9. // a5 already in R8. MOVQ SI, R10 // a4 MOVQ DI, DX // a3 MOVQ CX, SI // a2 MOVQ BX, DI // a1 // num already in AX. SYSCALL CMPQ AX, $0xfffffffffffff001 JLS ok NEGQ AX MOVQ AX, CX // errno MOVQ $-1, AX // r1 MOVQ $0, BX // r2 RET ok: // r1 already in AX. MOVQ DX, BX // r2 MOVQ $0, CX // errno RET //--to ================================================ FILE: 1.25_linux/internal/runtime/syscall/asm_linux_arm64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0-80 MOVD num+0(FP), R8 // syscall entry MOVD a1+8(FP), R0 MOVD a2+16(FP), R1 MOVD a3+24(FP), R2 MOVD a4+32(FP), R3 MOVD a5+40(FP), R4 MOVD a6+48(FP), R5 SVC CMN $4095, R0 BCC ok MOVD $-1, R4 MOVD R4, r1+56(FP) MOVD ZR, r2+64(FP) NEG R0, R0 MOVD R0, errno+72(FP) RET ok: MOVD R0, r1+56(FP) MOVD R1, r2+64(FP) MOVD ZR, errno+72(FP) RET //--to ================================================ FILE: 1.25_linux/internal/runtime/syscall/syscall_linux.go.patch ================================================ //--from func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) //--to func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { println("not implemented syscall at Syscall6", num) panic("syscall.Syscall6") return 0, 0, 0x26 // ENOSYS } ================================================ FILE: 1.25_linux/internal/runtime/syscall/syscall_linux_test.go.patch ================================================ //--from import ( "internal/runtime/syscall" "testing" ) //--to import ( "testing" ) //--from func TestEpollctlErrorSign(t *testing.T) { v := syscall.EpollCtl(-1, 1, -1, &syscall.EpollEvent{}) const EBADF = 0x09 if v != EBADF { t.Errorf("epollctl = %v, want %v", v, EBADF) } } //--to func TestEpollctlErrorSign(t *testing.T) { t.Skip("Epollctl is not supported in this environment") } ================================================ FILE: 1.25_linux/internal/syscall/unix/fcntl_unix.go.patch ================================================ //--from func Fcntl(fd int, cmd int, arg int) (int, error) { val, errno := fcntl(int32(fd), int32(cmd), int32(arg)) if val == -1 { return int(val), syscall.Errno(errno) } return int(val), nil } //--to func Fcntl(fd int, cmd int, arg int) (int, error) { return 0, syscall.ENOSYS } ================================================ FILE: 1.25_linux/internal/testenv/exec.go.patch ================================================ //--from var tryExec = sync.OnceValue(func() error { //--to var tryExec = sync.OnceValue(func() error { return fmt.Errorf("can't probe for exec support") ================================================ FILE: 1.25_linux/internal/testenv/testenv.go.patch ================================================ //--from func HasGoBuild() bool { //--to func HasGoBuild() bool { return false ================================================ FILE: 1.25_linux/internal/testenv/testenv_notunix.go.patch ================================================ //--from //go:build windows || plan9 || (js && wasm) || wasip1 //--to //go:build windows || plan9 || (js && wasm) || wasip1 || linux ================================================ FILE: 1.25_linux/internal/testenv/testenv_unix.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.25_linux/math/big/link_test.go.patch ================================================ //--from func TestLinkerGC(t *testing.T) { //--to func TestLinkerGC(t *testing.T) { t.Skip("go tools are not supported in this environment") ================================================ FILE: 1.25_linux/math/rand/default_test.go.patch ================================================ //--from func TestDefaultRace(t *testing.T) { //--to func TestDefaultRace(t *testing.T) { t.Skip("os.Getenv and creating processes are not supported in this environment") ================================================ FILE: 1.25_linux/runtime/align_test.go.patch ================================================ //--from func TestAtomicAlignment(t *testing.T) { //--to func TestAtomicAlignment(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.25_linux/runtime/callers_test.go.patch ================================================ //--from func TestCallersNilPointerPanic(t *testing.T) { //--to func TestCallersNilPointerPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestCallersDeferNilFuncPanic(t *testing.T) { //--to func TestCallersDeferNilFuncPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { //--to func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.25_linux/runtime/cgo/cgo.go.patch ================================================ //--from */ import "C" //--to #cgo !darwin LDFLAGS: -Wl,-unresolved-symbols=ignore-all #cgo darwin LDFLAGS: -Wl,-undefined,dynamic_lookup */ import "C" ================================================ FILE: 1.25_linux/runtime/cgo/gcc_linux_amd64.c.patch ================================================ //--from #include #include #include // strerror #include #include #include "libcgo.h" #include "libcgo_unix.h" //--to #include #include #include // strerror #include #include "libcgo.h" #include "libcgo_unix.h" //--from void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--to void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; pthread_t p; size_t size; int err; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--from static void* threadentry(void *v) { ThreadStart ts; //--to static void* threadentry(void *v) { ThreadStart ts; extern void hitsumabushi_initializeThread(void); hitsumabushi_initializeThread(); ================================================ FILE: 1.25_linux/runtime/cgo/gcc_linux_arm64.c.patch ================================================ //--from void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--to void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setstacksize(&attr, 16 * 4096); // Hack for some special environments pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--from static void* threadentry(void *v) { ThreadStart ts; //--to static void* threadentry(void *v) { ThreadStart ts; // Note that threadentry will also be defined in gcc_linux.go in Go 1.22. extern void hitsumabushi_initializeThread(void); hitsumabushi_initializeThread(); ================================================ FILE: 1.25_linux/runtime/cgo/gcc_setenv.c.patch ================================================ //--from void x_cgo_setenv(char **arg) { _cgo_tsan_acquire(); setenv(arg[0], arg[1], 1); _cgo_tsan_release(); } //--to void x_cgo_setenv(char **arg) { } //--from void x_cgo_unsetenv(char **arg) { _cgo_tsan_acquire(); unsetenv(arg[0]); _cgo_tsan_release(); } //--to void x_cgo_unsetenv(char **arg) { } ================================================ FILE: 1.25_linux/runtime/cgo/gcc_sigaction.c.patch ================================================ //--from //go:build linux && (amd64 || arm64 || loong64 || ppc64le) //--to //go:build linux && (arm64 || loong64 || ppc64le) ================================================ FILE: 1.25_linux/runtime/cgo/hitsumabushi_clock_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp) { return clock_gettime(clk_id, tp); } ================================================ FILE: 1.25_linux/runtime/cgo/hitsumabushi_cpu_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int32_t hitsumabushi_getproccount() { return 1; } ================================================ FILE: 1.25_linux/runtime/cgo/hitsumabushi_filesystem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include #include #include "libcgo.h" #include "libcgo_unix.h" static const int kFDOffset = 100; typedef struct { const void* content; size_t content_size; size_t current; int32_t fd; } pseudo_file; // TODO: Do we need to protect this by mutex? static pseudo_file pseudo_files[100]; static pthread_mutex_t* pseudo_file_mutex() { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; return &mutex; } static int32_t open_pseudo_file(const void* content, size_t content_size) { int index = 0; int found = 0; int32_t fd = 0; pthread_mutex_lock(pseudo_file_mutex()); for (int i = 0; i < sizeof(pseudo_files) / sizeof(pseudo_file); i++) { if (pseudo_files[i].fd == 0) { index = i; found = 1; break; } } if (!found) { // Too many pseudo files are opened. pthread_mutex_unlock(pseudo_file_mutex()); return -1; } fd = index + kFDOffset; pseudo_files[index].content = content; pseudo_files[index].content_size = content_size; pseudo_files[index].current = 0; pseudo_files[index].fd = fd; pthread_mutex_unlock(pseudo_file_mutex()); return fd; } static size_t read_pseudo_file(int32_t fd, void *p, int32_t n) { int32_t index = fd - kFDOffset; pseudo_file *file = NULL; size_t rest = 0; pthread_mutex_lock(pseudo_file_mutex()); file = &pseudo_files[index]; rest = file->content_size - file->current; if (rest < n) { n = rest; } memcpy(p, file->content + file->current, n); pseudo_files[index].current += n; pthread_mutex_unlock(pseudo_file_mutex()); return n; } static void close_pseudo_file(int32_t fd) { int32_t index = fd - kFDOffset; pthread_mutex_lock(pseudo_file_mutex()); pseudo_files[index].content = NULL; pseudo_files[index].content_size = 0; pseudo_files[index].current = 0; pseudo_files[index].fd = 0; pthread_mutex_unlock(pseudo_file_mutex()); } int32_t hitsumabushi_closefd(int32_t fd) { if (fd >= kFDOffset) { close_pseudo_file(fd); return 0; } fprintf(stderr, "syscall close(%d) is not implemented\n", fd); return 0; } int32_t hitsumabushi_open(char *name, int32_t mode, int32_t perm) { const static int kENOENT = 0x2; if (strcmp(name, "/proc/self/auxv") == 0) { static const char auxv[] = "\x06\x00\x00\x00\x00\x00\x00\x00" // _AT_PAGESZ tag (6) "\x00\x10\x00\x00\x00\x00\x00\x00" // 4096 bytes per page "\x00\x00\x00\x00\x00\x00\x00\x00" // Dummy bytes "\x00\x00\x00\x00\x00\x00\x00\x00"; // Dummy bytes return open_pseudo_file(auxv, sizeof(auxv) / sizeof(char)); } if (strcmp(name, "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size") == 0) { static const char hpage_pmd_size[] = "\x30\x5c"; // '0', '\n' return open_pseudo_file(hpage_pmd_size, sizeof(hpage_pmd_size) / sizeof(char)); } fprintf(stderr, "syscall open(%s, %d, %d) is not implemented\n", name, mode, perm); return kENOENT; } int32_t hitsumabushi_read(int32_t fd, void *p, int32_t n) { const static int kEBADF = 0x9; if (fd >= kFDOffset) { return read_pseudo_file(fd, p, n); } fprintf(stderr, "syscall read(%d, %p, %d) is not implemented\n", fd, p, n); return kEBADF; } int32_t hitsumabushi_write1(uintptr_t fd, void *p, int32_t n) { static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; int32_t ret = 0; pthread_mutex_lock(&m); switch (fd) { case 1: ret = fwrite(p, 1, n, stdout); fflush(stdout); break; case 2: ret = fwrite(p, 1, n, stderr); fflush(stderr); break; default: fprintf(stderr, "syscall write(%lu, %p, %d) is not implemented\n", fd, p, n); ret = -EBADF; break; } pthread_mutex_unlock(&m); return ret; } int32_t hitsumabushi_lseek(uintptr_t fd, off_t offset, int32_t whence) { fprintf(stderr, "syscall lseek(%lu, %lu, %d) is not implemented\n", fd, offset, whence); return -ENOSYS; } int32_t hitsumabushi_fcntl(int32_t fd, int32_t cmd, int32_t arg) { if (fd == 0 || fd == 1 || fd == 2) { if (cmd == F_GETFL) { return 0; } } fprintf(stderr, "syscall fcntl(%d, %d, %d) is not implemented\n", fd, cmd, arg); return -EBADF; } int32_t hitsumabushi_fstat(int32_t fd, struct stat *stat) { fprintf(stderr, "syscall fstat(%d, %p) is not implemented\n", fd, stat); return -ENOSYS; } int32_t hitsumabushi_renameat(int32_t fd1, char* name1, int32_t fd2, char* name2) { fprintf(stderr, "syscall renameat(%d, %s, %d, %s) is not implemented\n", fd1, name1, fd2, name2); return -ENOSYS; } int32_t hitsumabushi_fstatat(int32_t fd, char* name, struct stat* p, int32_t flags) { fprintf(stderr, "syscall fstatat(%d, %s, %p, %d) is not implemented\n", fd, name, p, flags); return -ENOSYS; } ================================================ FILE: 1.25_linux/runtime/cgo/hitsumabushi_futex_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include #include #include #include static const int kPseudoFutexWait = 0; static const int kPseudoFutexWake = 1; static void pseudo_futex(uint32_t *uaddr, int mode, uint32_t val, const struct timespec *reltime) { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; int ret = 0; struct timespec abstime; if (reltime) { // We are not sure CLOCK_REALTIME is correct or not here. // However, this time limit is actually not used as the condition variable is shared by // all the threads. Before the time limit reaches, the thread wakes up in 99.9999...% cases. clock_gettime(CLOCK_REALTIME, &abstime); abstime.tv_sec += reltime->tv_sec; abstime.tv_nsec += reltime->tv_nsec; if (1000000000 <= abstime.tv_nsec) { abstime.tv_sec += 1; abstime.tv_nsec -= 1000000000; } } ret = pthread_mutex_lock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_lock failed: %d\n", ret); abort(); } switch (mode) { case kPseudoFutexWait: if (reltime) { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_timedwait(&cond, &mutex, &abstime); if (ret && ret != ETIMEDOUT) { fprintf(stderr, "pthread_cond_timedwait failed: %d\n", ret); abort(); } } } else { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_wait(&cond, &mutex); if (ret) { fprintf(stderr, "pthread_cond_wait failed: %d\n", ret); abort(); } } } break; case kPseudoFutexWake: if (val != 1) { fprintf(stderr, "val for waking must be 1 but %d\n", val); abort(); } // TODO: broadcasting is not efficient. Use a mutex for each uaddr. ret = pthread_cond_broadcast(&cond); if (ret) { fprintf(stderr, "pthread_cond_broadcast failed: %d\n", ret); abort(); } break; } ret = pthread_mutex_unlock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_unlock failed: %d\n", ret); abort(); } } int32_t hitsumabushi_futex(uint32_t *uaddr, int32_t futex_op, uint32_t val, const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3) { enum { kFutexWaitPrivate = 128, kFutexWakePrivate = 129, }; switch (futex_op) { case kFutexWaitPrivate: pseudo_futex(uaddr, kPseudoFutexWait, val, timeout); break; case kFutexWakePrivate: pseudo_futex(uaddr, kPseudoFutexWake, val, NULL); break; } // This function should return the number of awaken threads, but now it is impossible. // Just return 0. return 0; } ================================================ FILE: 1.25_linux/runtime/cgo/hitsumabushi_mem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include void* hitsumabushi_sysReserveOS(void* v, uintptr_t n); void* hitsumabushi_sysAllocOS(uintptr_t n) { return hitsumabushi_sysReserveOS(NULL, n); } void hitsumabushi_sysUnusedOS(void* v, uintptr_t n) { } void hitsumabushi_sysUsedOS(void* v, uintptr_t n) { } void hitsumabushi_sysHugePageOS(void* v, uintptr_t n) { } void hitsumabushi_sysFreeOS(void* v, uintptr_t n) { } void hitsumabushi_sysFaultOS(void* v, uintptr_t n) { } void* hitsumabushi_sysReserveOS(void* v, uintptr_t n) { if (v) { return NULL; } // The returned pointer must be aligned to 1 << 9 bytes. // See also: // * https://cs.opensource.google/go/go/+/refs/tags/go1.25.0:src/runtime/tagptr_64bit.go // * https://go.dev/cl/665815/ return aligned_alloc(1 << 9, n); } void hitsumabushi_sysMapOS(void* v, uintptr_t n) { } ================================================ FILE: 1.25_linux/runtime/cgo/hitsumabushi_syscalls_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include // for usleep #include // for size_t #include "libcgo.h" #include "libcgo_unix.h" typedef unsigned int gid_t; extern int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp); extern int32_t hitsumabushi_getproccount(); void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { abort(); return NULL; } int munmap(void *addr, size_t length) { abort(); return 0; } int pthread_sigmask(int how, void *set, void *oldset) { // Do nothing. return 0; } int setegid(gid_t gid) { // Do nothing. return 0; } int seteuid(uid_t gid) { // Do nothing. return 0; } int setgid(gid_t gid) { // Do nothing. return 0; } int setgroups(size_t size, const gid_t *list) { // Do nothing. return 0; } int setregid(gid_t rgid, gid_t egid) { // Do nothing. return 0; } int setreuid(uid_t ruid, uid_t euid) { // Do nothing. return 0; } int setresgid(gid_t rgid, gid_t egid, gid_t sgid) { // Do nothing. return 0; } int setresuid(uid_t ruid, uid_t euid, uid_t suid) { // Do nothing. return 0; } int setuid(uid_t gid) { // Do nothing. return 0; } int sigaction(int signum, void *act, void *oldact) { // Do nothing. return 0; } int sigaddset(void *set, int signum) { // Do nothing. return 0; } int sigemptyset(void *set) { // Do nothing. return 0; } int sigfillset(void *set) { // Do nothing. return 0; } int sigismember(void *set, int signum) { // Do nothing. return 0; } uint32_t hitsumabushi_gettid() { uint64_t tid64 = (uint64_t)(pthread_self()); uint32_t tid = (uint32_t)(tid64 >> 32) ^ (uint32_t)(tid64); return tid; } int64_t hitsumabushi_nanotime1() { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_MONOTONIC, &tp); return (int64_t)(tp.tv_sec) * 1000000000ll + (int64_t)tp.tv_nsec; } int32_t hitsumabushi_osyield() { return sched_yield(); } int32_t hitsumabushi_sched_getaffinity(pid_t pid, size_t cpusetsize, void *mask) { int32_t numcpu = hitsumabushi_getproccount(); for (int32_t i = 0; i < numcpu; i += 8) ((unsigned char*)mask)[i / 8] = (unsigned char)((1u << (numcpu - i)) - 1); // https://man7.org/linux/man-pages/man2/sched_setaffinity.2.html // > On success, the raw sched_getaffinity() system call returns the // > number of bytes placed copied into the mask buffer; return (numcpu + 7) / 8; } void hitsumabushi_usleep(useconds_t usec) { usleep(usec); } void hitsumabushi_walltime1(int64_t* sec, int32_t* nsec) { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_REALTIME, &tp); *sec = tp.tv_sec; *nsec = tp.tv_nsec; } void hitsumabushi_exit(int32_t code) { exit(code); } ================================================ FILE: 1.25_linux/runtime/cgo/hitsumabushi_thread_linux.c ================================================ void hitsumabushi_initializeThread(void) { } ================================================ FILE: 1.25_linux/runtime/cgo/linux_syscall.c.patch ================================================ //--from #include #include #include #include #include "libcgo.h" //--to #include #include #include #include "libcgo.h" //--from void _cgo_libc_setegid(argset_t* x) { SET_RETVAL(setegid((gid_t) x->args[0])); } //--to void _cgo_libc_setegid(argset_t* x) { } //--from void _cgo_libc_seteuid(argset_t* x) { SET_RETVAL(seteuid((uid_t) x->args[0])); } //--to void _cgo_libc_seteuid(argset_t* x) { } //--from void _cgo_libc_setgid(argset_t* x) { SET_RETVAL(setgid((gid_t) x->args[0])); } //--to void _cgo_libc_setgid(argset_t* x) { } //--from void _cgo_libc_setgroups(argset_t* x) { SET_RETVAL(setgroups((size_t) x->args[0], (const gid_t *) x->args[1])); } //--to void _cgo_libc_setgroups(argset_t* x) { } //--from void _cgo_libc_setregid(argset_t* x) { SET_RETVAL(setregid((gid_t) x->args[0], (gid_t) x->args[1])); } //--to void _cgo_libc_setregid(argset_t* x) { } //--from void _cgo_libc_setresgid(argset_t* x) { SET_RETVAL(setresgid((gid_t) x->args[0], (gid_t) x->args[1], (gid_t) x->args[2])); } //--to void _cgo_libc_setresgid(argset_t* x) { } //--from void _cgo_libc_setreuid(argset_t* x) { SET_RETVAL(setreuid((uid_t) x->args[0], (uid_t) x->args[1])); } //--to void _cgo_libc_setreuid(argset_t* x) { } //--from void _cgo_libc_setuid(argset_t* x) { SET_RETVAL(setuid((uid_t) x->args[0])); } //--to void _cgo_libc_setuid(argset_t* x) { } ================================================ FILE: 1.25_linux/runtime/cgo/sigaction.go.patch ================================================ //--from //go:build (linux && (amd64 || arm64 || loong64 || ppc64le)) || (freebsd && amd64) //--to //go:build (linux && (arm64 || loong64 || ppc64le)) || (freebsd && amd64) ================================================ FILE: 1.25_linux/runtime/crash_test.go.patch ================================================ //--from func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { //--to func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { t.Skip("buildTestProg is not supported in this environment") //--from func TestPanicInlined(t *testing.T) { //--to func TestPanicInlined(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.25_linux/runtime/crash_unix_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.25_linux/runtime/debug/heapdump_test.go.patch ================================================ //--from func TestWriteHeapDumpNonempty(t *testing.T) { //--to func TestWriteHeapDumpNonempty(t *testing.T) { t.Skip("file is not supported in this environment") //--from func TestWriteHeapDumpFinalizers(t *testing.T) { //--to func TestWriteHeapDumpFinalizers(t *testing.T) { t.Skip("file is not supported in this environment") //--from func TestWriteHeapDumpTypeName(t *testing.T) { //--to func TestWriteHeapDumpTypeName(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.25_linux/runtime/debug/panic_test.go.patch ================================================ //--from func TestPanicOnFault(t *testing.T) { //--to func TestPanicOnFault(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.25_linux/runtime/debug/stack_test.go.patch ================================================ //--from func TestSetCrashOutput(t *testing.T) { //--to func TestSetCrashOutput(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.25_linux/runtime/debug_test.go.patch ================================================ //--from //go:build (amd64 || arm64 || loong64 || ppc64le) && linux && !race //--to //go:build ignore ================================================ FILE: 1.25_linux/runtime/decoratemappings_test.go.patch ================================================ //--from func TestDecorateMappings(t *testing.T) { //--to func TestDecorateMappings(t *testing.T) { t.Skip("files are not supported in this environment") ================================================ FILE: 1.25_linux/runtime/export_unix_test.go ================================================ // Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build unix package runtime const ( O_WRONLY = _O_WRONLY O_CREAT = _O_CREAT O_TRUNC = _O_TRUNC ) ================================================ FILE: 1.25_linux/runtime/fds_unix.go.patch ================================================ //--from func checkfds() { //--to func checkfds() { return ================================================ FILE: 1.25_linux/runtime/mem_linux.go ================================================ // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This implementation is the most fundamental and minimal allocations like Wasm. // Malloced memory regions are never freed. package runtime import ( "internal/abi" "unsafe" ) const ( _EINVAL = 22 ) // Don't split the stack as this method may be invoked without a valid G, which // prevents us from allocating more stack. // //go:nosplit func sysAllocOS(n uintptr, vmaName string) (ptr unsafe.Pointer) { return sysAllocOSImpl(n) } //go:nosplit //go:cgo_unsafe_args func sysAllocOSImpl(n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysAllocOS_trampoline)), unsafe.Pointer(&n)) return } func sysAllocOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit //go:cgo_unsafe_args func sysUnusedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUnusedOS_trampoline)), unsafe.Pointer(&v)) } func sysUnusedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysUsedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUsedOS_trampoline)), unsafe.Pointer(&v)) } func sysUsedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysHugePageOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysHugePageOS_trampoline)), unsafe.Pointer(&v)) } func sysHugePageOS_trampoline(n uintptr, size uintptr) func sysNoHugePageOS(v unsafe.Pointer, n uintptr) { } func sysHugePageCollapseOS(v unsafe.Pointer, n uintptr) { } // Don't split the stack as this function may be invoked without a valid G, // which prevents us from allocating more stack. // //go:nosplit //go:cgo_unsafe_args func sysFreeOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFreeOS_trampoline)), unsafe.Pointer(&v)) } func sysFreeOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysFaultOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFaultOS_trampoline)), unsafe.Pointer(&v)) } func sysFaultOS_trampoline(n uintptr, size uintptr) //go:nosplit func sysReserveOS(v unsafe.Pointer, n uintptr, vmaName string) (ptr unsafe.Pointer) { return sysReserveOSImpl(v, n) } //go:nosplit //go:cgo_unsafe_args func sysReserveOSImpl(v unsafe.Pointer, n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysReserveOS_trampoline)), unsafe.Pointer(&v)) return } func sysReserveOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit func sysMapOS(v unsafe.Pointer, n uintptr, vmaName string) { sysMapOSImpl(v, n) } //go:nosplit //go:cgo_unsafe_args func sysMapOSImpl(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysMapOS_trampoline)), unsafe.Pointer(&v)) } func sysMapOS_trampoline(n uintptr, size uintptr) ================================================ FILE: 1.25_linux/runtime/memmove_linux_amd64_test.go.patch ================================================ //--from func TestMemmoveOverflow(t *testing.T) { //--to func TestMemmoveOverflow(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.25_linux/runtime/metrics_test.go.patch ================================================ //--from name: "runtime/debug.WriteHeapDump", fn: func(t *testing.T) { //--to name: "runtime/debug.WriteHeapDump", fn: func(t *testing.T) { t.Skip("debug.WriteHeapDump is not supported in this environment") ================================================ FILE: 1.25_linux/runtime/nbpipe_pipe2.go.patch ================================================ //--from //go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris //--to //go:build dragonfly || freebsd || netbsd || openbsd || solaris ================================================ FILE: 1.25_linux/runtime/nbpipe_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.25_linux/runtime/netpoll_epoll.go.patch ================================================ //--from //go:build linux //--to //go:build ignore ================================================ FILE: 1.25_linux/runtime/netpoll_fake.go.patch ================================================ //--from //go:build js && wasm //--to //go:build linux ================================================ FILE: 1.25_linux/runtime/nosan_linux_test.go.patch ================================================ //--from func TestNewOSProc0(t *testing.T) { //--to func TestNewOSProc0(t *testing.T) { t.Skip("newosproc0 is not supported in this environment") ================================================ FILE: 1.25_linux/runtime/os_linux.go.patch ================================================ //--from import ( "internal/abi" "internal/goarch" "internal/runtime/atomic" "internal/runtime/strconv" "internal/runtime/syscall" "unsafe" ) //--to import ( "internal/abi" "internal/runtime/atomic" "internal/runtime/strconv" "internal/runtime/syscall" "unsafe" ) //--from //go:noescape func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 //--to //go:nosplit //go:cgo_unsafe_args func futex(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 { ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(futex_trampoline)), unsafe.Pointer(&addr)) return ret } func futex_trampoline(addr unsafe.Pointer, op int32, val uint32, ts, addr2 unsafe.Pointer, val3 uint32) int32 //--from func sysargs(argc int32, argv **byte) { n := argc + 1 // skip over argv, envp to get to auxv for argv_index(argv, n) != nil { n++ } // skip NULL separator n++ // now argv+n is auxv auxvp := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*goarch.PtrSize)) if pairs := sysauxv(auxvp[:]); pairs != 0 { auxv = auxvp[: pairs*2 : pairs*2] return } // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } n = read(fd, noescape(unsafe.Pointer(&auxvreadbuf[0])), int32(unsafe.Sizeof(auxvreadbuf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. auxvreadbuf[len(auxvreadbuf)-2] = _AT_NULL pairs := sysauxv(auxvreadbuf[:]) auxv = auxvreadbuf[: pairs*2 : pairs*2] } //--to func sysargs(argc int32, argv **byte) { // argc/argv is not reliable on some machines. // Skip analysing them. // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } n := read(fd, noescape(unsafe.Pointer(&auxvreadbuf[0])), int32(unsafe.Sizeof(auxvreadbuf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. auxvreadbuf[len(auxvreadbuf)-2] = _AT_NULL pairs := sysauxv(auxvreadbuf[:]) auxv = auxvreadbuf[: pairs*2 : pairs*2] } //--from var urandom_dev = []byte("/dev/urandom\x00") func readRandom(r []byte) int { // Note that all supported Linux kernels should provide AT_RANDOM which // populates startupRand, so this fallback should be unreachable. fd := open(&urandom_dev[0], 0 /* O_RDONLY */, 0) n := read(fd, unsafe.Pointer(&r[0]), int32(len(r))) closefd(fd) return int(n) } //--to //go:nosplit func readRandom(r []byte) int { return 0 } //--from func gettid() uint32 //--to //go:nosplit //go:cgo_unsafe_args func gettid() (tid uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(gettid_trampoline)), unsafe.Pointer(&tid)) return } func gettid_trampoline() uint32 //--from //go:noescape func sigaltstack(new, old *stackt) //--to func sigaltstack(new, old *stackt) { // Do nothing. } //--from func sigprocmask(how int32, new, old *sigset) { rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--to func sigprocmask(how int32, new, old *sigset) { // Do nothing. // rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--from func raise(sig uint32) //--to func raise(sig uint32) { // Do nothing } //--from func raiseproc(sig uint32) //--to func raiseproc(sig uint32) { // Do nothing } //--from //go:noescape func sched_getaffinity(pid, len uintptr, buf *byte) int32 //--to //go:nosplit //go:cgo_unsafe_args func sched_getaffinity(pid, len uintptr, buf *byte) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(sched_getaffinity_trampoline)), unsafe.Pointer(&pid)) } func sched_getaffinity_trampoline(pid, len uintptr, buf *byte) int32 //--from func osyield() //--to //go:nosplit //go:cgo_unsafe_args func osyield() { libcCall(unsafe.Pointer(abi.FuncPCABI0(osyield_trampoline)), nil) } func osyield_trampoline() //--from func sysSigaction(sig uint32, new, old *sigactiont) { //--to func sysSigaction(sig uint32, new, old *sigactiont) { // Do nothing. return //--from func signalM(mp *m, sig int) { tgkill(getpid(), int(mp.procid), sig) } //--to func signalM(mp *m, sig int) { // Do nothiing. } //--from func runPerThreadSyscall() { gp := getg() if gp.m.needPerThreadSyscall.Load() == 0 { return } args := perThreadSyscall r1, r2, errno := syscall.Syscall6(args.trap, args.a1, args.a2, args.a3, args.a4, args.a5, args.a6) if GOARCH == "ppc64" || GOARCH == "ppc64le" { // TODO(https://go.dev/issue/51192 ): ppc64 doesn't use r2. r2 = 0 } if errno != 0 || r1 != args.r1 || r2 != args.r2 { print("trap:", args.trap, ", a123456=[", args.a1, ",", args.a2, ",", args.a3, ",", args.a4, ",", args.a5, ",", args.a6, "]\n") print("results: got {r1=", r1, ",r2=", r2, ",errno=", errno, "}, want {r1=", args.r1, ",r2=", args.r2, ",errno=0}\n") fatal("AllThreadsSyscall6 results differ between threads; runtime corrupted") } gp.m.needPerThreadSyscall.Store(0) } //--to func runPerThreadSyscall() { // Do nothing. // needPerThreadSyscall should never be 1 as syscall_runtime_doAllThreadsSyscall is not available with Cgo. } //--append //go:linkname hitsumabushi_closefd hitsumabushi_closefd //go:cgo_import_static hitsumabushi_closefd var hitsumabushi_closefd byte //go:linkname hitsumabushi_exit hitsumabushi_exit //go:cgo_import_static hitsumabushi_exit var hitsumabushi_exit byte //go:linkname hitsumabushi_gettid hitsumabushi_gettid //go:cgo_import_static hitsumabushi_gettid var hitsumabushi_gettid byte //go:linkname hitsumabushi_nanotime1 hitsumabushi_nanotime1 //go:cgo_import_static hitsumabushi_nanotime1 var hitsumabushi_nanotime1 byte //go:linkname hitsumabushi_open hitsumabushi_open //go:cgo_import_static hitsumabushi_open var hitsumabushi_open byte //go:linkname hitsumabushi_osyield hitsumabushi_osyield //go:cgo_import_static hitsumabushi_osyield var hitsumabushi_osyield byte //go:linkname hitsumabushi_read hitsumabushi_read //go:cgo_import_static hitsumabushi_read var hitsumabushi_read byte //go:linkname hitsumabushi_sched_getaffinity hitsumabushi_sched_getaffinity //go:cgo_import_static hitsumabushi_sched_getaffinity var hitsumabushi_sched_getaffinity byte //go:linkname hitsumabushi_usleep hitsumabushi_usleep //go:cgo_import_static hitsumabushi_usleep var hitsumabushi_usleep byte //go:linkname hitsumabushi_walltime1 hitsumabushi_walltime1 //go:cgo_import_static hitsumabushi_walltime1 var hitsumabushi_walltime1 byte //go:linkname hitsumabushi_write1 hitsumabushi_write1 //go:cgo_import_static hitsumabushi_write1 var hitsumabushi_write1 byte //go:nosplit //go:cgo_unsafe_args func fcntl1(fd, cmd, arg int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fcntl_trampoline)), unsafe.Pointer(&fd)) } func fcntl_trampoline() //go:nosplit //go:cgo_unsafe_args func fstat1(fd int, stat unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstat_trampoline)), unsafe.Pointer(&fd)) } func fstat_trampoline(fd int, stat unsafe.Pointer) int32 //go:nosplit //go:cgo_unsafe_args func lseek1(fd int, offset int64, whence int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(lseek_trampoline)), unsafe.Pointer(&fd)) } func lseek_trampoline() //go:nosplit //go:cgo_unsafe_args func renameat(fd1 int, name1 unsafe.Pointer, fd2 int, name2 unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(renameat_trampoline)), unsafe.Pointer(&fd1)) } func renameat_trampoline() //go:nosplit //go:cgo_unsafe_args func fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstatat_trampoline)), unsafe.Pointer(&fd)) } func fstatat_trampoline() ================================================ FILE: 1.25_linux/runtime/panicnil_test.go.patch ================================================ //--from func TestPanicNil(t *testing.T) { //--to func TestPanicNil(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.25_linux/runtime/proc_test.go.patch ================================================ //--from func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) testGoroutineParallelism2(t, false, true) testGoroutineParallelism2(t, true, true) } //--to func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) //testGoroutineParallelism2(t, false, true) //testGoroutineParallelism2(t, true, true) } ================================================ FILE: 1.25_linux/runtime/rand_test.go.patch ================================================ //--from func TestReadRandom(t *testing.T) { //--to func TestReadRandom(t *testing.T) { t.Skip("readRandom is not available in this environment") ================================================ FILE: 1.25_linux/runtime/runtime1.go.patch ================================================ //--from func argv_index(argv **byte, i int32) *byte { return *(**byte)(add(unsafe.Pointer(argv), uintptr(i)*goarch.PtrSize)) } //--to func argv_index(argv **byte, i int32) *byte { return nil } //--from func args(c int32, v **byte) { argc = c argv = v sysargs(c, v) } //--to func args(c int32, v **byte) { // In the original code, physPageSize is determined at sysargs. // Hitsumabushi gives an initial value for physPageSize at its declaration, so sysargs doesn't have to be called. } //--append // Expose the entry point for some special environments. //go:cgo_export_static _rt0_amd64_linux_lib //go:cgo_export_dynamic _rt0_amd64_linux_lib ================================================ FILE: 1.25_linux/runtime/runtime_linux_test.go.patch ================================================ //--from func TestMincoreErrorSign(t *testing.T) { //--to func TestMincoreErrorSign(t *testing.T) { t.Skip("mincore is not supported in this environment") ================================================ FILE: 1.25_linux/runtime/runtime_mmap_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.25_linux/runtime/runtime_test.go.patch ================================================ //--from func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { //--to func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { t.Skip("catching faults is not supported in this environment") ================================================ FILE: 1.25_linux/runtime/runtime_unix_test.go.patch ================================================ //--from //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || plan9 //--to //go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || plan9 ================================================ FILE: 1.25_linux/runtime/stack_test.go.patch ================================================ //--from func TestDeferLeafSigpanic(t *testing.T) { //--to func TestDeferLeafSigpanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestStackWrapperStackPanic(t *testing.T) { //--to func TestStackWrapperStackPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.25_linux/runtime/stubs2.go.patch ================================================ //--from import ( "internal/runtime/atomic" "unsafe" ) //--to import ( "internal/abi" "internal/runtime/atomic" "unsafe" ) //--from func read(fd int32, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func read(fd int32, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(read_trampoline)), unsafe.Pointer(&fd)) } func read_trampoline(fd int32, p unsafe.Pointer, n int32) int32 //--from func closefd(fd int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func closefd(fd int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(closefd_trampoline)), unsafe.Pointer(&fd)) } func closefd_trampoline(fd int32) int32 //--from func exit(code int32) //--to //go:nosplit //go:cgo_unsafe_args func exit(code int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(exit_trampoline)), unsafe.Pointer(&code)) } func exit_trampoline(code int32) //--from func usleep(usec uint32) //--to //go:nosplit //go:cgo_unsafe_args func usleep(usec uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } func usleep_trampoline(usec uint32) //--from //go:nosplit func usleep_no_g(usec uint32) { usleep(usec) } //--to //go:nosplit //go:cgo_unsafe_args func usleep_no_g(usec uint32) { asmcgocall_no_g(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } //--from //go:noescape func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func write1(fd uintptr, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(write1_trampoline)), unsafe.Pointer(&fd)) } func write1_trampoline(fd uintptr, p unsafe.Pointer, n int32) int32 //--from //go:noescape func open(name *byte, mode, perm int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func open(name *byte, mode, perm int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(open_trampoline)), unsafe.Pointer(&name)) } func open_trampoline(name *byte, mode, perm int32) int32 ================================================ FILE: 1.25_linux/runtime/stubs3.go.patch ================================================ //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func nanotime1() int64 //--to //go:nosplit //go:cgo_unsafe_args func nanotime1() (now int64) { libcCall(unsafe.Pointer(abi.FuncPCABI0(nanotime1_trampoline)), unsafe.Pointer(&now)) return } func nanotime1_trampoline() int64 ================================================ FILE: 1.25_linux/runtime/sys_libc.go.patch ================================================ //--from //go:build darwin || (openbsd && !mips64) //--to //go:build darwin || (openbsd && !mips64) || linux ================================================ FILE: 1.25_linux/runtime/sys_linux_amd64.s.patch ================================================ //--from TEXT runtime·open(SB),NOSPLIT,$0-20 // This uses openat instead of open, because Android O blocks open. MOVL $AT_FDCWD, DI // AT_FDCWD, so this acts like open MOVQ name+0(FP), SI MOVL mode+8(FP), DX MOVL perm+12(FP), R10 MOVL $SYS_openat, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVL 8(DI), SI // arg 2 flags MOVL 12(DI), DX // arg 3 mode MOVQ 0(DI), DI // arg 1 pathname XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_open(SB) MOVQ AX, 16(BX) POPQ BP RET //--from TEXT runtime·futex(SB),NOSPLIT,$0 MOVQ addr+0(FP), DI MOVL op+8(FP), SI MOVL val+12(FP), DX MOVQ ts+16(FP), R10 MOVQ addr2+24(FP), R8 MOVL val3+32(FP), R9 MOVL $SYS_futex, AX SYSCALL MOVL AX, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 addr MOVL 8(BX), SI // arg 2 op MOVL 12(BX), DX // arg 3 val MOVQ 16(BX), CX // arg 4 ts MOVQ 24(BX), R8 // arg 5 addr2 MOVL 32(BX), R9 // arg 6 val3 CALL hitsumabushi_futex(SB) MOVL AX, 40(BX) POPQ BP RET //--from TEXT runtime·exit(SB),NOSPLIT,$0-4 MOVL code+0(FP), DI MOVL $SYS_exit_group, AX SYSCALL RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 exit status CALL hitsumabushi_exit(SB) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·read(SB),NOSPLIT,$0-28 MOVL fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_read, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 0(BX), DI // arg 1 fd MOVQ 8(BX), SI // arg 2 buf MOVQ 16(BX), DX // arg 3 count CALL hitsumabushi_read(SB) MOVQ AX, 24(BX) // return value POPQ BP RET //--from TEXT runtime·closefd(SB),NOSPLIT,$0-12 MOVL fd+0(FP), DI MOVL $SYS_close, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 fd CALL hitsumabushi_closefd(SB) POPQ BP RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVL $SYS_gettid, AX SYSCALL MOVL AX, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_gettid(SB) POPQ BP RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT,$0 MOVQ new+0(FP), DI MOVQ old+8(FP), SI MOVQ $SYS_sigaltstack, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $0xf1, 0xf1 // crash RET //--to TEXT runtime·sigaltstack_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 old MOVQ 0(DI), DI // arg 1 new CALL hitsumabushi_sigaltstack(SB) TESTQ AX, AX JEQ 2(PC) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·raise(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, R12 MOVL $SYS_gettid, AX SYSCALL MOVL AX, SI // arg 2 tid MOVL R12, DI // arg 1 pid MOVL sig+0(FP), DX // arg 3 MOVL $SYS_tgkill, AX SYSCALL RET //--to TEXT runtime·raise_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 signal CALL hitsumabushi_raise(SB) POPQ BP RET //--from TEXT runtime·raiseproc(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, DI // arg 1 pid MOVL sig+0(FP), SI // arg 2 MOVL $SYS_kill, AX SYSCALL RET //--to TEXT runtime·raiseproc_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), BX // signal CALL hitsumabushi_getpid(SB) MOVL AX, DI // arg 1 pid MOVL BX, SI // arg 2 signal CALL hitsumabushi_kill(SB) POPQ BP RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0 MOVQ pid+0(FP), DI MOVQ len+8(FP), SI MOVQ buf+16(FP), DX MOVL $SYS_sched_getaffinity, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 len MOVQ 16(DI), DX // arg 3 buf MOVQ 0(DI), DI // arg 1 pid CALL hitsumabushi_sched_getaffinity(SB) POPQ BP RET //--from TEXT runtime·osyield(SB),NOSPLIT,$0 MOVL $SYS_sched_yield, AX SYSCALL RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_osyield(SB) POPQ BP RET //--from TEXT runtime·usleep(SB),NOSPLIT,$16 MOVL $0, DX MOVL usec+0(FP), AX MOVL $1000000, CX DIVL CX MOVQ AX, 0(SP) MOVL $1000, AX // usec to nsec MULL DX MOVQ AX, 8(SP) // nanosleep(&ts, 0) MOVQ SP, DI MOVL $0, SI MOVL $SYS_nanosleep, AX SYSCALL RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 usec CALL hitsumabushi_usleep(SB) POPQ BP RET //--from TEXT runtime·write1(SB),NOSPLIT,$0-28 MOVQ fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_write, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 p MOVQ 16(DI), DX // arg 3 n MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_write1(SB) POPQ BP RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$16-8 // We don't know how much stack space the VDSO code will need, // so switch to g0. // In particular, a kernel configured with CONFIG_OPTIMIZE_INLINING=n // and hardening can use a full page of stack space in gettime_sym // due to stack probes inserted to avoid stack/heap collisions. // See issue #20427. MOVQ SP, R12 // Save old SP; R12 unchanged by C code. MOVQ g_m(R14), BX // BX unchanged by C code. // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVQ m_vdsoPC(BX), CX MOVQ m_vdsoSP(BX), DX MOVQ CX, 0(SP) MOVQ DX, 8(SP) LEAQ ret+0(FP), DX MOVQ -8(DX), CX MOVQ CX, m_vdsoPC(BX) MOVQ DX, m_vdsoSP(BX) CMPQ R14, m_curg(BX) // Only switch if on curg. JNE noswitch MOVQ m_g0(BX), DX MOVQ (g_sched+gobuf_sp)(DX), SP // Set SP to g0 stack noswitch: SUBQ $16, SP // Space for results ANDQ $~15, SP // Align for C code MOVL $1, DI // CLOCK_MONOTONIC LEAQ 0(SP), SI MOVQ runtime·vdsoClockgettimeSym(SB), AX CMPQ AX, $0 JEQ fallback CALL AX ret: MOVQ 0(SP), AX // sec MOVQ 8(SP), DX // nsec MOVQ R12, SP // Restore real SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVQ 8(SP), CX MOVQ CX, m_vdsoSP(BX) MOVQ 0(SP), CX MOVQ CX, m_vdsoPC(BX) // sec is in AX, nsec in DX // return nsec in AX IMULQ $1000000000, AX ADDQ DX, AX MOVQ AX, ret+0(FP) RET fallback: MOVQ $SYS_clock_gettime, AX SYSCALL JMP ret //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ DI, BX // BX is callee-saved MOVQ SP, BP CALL hitsumabushi_nanotime1(SB) MOVQ AX, 0(BX) POPQ BP RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(DI), DI CALL hitsumabushi_sysAllocOS(SB) MOVQ AX, 8(BX) POPQ BP RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUnusedOS(SB) POPQ BP RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUsedOS(SB) POPQ BP RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysHugePageOS(SB) POPQ BP RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFreeOS(SB) POPQ BP RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFaultOS(SB) POPQ BP RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysReserveOS(SB) MOVQ AX, 16(BX) POPQ BP RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysMapOS(SB) POPQ BP RET TEXT runtime·walltime1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_walltime1(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 cmd MOVQ 16(DI), DX // arg 3 arg MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_fcntl(SB) POPQ BP RET TEXT runtime·fstat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 stat MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_fstat(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·lseek_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 offset MOVQ 16(DI), DX // arg 3 whence MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_lseek(SB) MOVQ AX, 24(BX) // return value POPQ BP RET TEXT runtime·renameat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_renameat(SB) MOVL AX, 32(BX) POPQ BP RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_fstatat(SB) MOVL AX, 32(BX) POPQ BP RET ================================================ FILE: 1.25_linux/runtime/sys_linux_arm64.s.patch ================================================ //--from #define SYS_exit 93 #define SYS_read 63 #define SYS_write 64 #define SYS_openat 56 #define SYS_close 57 #define SYS_pipe2 59 #define SYS_nanosleep 101 #define SYS_mmap 222 #define SYS_munmap 215 #define SYS_setitimer 103 #define SYS_clone 220 #define SYS_sched_yield 124 #define SYS_rt_sigreturn 139 #define SYS_rt_sigaction 134 #define SYS_rt_sigprocmask 135 #define SYS_sigaltstack 132 #define SYS_madvise 233 #define SYS_mincore 232 #define SYS_getpid 172 #define SYS_gettid 178 #define SYS_kill 129 #define SYS_tgkill 131 #define SYS_futex 98 #define SYS_sched_getaffinity 123 #define SYS_exit_group 94 #define SYS_clock_gettime 113 #define SYS_faccessat 48 #define SYS_socket 198 #define SYS_connect 203 #define SYS_brk 214 #define SYS_timer_create 107 #define SYS_timer_settime 110 #define SYS_timer_delete 111 //--to #define SYS_exit 2147483647 #define SYS_read 2147483647 #define SYS_write 2147483647 #define SYS_openat 2147483647 #define SYS_close 2147483647 #define SYS_pipe2 2147483647 #define SYS_nanosleep 2147483647 #define SYS_mmap 2147483647 #define SYS_munmap 2147483647 #define SYS_setitimer 2147483647 #define SYS_clone 2147483647 #define SYS_sched_yield 2147483647 #define SYS_rt_sigreturn 2147483647 #define SYS_rt_sigaction 2147483647 #define SYS_rt_sigprocmask 2147483647 #define SYS_sigaltstack 2147483647 #define SYS_madvise 2147483647 #define SYS_mincore 2147483647 #define SYS_getpid 2147483647 #define SYS_gettid 2147483647 #define SYS_kill 2147483647 #define SYS_tgkill 2147483647 #define SYS_futex 2147483647 #define SYS_sched_getaffinity 2147483647 #define SYS_exit_group 2147483647 #define SYS_clock_gettime 2147483647 #define SYS_faccessat 2147483647 #define SYS_socket 2147483647 #define SYS_connect 2147483647 #define SYS_brk 2147483647 #define SYS_timer_create 2147483647 #define SYS_timer_settime 2147483647 #define SYS_timer_delete 2147483647 //--from TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0-4 MOVW code+0(FP), R0 MOVD $SYS_exit_group, R8 SVC RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_exit(SB) RET //--from TEXT runtime·open(SB),NOSPLIT|NOFRAME,$0-20 MOVD $AT_FDCWD, R0 MOVD name+0(FP), R1 MOVW mode+8(FP), R2 MOVW perm+12(FP), R3 MOVD $SYS_openat, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_open(SB) RET //--from TEXT runtime·closefd(SB),NOSPLIT|NOFRAME,$0-12 MOVW fd+0(FP), R0 MOVD $SYS_close, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT,$0-12 MOVW 0(R0), R0 BL hitsumabushi_closefd(SB) RET //--from TEXT runtime·write1(SB),NOSPLIT|NOFRAME,$0-28 MOVD fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_write, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_write1(SB) RET //--from TEXT runtime·read(SB),NOSPLIT|NOFRAME,$0-28 MOVW fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_read, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_read(SB) RET //--from TEXT runtime·usleep(SB),NOSPLIT,$24-4 MOVWU usec+0(FP), R3 MOVD R3, R5 MOVW $1000000, R4 UDIV R4, R3 MOVD R3, 8(RSP) MUL R3, R4 SUB R4, R5 MOVW $1000, R4 MUL R4, R5 MOVD R5, 16(RSP) // nanosleep(&ts, 0) ADD $8, RSP, R0 MOVD $0, R1 MOVD $SYS_nanosleep, R8 SVC RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_usleep(SB) RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVD $SYS_gettid, R8 SVC MOVW R0, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_gettid(SB) MOVW R0, 0(R19) // return value RET //--from TEXT runtime·raise(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R19 MOVD $SYS_gettid, R8 SVC MOVW R0, R1 // arg 2 tid MOVW R19, R0 // arg 1 pid MOVW sig+0(FP), R2 // arg 3 MOVD $SYS_tgkill, R8 SVC RET //--to //--from TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R0 // arg 1 pid MOVW sig+0(FP), R1 // arg 2 MOVD $SYS_kill, R8 SVC RET //--to //--from TEXT runtime·walltime(SB),NOSPLIT,$24-12 MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $16, R1 BIC $15, R1 // Align for C code MOVD R1, RSP MOVW $CLOCK_REALTIME, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) MOVD R3, sec+0(FP) MOVW R5, nsec+8(FP) RET //--to TEXT runtime·walltime1_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_walltime1(SB) RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$24-8 MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $32, R1 BIC $15, R1 MOVD R1, RSP MOVW $CLOCK_MONOTONIC, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) // sec is in R3, nsec in R5 // return nsec in R3 MOVD $1000000000, R4 MUL R4, R3 ADD R5, R3 MOVD R3, ret+0(FP) RET //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_nanotime1(SB) MOVD R0, 0(R19) // return value RET //--from TEXT runtime·futex(SB),NOSPLIT|NOFRAME,$0 MOVD addr+0(FP), R0 MOVW op+8(FP), R1 MOVW val+12(FP), R2 MOVD ts+16(FP), R3 MOVD addr2+24(FP), R4 MOVW val3+32(FP), R5 MOVD $SYS_futex, R8 SVC MOVW R0, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 16(R0), R3 MOVD 24(R0), R4 MOVW 32(R0), R5 MOVD 0(R0), R0 BL hitsumabushi_futex(SB) RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT|NOFRAME,$0 MOVD new+0(FP), R0 MOVD old+8(FP), R1 MOVD $SYS_sigaltstack, R8 SVC CMN $4095, R0 BCC ok MOVD $0, R0 MOVD R0, (R0) // crash ok: RET //--to //--from TEXT runtime·osyield(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_sched_yield, R8 SVC RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT,$0 BL hitsumabushi_osyield(SB) RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT|NOFRAME,$0 MOVD pid+0(FP), R0 MOVD len+8(FP), R1 MOVD buf+16(FP), R2 MOVD $SYS_sched_getaffinity, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVD 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_sched_getaffinity(SB) RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 0(R0), R0 BL hitsumabushi_sysAllocOS(SB) MOVD R0, 8(R19) // return value RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUnusedOS(SB) RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUsedOS(SB) RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysHugePageOS(SB) RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFreeOS(SB) RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFaultOS(SB) RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysReserveOS(SB) MOVD R0, 16(R19) // return value RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysMapOS(SB) RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVW 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_fcntl(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·fstat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 0(R0), R0 BL hitsumabushi_fstat(SB) MOVW R0, 16(R19) // return value RET TEXT runtime·lseek_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_lseek(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·renameat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_renameat(SB) MOVW R0, 32(R19) // return value RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_fstatat(SB) MOVW R0, 32(R19) // return value RET ================================================ FILE: 1.25_linux/runtime/time_linux_amd64.s.patch ================================================ //--from //go:build !faketime //--to //go:build ignore ================================================ FILE: 1.25_linux/runtime/timeasm.go.patch ================================================ //--from //go:build !faketime && (windows || (linux && amd64)) //--to //go:build !faketime && windows ================================================ FILE: 1.25_linux/runtime/timestub.go.patch ================================================ //--from //go:build !faketime && !windows && !(linux && amd64) && !plan9 //--to //go:build !faketime && !windows && !plan9 ================================================ FILE: 1.25_linux/runtime/timestub2.go.patch ================================================ //--from //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !wasip1 && !windows && !(linux && amd64) && !plan9 //--to //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !wasip1 && !windows && !plan9 //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func walltime() (sec int64, nsec int32) //--to func walltime() (sec int64, nsec int32) { walltime1(&sec, &nsec) return } //go:nosplit //go:cgo_unsafe_args func walltime1(sec *int64, nsec *int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(walltime1_trampoline)), unsafe.Pointer(&sec)) } func walltime1_trampoline(sec *int64, nsec *int32) ================================================ FILE: 1.25_linux/runtime/traceback_test.go.patch ================================================ //--from func TestTracebackInlined(t *testing.T) { //--to func TestTracebackInlined(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.25_linux/strconv/fp_test.go.patch ================================================ //--from func TestFp(t *testing.T) { //--to func TestFp(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.25_linux/sync/atomic/atomic_test.go.patch ================================================ //--from func TestStoreLoadSeqCst32(t *testing.T) { //--to func TestStoreLoadSeqCst32(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") //--from func TestStoreLoadSeqCst64(t *testing.T) { //--to func TestStoreLoadSeqCst64(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") //--from func TestNilDeref(t *testing.T) { //--to func TestNilDeref(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.25_linux/syscall/hitsumabushi_stubs_linux_amd64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_FSTATAT = 0xffffffffffffffff // Stub: on amd64 Go uses SYS_NEWFSTATAT instead ) ================================================ FILE: 1.25_linux/syscall/hitsumabushi_stubs_linux_arm64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_NEWFSTATAT = 0xffffffffffffffff // Stub: on arm64 Go uses SYS_FSTATAT instead ) ================================================ FILE: 1.25_linux/syscall/rlimit.go.patch ================================================ //--from func init() { var lim Rlimit if err := Getrlimit(RLIMIT_NOFILE, &lim); err == nil && lim.Max > 0 && lim.Cur < lim.Max-1 { origRlimitNofile.Store(&lim) nlim := lim // We set Cur to Max - 1 so that we are more likely to // detect cases where another process uses prlimit // to change our resource limits. The theory is that // using prlimit to change to Cur == Max is more likely // than using prlimit to change to Cur == Max - 1. // The place we check for this is in exec_linux.go. nlim.Cur = nlim.Max - 1 adjustFileLimit(&nlim) setrlimit(RLIMIT_NOFILE, &nlim) } } //--to func init() { } ================================================ FILE: 1.25_linux/syscall/syscall_linux.go.patch ================================================ //--from func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() // N.B. Calling RawSyscall here is unsafe with atomic coverage // instrumentation and race mode. // // Coverage instrumentation will add a sync/atomic call to RawSyscall. // Race mode will add race instrumentation to sync/atomic. Race // instrumentation requires a P, which we no longer have. // // RawSyscall6 is fine because it is implemented in assembly and thus // has no coverage instrumentation. // // This is typically not a problem in the runtime because cmd/go avoids // adding coverage instrumentation to the runtime in race mode. r1, r2, err = RawSyscall6(trap, a1, a2, a3, 0, 0, 0) runtime_exitsyscall() return } //--to func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FCNTL: r = fcntl1(a1, a2, a3) case SYS_FSTAT: r = fstat1(a1, unsafe.Pointer(a2)) case SYS_READ: r = runtime_read(uintptr(a1), unsafe.Pointer(a2), int32(a3)) case SYS_WRITE: r = write1(a1, unsafe.Pointer(a2), int32(a3)) case SYS_LSEEK: r = lseek1(a1, int64(a2), int32(a3)) case SYS_CLOSE: r = runtime_closefd(int32(a1)) case SYS_MKDIRAT: println("syscall mkdirat() is not implemented") // Default to permission denied. TODO: implement this return 0, 0, EPERM case SYS_GETDENTS64: println("syscall getdents64() is not implemented") // Default to empty directory. TODO: implement this return 0, 0, 0 default: println("unimplemented syscall at runtime.Syscall", trap) panic("syscall.Syscall") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //go:linkname open runtime.open func open(name *byte, mode, perm int32) int32 //go:linkname write1 runtime.write1 func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname fcntl1 runtime.fcntl1 func fcntl1(fd uintptr, a uintptr, b uintptr) int32 //go:linkname fstat1 runtime.fstat1 func fstat1(fd uintptr, p unsafe.Pointer) int32 //go:linkname lseek1 runtime.lseek1 func lseek1(fd uintptr, offset int64, whence int32) int32 //go:linkname runtime_read runtime.read func runtime_read(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname runtime_closefd runtime.closefd func runtime_closefd(fd int32) int32 //go:linkname runtime_fstatat runtime.fstatat func runtime_fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 //go:linkname runtime_renameat runtime.renameat func runtime_renameat(fd1 uintptr, name1 unsafe.Pointer, fd2 uintptr, name2 unsafe.Pointer) int32 //--from func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() r1, r2, err = RawSyscall6(trap, a1, a2, a3, a4, a5, a6) runtime_exitsyscall() return } //--to func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FSTATAT, SYS_NEWFSTATAT: r = runtime_fstatat(uintptr(a1), unsafe.Pointer(a2), unsafe.Pointer(a3), int32(a4)) case SYS_RENAMEAT: r = runtime_renameat(uintptr(a1), unsafe.Pointer(a2), uintptr(a3), unsafe.Pointer(a4)) default: println("unimplemented syscall at runtime.Syscall6", trap) panic("syscall.Syscall6") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //--from func Open(path string, mode int, perm uint32) (fd int, err error) { return openat(_AT_FDCWD, path, mode|O_LARGEFILE, perm) } //--to func Open(path string, mode int, perm uint32) (fd int, err error) { p0, err := BytePtrFromString(path) if err != nil { return -1, errnoErr(EINVAL) } fd = int(open(p0, int32(mode|O_LARGEFILE), int32(perm))) if fd < 0 { return -1, errnoErr(ENOENT) } return } ================================================ FILE: 1.25_linux/testing/run_example.go ================================================ package testing func runExample(eg InternalExample) (ok bool) { // Do nothing. // TODO: Implement os.Pipe2 and use this here. return true } ================================================ FILE: 1.25_linux/time/format_test.go.patch ================================================ //--from func TestParseInLocation(t *testing.T) { //--to func TestParseInLocation(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationZipFile(t *testing.T) { //--to func TestLoadLocationZipFile(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.25_linux/time/internal_test.go.patch ================================================ //--from func initTestingZone() { // For hermeticity, use only tzinfo source from the test's GOROOT, // not the system sources and not whatever GOROOT may happen to be // set in the process's environment (if any). // This test runs in GOROOT/src/time, so GOROOT is "../..", // but it is theoretically possible sources := []string{"../../lib/time/zoneinfo.zip"} z, err := loadLocation("America/Los_Angeles", sources) if err != nil { panic("cannot load America/Los_Angeles for testing: " + err.Error() + "; you may want to use -tags=timetzdata") } z.name = "Local" localLoc = *z } //--to func initTestingZone() { // Data from the playground. // https://go.dev/play/p/VGXU57KZZ-x // name is replaced with "Local". // cachStart, cacheEnd, and cacheZone are removed. localLoc = Location{name:"Local",zone:[]zone{zone{name:"LMT", offset:-28378, isDST:false}, zone{name:"PDT", offset:-25200, isDST:true}, zone{name:"PST", offset:-28800, isDST:false}, zone{name:"PWT", offset:-25200, isDST:true}, zone{name:"PPT", offset:-25200, isDST:true}}, tx:[]zoneTrans{zoneTrans{when:-576460752303423488, index:0x0, isstd:false, isutc:false}, zoneTrans{when:-2717640000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1633269600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-1615129200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1601820000, index:0x1, isstd:true, isutc:true}, zoneTrans{when:-1583679600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-880207200, index:0x3, isstd:false, isutc:false}, zoneTrans{when:-769395600, index:0x4, isstd:false, isutc:false}, zoneTrans{when:-765385200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-687967140, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-662655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-620838000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-608137200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-589388400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-576082800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-557938800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-544633200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-526489200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-513183600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-495039600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-481734000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-463590000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-450284400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-431535600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-418230000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-400086000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-386780400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-368636400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-355330800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-337186800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-323881200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-305737200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-292431600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-273682800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-260982000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-242233200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-226508400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-210783600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-195058800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-179334000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-163609200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-147884400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-131554800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-116434800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-100105200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-84376800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-68655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-52927200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-37206000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-21477600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-5756400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:9972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:25693200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:41421600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:57747600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:73476000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:89197200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:104925600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:120646800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:126698400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:152096400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:162381600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:183546000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:199274400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:215600400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:230724000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:247050000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:262778400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:278499600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:294228000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:309949200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:325677600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:341398800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:357127200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:372848400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:388576800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:404902800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:420026400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:436352400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:452080800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:467802000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:483530400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:499251600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:514980000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:530701200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:544615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:562150800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:576064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:594205200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:607514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:625654800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:638964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:657104400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:671018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:688554000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:702468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:720003600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:733917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:752058000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:765367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:783507600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:796816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:814957200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:828871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:846406800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:860320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:877856400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:891770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:909306000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:923220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:941360400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:954669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:972810000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:986119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1004259600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1018173600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1035709200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1049623200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1067158800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1081072800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1099213200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1112522400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1130662800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1143972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1162112400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1173607200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1194166800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1205056800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1225616400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1236506400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1257066000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1268560800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1289120400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1300010400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1320570000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1331460000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1352019600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1362909600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1383469200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1394359200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1414918800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1425808800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1446368400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1457863200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1478422800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1489312800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1509872400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1520762400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1541322000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1552212000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1572771600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1583661600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1604221200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1615716000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1636275600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1647165600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1667725200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1678615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1699174800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1710064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1730624400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1741514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1762074000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1772964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1793523600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1805018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1825578000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1836468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1857027600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1867917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1888477200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1899367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1919926800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1930816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1951376400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1962871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1983430800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1994320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2014880400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2025770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2046330000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2057220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2077779600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2088669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2109229200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2120119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2140678800, index:0x2, isstd:false, isutc:false}}, extend:"PST8PDT,M3.2.0,M11.1.0"} } ================================================ FILE: 1.25_linux/time/sleep_test.go.patch ================================================ //--from func TestSleep(t *testing.T) { //--to func TestSleep(t *testing.T) { t.Skip("Interrupt (syscall.Kill) is not supported in this environment") //--from func TestIssue5745(t *testing.T) { //--to func TestIssue5745(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.25_linux/time/time_test.go.patch ================================================ //--from func TestLoadFixed(t *testing.T) { //--to func TestLoadFixed(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestTimeIsDST(t *testing.T) { //--to func TestTimeIsDST(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestTimeWithZoneTransition(t *testing.T) { //--to func TestTimeWithZoneTransition(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestMarshalBinaryVersion2(t *testing.T) { //--to func TestMarshalBinaryVersion2(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.25_linux/time/tzdata_test.go.patch ================================================ //--from func TestEmbeddedTZData(t *testing.T) { //--to func TestEmbeddedTZData(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.25_linux/time/zoneinfo_test.go.patch ================================================ //--from func TestEnvVarUsage(t *testing.T) { //--to func TestEnvVarUsage(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestBadLocationErrMsg(t *testing.T) { //--to func TestBadLocationErrMsg(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestVersion3(t *testing.T) { //--to func TestVersion3(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestFirstZone(t *testing.T) { //--to func TestFirstZone(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationFromTZData(t *testing.T) { //--to func TestLoadLocationFromTZData(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestEarlyLocation(t *testing.T) { //--to func TestEarlyLocation(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationFromTZDataSlim(t *testing.T) { //--to func TestLoadLocationFromTZDataSlim(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.25_linux/time/zoneinfo_unix.go.patch ================================================ //--from import ( "syscall" ) //--to //--from func initLocal() { // consult $TZ to find the time zone to use. // no $TZ means use the system default /etc/localtime. // $TZ="" means use UTC. // $TZ="foo" or $TZ=":foo" if foo is an absolute path, then the file pointed // by foo will be used to initialize timezone; otherwise, file // /usr/share/zoneinfo/foo will be used. tz, ok := syscall.Getenv("TZ") switch { case !ok: z, err := loadLocation("localtime", []string{"/etc"}) if err == nil { localLoc = *z localLoc.name = "Local" return } case tz != "": if tz[0] == ':' { tz = tz[1:] } if tz != "" && tz[0] == '/' { if z, err := loadLocation(tz, []string{""}); err == nil { localLoc = *z if tz == "/etc/localtime" { localLoc.name = "Local" } else { localLoc.name = tz } return } } else if tz != "" && tz != "UTC" { if z, err := loadLocation(tz, platformZoneSources); err == nil { localLoc = *z return } } } // Fall back to UTC. localLoc.name = "UTC" } //--to func initLocal() { localLoc.name = "UTC" } ================================================ FILE: 1.25_linux/time/zoneinfo_unix_test.go.patch ================================================ //--from func TestEnvTZUsage(t *testing.T) { //--to func TestEnvTZUsage(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.25_windows/internal/testenv/exec.go.patch ================================================ //--from var tryExec = sync.OnceValue(func() error { //--to var tryExec = sync.OnceValue(func() error { return fmt.Errorf("can't probe for exec support") ================================================ FILE: 1.25_windows/internal/testenv/testenv.go.patch ================================================ //--from func HasGoBuild() bool { //--to func HasGoBuild() bool { return false ================================================ FILE: 1.25_windows/runtime/cgo/gcc_windows_amd64.c.patch ================================================ //--from static unsigned long __stdcall threadentry(void *v) { ThreadStart ts; //--to static int getproccount() { static int proccount = 0; if (!proccount) { SYSTEM_INFO info; GetSystemInfo(&info); proccount = info.dwNumberOfProcessors; } return proccount; } static unsigned long __stdcall threadentry(void *v) { ThreadStart ts; SetThreadAffinityMask(GetCurrentThread(), (1< //--to //--append #define fprintf dummy_fprintf // TODO: Use OutputDebugMessage. #define dummy_fprintf(stream, format, ...) ================================================ FILE: 1.25_windows/runtime/os_windows.go.patch ================================================ //--from //go:cgo_import_dynamic runtime._GetConsoleMode GetConsoleMode%2 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._SetConsoleCtrlHandler SetConsoleCtrlHandler%2 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._WerGetFlags WerGetFlags%2 "kernel32.dll" //go:cgo_import_dynamic runtime._WerSetFlags WerSetFlags%1 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._WriteConsoleW WriteConsoleW%5 "kernel32.dll" //--to //go:cgo_import_dynamic runtime._OutputDebugStringW OutputDebugStringW%1 "kernel32.dll" //--from _GetConsoleMode, //--to //--from _SetConsoleCtrlHandler, //--to //--from _WerGetFlags, _WerSetFlags, //--to //--from _WriteConsoleW, //--to _OutputDebugStringW, //--from // We call these all the way here, late in init, so that malloc works // for the callback functions these generate. var fn any = ctrlHandler ctrlHandlerPC := compileCallback(*efaceOf(&fn), true) stdcall2(_SetConsoleCtrlHandler, ctrlHandlerPC, 1) //--to //--from func write1(fd uintptr, buf unsafe.Pointer, n int32) int32 { const ( _STD_OUTPUT_HANDLE = ^uintptr(10) // -11 _STD_ERROR_HANDLE = ^uintptr(11) // -12 ) var handle uintptr switch fd { case 1: handle = stdcall1(_GetStdHandle, _STD_OUTPUT_HANDLE) case 2: handle = stdcall1(_GetStdHandle, _STD_ERROR_HANDLE) default: // assume fd is real windows handle. handle = fd } isASCII := true b := (*[1 << 30]byte)(buf)[:n] for _, x := range b { if x >= 0x80 { isASCII = false break } } if !isASCII { var m uint32 isConsole := stdcall2(_GetConsoleMode, handle, uintptr(unsafe.Pointer(&m))) != 0 // If this is a console output, various non-unicode code pages can be in use. // Use the dedicated WriteConsole call to ensure unicode is printed correctly. if isConsole { return int32(writeConsole(handle, buf, n)) } } var written uint32 stdcall5(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--to func write1(fd uintptr, buf unsafe.Pointer, n int32) int32 { const ( _STD_OUTPUT_HANDLE = ^uintptr(10) // -11 _STD_ERROR_HANDLE = ^uintptr(11) // -12 ) var handle uintptr switch fd { case 1: handle = stdcall1(_GetStdHandle, _STD_OUTPUT_HANDLE) case 2: handle = stdcall1(_GetStdHandle, _STD_ERROR_HANDLE) default: // assume fd is real windows handle. handle = fd } if fd == 1 || fd == 2 { // Note that handle is not used anyway. return int32(writeConsole(handle, buf, n)) } var written uint32 stdcall5(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--from func writeConsoleUTF16(handle uintptr, b []uint16) { l := uint32(len(b)) if l == 0 { return } var written uint32 stdcall5(_WriteConsoleW, handle, uintptr(unsafe.Pointer(&b[0])), uintptr(l), uintptr(unsafe.Pointer(&written)), 0, ) return } //--to func writeConsoleUTF16(handle uintptr, b []uint16) { b = b[:len(b)+1] b[len(b)-1] = 0 l := uint32(len(b)) if l <= 1 { return } stdcall1(_OutputDebugStringW, uintptr(unsafe.Pointer(&b[0])), ) return } ================================================ FILE: 1.25_windows/runtime/signal_windows.go.patch ================================================ //--from func preventErrorDialogs() { errormode := stdcall0(_GetErrorMode) stdcall1(_SetErrorMode, errormode|_SEM_FAILCRITICALERRORS|_SEM_NOGPFAULTERRORBOX|_SEM_NOOPENFILEERRORBOX) // Disable WER fault reporting UI. // Do this even if WER is disabled as a whole, // as WER might be enabled later with setTraceback("wer") // and we still want the fault reporting UI to be disabled if this happens. var werflags uintptr stdcall2(_WerGetFlags, currentProcess, uintptr(unsafe.Pointer(&werflags))) stdcall1(_WerSetFlags, werflags|_WER_FAULT_REPORTING_NO_UI) } //--to func preventErrorDialogs() { errormode := stdcall0(_GetErrorMode) stdcall1(_SetErrorMode, errormode|_SEM_FAILCRITICALERRORS|_SEM_NOGPFAULTERRORBOX|_SEM_NOOPENFILEERRORBOX) } ================================================ FILE: 1.25_windows/runtime/syscall_windows.go.patch ================================================ //--from func syscall_SyscallN(fn uintptr, args ...uintptr) (r1, r2, err uintptr) { //--to func syscall_SyscallN(fn uintptr, args ...uintptr) (r1, r2, err uintptr) { if fn == 0 { panic("fn must not be 0 at SyscallN") } ================================================ FILE: 1.25_windows/runtime/syscall_windows_test.go.patch ================================================ //--from func TestNumCPU(t *testing.T) { //--to func TestNumCPU(t *testing.T) { t.Skip("creating a new process with os.Args[0] doesn't work in this environment") ================================================ FILE: 1.26_linux/internal/reflectlite/reflect_mirror_test.go.patch ================================================ //--from func TestMirrorWithReflect(t *testing.T) { //--to func TestMirrorWithReflect(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.26_linux/internal/runtime/cgroup/cgroup_linux.go.patch ================================================ //--from func FindCPUCgroup(out []byte, scratch []byte) (int, Version, error) { //--to func FindCPUCgroup(out []byte, scratch []byte) (int, Version, error) { return 0, 0, ErrNoCgroup //--from func FindCPUMountPoint(out, cgroup []byte, version Version, scratch []byte) (int, error) { //--to func FindCPUMountPoint(out, cgroup []byte, version Version, scratch []byte) (int, error) { return 0, ErrNoCgroup ================================================ FILE: 1.26_linux/internal/runtime/syscall/linux/asm_linux_amd64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0 // a6 already in R9. // a5 already in R8. MOVQ SI, R10 // a4 MOVQ DI, DX // a3 MOVQ CX, SI // a2 MOVQ BX, DI // a1 // num already in AX. SYSCALL CMPQ AX, $0xfffffffffffff001 JLS ok NEGQ AX MOVQ AX, CX // errno MOVQ $-1, AX // r1 MOVQ $0, BX // r2 RET ok: // r1 already in AX. MOVQ DX, BX // r2 MOVQ $0, CX // errno RET //--to ================================================ FILE: 1.26_linux/internal/runtime/syscall/linux/asm_linux_arm64.s.patch ================================================ //--from TEXT ·Syscall6(SB),NOSPLIT,$0-80 MOVD num+0(FP), R8 // syscall entry MOVD a1+8(FP), R0 MOVD a2+16(FP), R1 MOVD a3+24(FP), R2 MOVD a4+32(FP), R3 MOVD a5+40(FP), R4 MOVD a6+48(FP), R5 SVC CMN $4095, R0 BCC ok MOVD $-1, R4 MOVD R4, r1+56(FP) MOVD ZR, r2+64(FP) NEG R0, R0 MOVD R0, errno+72(FP) RET ok: MOVD R0, r1+56(FP) MOVD R1, r2+64(FP) MOVD ZR, errno+72(FP) RET //--to ================================================ FILE: 1.26_linux/internal/runtime/syscall/linux/syscall_linux.go.patch ================================================ //--from func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) //--to func Syscall6(num, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, errno uintptr) { println("not implemented syscall at Syscall6", num) panic("syscall.Syscall6") return 0, 0, 0x26 // ENOSYS } ================================================ FILE: 1.26_linux/internal/runtime/syscall/linux/syscall_linux_test.go.patch ================================================ //--from import ( "internal/runtime/syscall/linux" "testing" ) //--to import ( "testing" ) //--from func TestEpollctlErrorSign(t *testing.T) { v := linux.EpollCtl(-1, 1, -1, &linux.EpollEvent{}) const EBADF = 0x09 if v != EBADF { t.Errorf("epollctl = %v, want %v", v, EBADF) } } //--to func TestEpollctlErrorSign(t *testing.T) { t.Skip("Epollctl is not supported in this environment") } ================================================ FILE: 1.26_linux/internal/strconv/fp_test.go.patch ================================================ //--from func TestFp(t *testing.T) { //--to func TestFp(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.26_linux/internal/syscall/unix/fcntl_unix.go.patch ================================================ //--from func Fcntl(fd int, cmd int, arg int) (int, error) { val, errno := fcntl(int32(fd), int32(cmd), int32(arg)) if val == -1 { return int(val), syscall.Errno(errno) } return int(val), nil } //--to func Fcntl(fd int, cmd int, arg int) (int, error) { return 0, syscall.ENOSYS } ================================================ FILE: 1.26_linux/internal/testenv/exec.go.patch ================================================ //--from var tryExec = sync.OnceValue(func() error { //--to var tryExec = sync.OnceValue(func() error { return fmt.Errorf("can't probe for exec support") ================================================ FILE: 1.26_linux/internal/testenv/testenv.go.patch ================================================ //--from func HasGoBuild() bool { //--to func HasGoBuild() bool { return false ================================================ FILE: 1.26_linux/internal/testenv/testenv_notunix.go.patch ================================================ //--from //go:build windows || plan9 || (js && wasm) || wasip1 //--to //go:build windows || plan9 || (js && wasm) || wasip1 || linux ================================================ FILE: 1.26_linux/internal/testenv/testenv_unix.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.26_linux/math/big/link_test.go.patch ================================================ //--from func TestLinkerGC(t *testing.T) { //--to func TestLinkerGC(t *testing.T) { t.Skip("go tools are not supported in this environment") ================================================ FILE: 1.26_linux/math/rand/default_test.go.patch ================================================ //--from func TestDefaultRace(t *testing.T) { //--to func TestDefaultRace(t *testing.T) { t.Skip("os.Getenv and creating processes are not supported in this environment") ================================================ FILE: 1.26_linux/runtime/align_test.go.patch ================================================ //--from func TestAtomicAlignment(t *testing.T) { //--to func TestAtomicAlignment(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.26_linux/runtime/asm_arm64.s.patch ================================================ //--from TEXT runtime·procyieldAsm(SB),NOSPLIT,$0-0 MOVWU cycles+0(FP), R0 CBZ R0, done //Prevent speculation of subsequent counter/timer reads and memory accesses. ISB $15 // If the delay is very short, just return. // Hardcode 18ns as the first ISB delay. CMP $18, R0 BLS done // Adjust for overhead of initial ISB. SUB $18, R0, R0 // Convert the delay from nanoseconds to counter/timer ticks. // Read the counter/timer frequency. // delay_ticks = (delay * CNTFRQ_EL0) / 1e9 // With the below simplifications and adjustments, // we are usually within 2% of the correct value: // delay_ticks = (delay + delay / 16) * CNTFRQ_EL0 >> 30 MRS CNTFRQ_EL0, R1 ADD R0>>4, R0, R0 MUL R1, R0, R0 LSR $30, R0, R0 CBZ R0, done // start = current counter/timer value MRS CNTVCT_EL0, R2 delay: // Delay using ISB for all ticks. ISB $15 // Substract and compare to handle counter roll-over. // counter_read() - start < delay_ticks MRS CNTVCT_EL0, R1 SUB R2, R1, R1 CMP R0, R1 BCC delay done: RET //--to TEXT runtime·procyieldAsm(SB),NOSPLIT,$0-0 MOVWU cycles+0(FP), R0 CBZ R0, done again: YIELD SUBW $1, R0 CBNZ R0, again done: RET ================================================ FILE: 1.26_linux/runtime/callers_test.go.patch ================================================ //--from func TestCallersNilPointerPanic(t *testing.T) { //--to func TestCallersNilPointerPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestCallersDeferNilFuncPanic(t *testing.T) { //--to func TestCallersDeferNilFuncPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { //--to func TestCallersDeferNilFuncPanicWithLoop(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.26_linux/runtime/cgo/cgo.go.patch ================================================ //--from */ import "C" //--to #cgo !darwin LDFLAGS: -Wl,-unresolved-symbols=ignore-all #cgo darwin LDFLAGS: -Wl,-undefined,dynamic_lookup */ import "C" ================================================ FILE: 1.26_linux/runtime/cgo/gcc_clearenv.c.patch ================================================ //--from void x_cgo_clearenv(void **_unused) { _cgo_tsan_acquire(); clearenv(); _cgo_tsan_release(); } //--to void x_cgo_clearenv(void **_unused) { } ================================================ FILE: 1.26_linux/runtime/cgo/gcc_linux_amd64.c.patch ================================================ //--from #include #include #include // strerror #include #include #include "libcgo.h" #include "libcgo_unix.h" //--to #include #include #include // strerror #include #include "libcgo.h" #include "libcgo_unix.h" //--from void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--to void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; pthread_t p; size_t size; int err; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--from static void* threadentry(void *v) { ThreadStart ts; //--to static void* threadentry(void *v) { ThreadStart ts; extern void hitsumabushi_initializeThread(void); hitsumabushi_initializeThread(); ================================================ FILE: 1.26_linux/runtime/cgo/gcc_linux_arm64.c.patch ================================================ //--from void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--to void _cgo_sys_thread_start(ThreadStart *ts) { pthread_attr_t attr; sigset_t ign, oset; pthread_t p; size_t size; int err; sigfillset(&ign); pthread_sigmask(SIG_SETMASK, &ign, &oset); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); pthread_attr_setstacksize(&attr, 16 * 4096); // Hack for some special environments pthread_attr_getstacksize(&attr, &size); // Leave stacklo=0 and set stackhi=size; mstart will do the rest. ts->g->stackhi = size; err = _cgo_try_pthread_create(&p, &attr, threadentry, ts); pthread_sigmask(SIG_SETMASK, &oset, nil); if (err != 0) { fatalf("pthread_create failed: %s", strerror(err)); } } //--from static void* threadentry(void *v) { ThreadStart ts; //--to static void* threadentry(void *v) { ThreadStart ts; // Note that threadentry will also be defined in gcc_linux.go in Go 1.22. extern void hitsumabushi_initializeThread(void); hitsumabushi_initializeThread(); ================================================ FILE: 1.26_linux/runtime/cgo/gcc_setenv.c.patch ================================================ //--from void x_cgo_setenv(char **arg) { _cgo_tsan_acquire(); setenv(arg[0], arg[1], 1); _cgo_tsan_release(); } //--to void x_cgo_setenv(char **arg) { } //--from void x_cgo_unsetenv(char **arg) { _cgo_tsan_acquire(); unsetenv(arg[0]); _cgo_tsan_release(); } //--to void x_cgo_unsetenv(char **arg) { } ================================================ FILE: 1.26_linux/runtime/cgo/gcc_sigaction.c.patch ================================================ //--from //go:build linux && (386 || amd64 || arm64 || loong64 || ppc64le) //--to //go:build linux && (386 || arm64 || loong64 || ppc64le) ================================================ FILE: 1.26_linux/runtime/cgo/hitsumabushi_clock_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp) { return clock_gettime(clk_id, tp); } ================================================ FILE: 1.26_linux/runtime/cgo/hitsumabushi_cpu_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include int32_t hitsumabushi_getproccount() { return 1; } ================================================ FILE: 1.26_linux/runtime/cgo/hitsumabushi_filesystem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include #include #include "libcgo.h" #include "libcgo_unix.h" static const int kFDOffset = 100; typedef struct { const void* content; size_t content_size; size_t current; int32_t fd; } pseudo_file; // TODO: Do we need to protect this by mutex? static pseudo_file pseudo_files[100]; static pthread_mutex_t* pseudo_file_mutex() { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; return &mutex; } static int32_t open_pseudo_file(const void* content, size_t content_size) { int index = 0; int found = 0; int32_t fd = 0; pthread_mutex_lock(pseudo_file_mutex()); for (int i = 0; i < sizeof(pseudo_files) / sizeof(pseudo_file); i++) { if (pseudo_files[i].fd == 0) { index = i; found = 1; break; } } if (!found) { // Too many pseudo files are opened. pthread_mutex_unlock(pseudo_file_mutex()); return -1; } fd = index + kFDOffset; pseudo_files[index].content = content; pseudo_files[index].content_size = content_size; pseudo_files[index].current = 0; pseudo_files[index].fd = fd; pthread_mutex_unlock(pseudo_file_mutex()); return fd; } static size_t read_pseudo_file(int32_t fd, void *p, int32_t n) { int32_t index = fd - kFDOffset; pseudo_file *file = NULL; size_t rest = 0; pthread_mutex_lock(pseudo_file_mutex()); file = &pseudo_files[index]; rest = file->content_size - file->current; if (rest < n) { n = rest; } memcpy(p, file->content + file->current, n); pseudo_files[index].current += n; pthread_mutex_unlock(pseudo_file_mutex()); return n; } static void close_pseudo_file(int32_t fd) { int32_t index = fd - kFDOffset; pthread_mutex_lock(pseudo_file_mutex()); pseudo_files[index].content = NULL; pseudo_files[index].content_size = 0; pseudo_files[index].current = 0; pseudo_files[index].fd = 0; pthread_mutex_unlock(pseudo_file_mutex()); } int32_t hitsumabushi_closefd(int32_t fd) { if (fd >= kFDOffset) { close_pseudo_file(fd); return 0; } fprintf(stderr, "syscall close(%d) is not implemented\n", fd); return 0; } int32_t hitsumabushi_open(char *name, int32_t mode, int32_t perm) { const static int kENOENT = 0x2; if (strcmp(name, "/proc/self/auxv") == 0) { static const char auxv[] = "\x06\x00\x00\x00\x00\x00\x00\x00" // _AT_PAGESZ tag (6) "\x00\x10\x00\x00\x00\x00\x00\x00" // 4096 bytes per page "\x00\x00\x00\x00\x00\x00\x00\x00" // Dummy bytes "\x00\x00\x00\x00\x00\x00\x00\x00"; // Dummy bytes return open_pseudo_file(auxv, sizeof(auxv) / sizeof(char)); } if (strcmp(name, "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size") == 0) { static const char hpage_pmd_size[] = "\x30\x5c"; // '0', '\n' return open_pseudo_file(hpage_pmd_size, sizeof(hpage_pmd_size) / sizeof(char)); } fprintf(stderr, "syscall open(%s, %d, %d) is not implemented\n", name, mode, perm); return kENOENT; } int32_t hitsumabushi_read(int32_t fd, void *p, int32_t n) { const static int kEBADF = 0x9; if (fd >= kFDOffset) { return read_pseudo_file(fd, p, n); } fprintf(stderr, "syscall read(%d, %p, %d) is not implemented\n", fd, p, n); return kEBADF; } int32_t hitsumabushi_write1(uintptr_t fd, void *p, int32_t n) { static pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER; int32_t ret = 0; pthread_mutex_lock(&m); switch (fd) { case 1: ret = fwrite(p, 1, n, stdout); fflush(stdout); break; case 2: ret = fwrite(p, 1, n, stderr); fflush(stderr); break; default: fprintf(stderr, "syscall write(%lu, %p, %d) is not implemented\n", fd, p, n); ret = -EBADF; break; } pthread_mutex_unlock(&m); return ret; } int32_t hitsumabushi_lseek(uintptr_t fd, off_t offset, int32_t whence) { fprintf(stderr, "syscall lseek(%lu, %lu, %d) is not implemented\n", fd, offset, whence); return -ENOSYS; } int32_t hitsumabushi_fcntl(int32_t fd, int32_t cmd, int32_t arg) { if (fd == 0 || fd == 1 || fd == 2) { if (cmd == F_GETFL) { return 0; } } fprintf(stderr, "syscall fcntl(%d, %d, %d) is not implemented\n", fd, cmd, arg); return -EBADF; } int32_t hitsumabushi_fstat(int32_t fd, struct stat *stat) { fprintf(stderr, "syscall fstat(%d, %p) is not implemented\n", fd, stat); return -ENOSYS; } int32_t hitsumabushi_renameat(int32_t fd1, char* name1, int32_t fd2, char* name2) { fprintf(stderr, "syscall renameat(%d, %s, %d, %s) is not implemented\n", fd1, name1, fd2, name2); return -ENOSYS; } int32_t hitsumabushi_fstatat(int32_t fd, char* name, struct stat* p, int32_t flags) { fprintf(stderr, "syscall fstatat(%d, %s, %p, %d) is not implemented\n", fd, name, p, flags); return -ENOSYS; } ================================================ FILE: 1.26_linux/runtime/cgo/hitsumabushi_futex_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include #include #include #include static const int kPseudoFutexWait = 0; static const int kPseudoFutexWake = 1; static void pseudo_futex(uint32_t *uaddr, int mode, uint32_t val, const struct timespec *reltime) { static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_cond_t cond = PTHREAD_COND_INITIALIZER; int ret = 0; struct timespec abstime; if (reltime) { // We are not sure CLOCK_REALTIME is correct or not here. // However, this time limit is actually not used as the condition variable is shared by // all the threads. Before the time limit reaches, the thread wakes up in 99.9999...% cases. clock_gettime(CLOCK_REALTIME, &abstime); abstime.tv_sec += reltime->tv_sec; abstime.tv_nsec += reltime->tv_nsec; if (1000000000 <= abstime.tv_nsec) { abstime.tv_sec += 1; abstime.tv_nsec -= 1000000000; } } ret = pthread_mutex_lock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_lock failed: %d\n", ret); abort(); } switch (mode) { case kPseudoFutexWait: if (reltime) { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_timedwait(&cond, &mutex, &abstime); if (ret && ret != ETIMEDOUT) { fprintf(stderr, "pthread_cond_timedwait failed: %d\n", ret); abort(); } } } else { uint32_t v = 0; __atomic_load(uaddr, &v, __ATOMIC_RELAXED); if (v == val) { int ret = pthread_cond_wait(&cond, &mutex); if (ret) { fprintf(stderr, "pthread_cond_wait failed: %d\n", ret); abort(); } } } break; case kPseudoFutexWake: if (val != 1) { fprintf(stderr, "val for waking must be 1 but %d\n", val); abort(); } // TODO: broadcasting is not efficient. Use a mutex for each uaddr. ret = pthread_cond_broadcast(&cond); if (ret) { fprintf(stderr, "pthread_cond_broadcast failed: %d\n", ret); abort(); } break; } ret = pthread_mutex_unlock(&mutex); if (ret) { fprintf(stderr, "pthread_mutex_unlock failed: %d\n", ret); abort(); } } int32_t hitsumabushi_futex(uint32_t *uaddr, int32_t futex_op, uint32_t val, const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3) { enum { kFutexWaitPrivate = 128, kFutexWakePrivate = 129, }; switch (futex_op) { case kFutexWaitPrivate: pseudo_futex(uaddr, kPseudoFutexWait, val, timeout); break; case kFutexWakePrivate: pseudo_futex(uaddr, kPseudoFutexWake, val, NULL); break; } // This function should return the number of awaken threads, but now it is impossible. // Just return 0. return 0; } ================================================ FILE: 1.26_linux/runtime/cgo/hitsumabushi_mem_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors #include #include void* hitsumabushi_sysReserveOS(void* v, uintptr_t n); void* hitsumabushi_sysAllocOS(uintptr_t n) { return hitsumabushi_sysReserveOS(NULL, n); } void hitsumabushi_sysUnusedOS(void* v, uintptr_t n) { } void hitsumabushi_sysUsedOS(void* v, uintptr_t n) { } void hitsumabushi_sysHugePageOS(void* v, uintptr_t n) { } void hitsumabushi_sysFreeOS(void* v, uintptr_t n) { } void hitsumabushi_sysFaultOS(void* v, uintptr_t n) { } void* hitsumabushi_sysReserveOS(void* v, uintptr_t n) { if (v) { return NULL; } // The returned pointer must be aligned to 1 << 9 bytes. // See also: // * https://cs.opensource.google/go/go/+/refs/tags/go1.25.0:src/runtime/tagptr_64bit.go // * https://go.dev/cl/665815/ return aligned_alloc(1 << 9, n); } void hitsumabushi_sysMapOS(void* v, uintptr_t n) { } ================================================ FILE: 1.26_linux/runtime/cgo/hitsumabushi_syscalls_linux.c ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors // This file defines C functions and system calls for Cgo. #include #include #include #include #include #include // for usleep #include // for size_t #include "libcgo.h" #include "libcgo_unix.h" typedef unsigned int gid_t; extern int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp); extern int32_t hitsumabushi_getproccount(); void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { abort(); return NULL; } int munmap(void *addr, size_t length) { abort(); return 0; } int pthread_sigmask(int how, void *set, void *oldset) { // Do nothing. return 0; } int setegid(gid_t gid) { // Do nothing. return 0; } int seteuid(uid_t gid) { // Do nothing. return 0; } int setgid(gid_t gid) { // Do nothing. return 0; } int setgroups(size_t size, const gid_t *list) { // Do nothing. return 0; } int setregid(gid_t rgid, gid_t egid) { // Do nothing. return 0; } int setreuid(uid_t ruid, uid_t euid) { // Do nothing. return 0; } int setresgid(gid_t rgid, gid_t egid, gid_t sgid) { // Do nothing. return 0; } int setresuid(uid_t ruid, uid_t euid, uid_t suid) { // Do nothing. return 0; } int setuid(uid_t gid) { // Do nothing. return 0; } int sigaction(int signum, void *act, void *oldact) { // Do nothing. return 0; } int sigaddset(void *set, int signum) { // Do nothing. return 0; } int sigemptyset(void *set) { // Do nothing. return 0; } int sigfillset(void *set) { // Do nothing. return 0; } int sigismember(void *set, int signum) { // Do nothing. return 0; } uint32_t hitsumabushi_gettid() { uint64_t tid64 = (uint64_t)(pthread_self()); uint32_t tid = (uint32_t)(tid64 >> 32) ^ (uint32_t)(tid64); return tid; } int64_t hitsumabushi_nanotime1() { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_MONOTONIC, &tp); return (int64_t)(tp.tv_sec) * 1000000000ll + (int64_t)tp.tv_nsec; } int32_t hitsumabushi_osyield() { return sched_yield(); } int32_t hitsumabushi_sched_getaffinity(pid_t pid, size_t cpusetsize, void *mask) { int32_t numcpu = hitsumabushi_getproccount(); for (int32_t i = 0; i < numcpu; i += 8) ((unsigned char*)mask)[i / 8] = (unsigned char)((1u << (numcpu - i)) - 1); // https://man7.org/linux/man-pages/man2/sched_setaffinity.2.html // > On success, the raw sched_getaffinity() system call returns the // > number of bytes placed copied into the mask buffer; return (numcpu + 7) / 8; } void hitsumabushi_usleep(useconds_t usec) { usleep(usec); } void hitsumabushi_walltime1(int64_t* sec, int32_t* nsec) { struct timespec tp; hitsumabushi_clock_gettime(CLOCK_REALTIME, &tp); *sec = tp.tv_sec; *nsec = tp.tv_nsec; } void hitsumabushi_exit(int32_t code) { exit(code); } ================================================ FILE: 1.26_linux/runtime/cgo/hitsumabushi_thread_linux.c ================================================ void hitsumabushi_initializeThread(void) { } ================================================ FILE: 1.26_linux/runtime/cgo/linux_syscall.c.patch ================================================ //--from #include #include #include #include #include "libcgo.h" //--to #include #include #include #include "libcgo.h" //--from void _cgo_libc_setegid(argset_t* x) { SET_RETVAL(setegid((gid_t) x->args[0])); } //--to void _cgo_libc_setegid(argset_t* x) { } //--from void _cgo_libc_seteuid(argset_t* x) { SET_RETVAL(seteuid((uid_t) x->args[0])); } //--to void _cgo_libc_seteuid(argset_t* x) { } //--from void _cgo_libc_setgid(argset_t* x) { SET_RETVAL(setgid((gid_t) x->args[0])); } //--to void _cgo_libc_setgid(argset_t* x) { } //--from void _cgo_libc_setgroups(argset_t* x) { SET_RETVAL(setgroups((size_t) x->args[0], (const gid_t *) x->args[1])); } //--to void _cgo_libc_setgroups(argset_t* x) { } //--from void _cgo_libc_setregid(argset_t* x) { SET_RETVAL(setregid((gid_t) x->args[0], (gid_t) x->args[1])); } //--to void _cgo_libc_setregid(argset_t* x) { } //--from void _cgo_libc_setresgid(argset_t* x) { SET_RETVAL(setresgid((gid_t) x->args[0], (gid_t) x->args[1], (gid_t) x->args[2])); } //--to void _cgo_libc_setresgid(argset_t* x) { } //--from void _cgo_libc_setreuid(argset_t* x) { SET_RETVAL(setreuid((uid_t) x->args[0], (uid_t) x->args[1])); } //--to void _cgo_libc_setreuid(argset_t* x) { } //--from void _cgo_libc_setuid(argset_t* x) { SET_RETVAL(setuid((uid_t) x->args[0])); } //--to void _cgo_libc_setuid(argset_t* x) { } ================================================ FILE: 1.26_linux/runtime/cgo/sigaction.go.patch ================================================ //--from //go:build (linux && (386 || amd64 || arm64 || loong64 || ppc64le)) || (freebsd && amd64) //--to //go:build (linux && (386 || arm64 || loong64 || ppc64le)) || (freebsd && amd64) ================================================ FILE: 1.26_linux/runtime/crash_test.go.patch ================================================ //--from func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { //--to func buildTestProg(t *testing.T, binary string, flags ...string) (string, error) { t.Skip("buildTestProg is not supported in this environment") //--from func TestPanicInlined(t *testing.T) { //--to func TestPanicInlined(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.26_linux/runtime/crash_unix_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.26_linux/runtime/debug/heapdump_test.go.patch ================================================ //--from func TestWriteHeapDumpNonempty(t *testing.T) { //--to func TestWriteHeapDumpNonempty(t *testing.T) { t.Skip("file is not supported in this environment") //--from func TestWriteHeapDumpFinalizers(t *testing.T) { //--to func TestWriteHeapDumpFinalizers(t *testing.T) { t.Skip("file is not supported in this environment") //--from func TestWriteHeapDumpTypeName(t *testing.T) { //--to func TestWriteHeapDumpTypeName(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.26_linux/runtime/debug/panic_test.go.patch ================================================ //--from func TestPanicOnFault(t *testing.T) { //--to func TestPanicOnFault(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.26_linux/runtime/debug/stack_test.go.patch ================================================ //--from func TestSetCrashOutput(t *testing.T) { //--to func TestSetCrashOutput(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.26_linux/runtime/debug_test.go.patch ================================================ //--from //go:build (amd64 || arm64 || loong64 || ppc64le) && linux && !race //--to //go:build ignore ================================================ FILE: 1.26_linux/runtime/decoratemappings_test.go.patch ================================================ //--from func TestDecorateMappings(t *testing.T) { //--to func TestDecorateMappings(t *testing.T) { t.Skip("files are not supported in this environment") ================================================ FILE: 1.26_linux/runtime/export_unix_test.go ================================================ // Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build unix package runtime const ( O_WRONLY = _O_WRONLY O_CREAT = _O_CREAT O_TRUNC = _O_TRUNC ) ================================================ FILE: 1.26_linux/runtime/fds_unix.go.patch ================================================ //--from func checkfds() { //--to func checkfds() { return ================================================ FILE: 1.26_linux/runtime/mem_linux.go ================================================ // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This implementation is the most fundamental and minimal allocations like Wasm. // Malloced memory regions are never freed. package runtime import ( "internal/abi" "unsafe" ) const ( _EINVAL = 22 ) // Don't split the stack as this method may be invoked without a valid G, which // prevents us from allocating more stack. // //go:nosplit func sysAllocOS(n uintptr, vmaName string) (ptr unsafe.Pointer) { return sysAllocOSImpl(n) } //go:nosplit //go:cgo_unsafe_args func sysAllocOSImpl(n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysAllocOS_trampoline)), unsafe.Pointer(&n)) return } func sysAllocOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit //go:cgo_unsafe_args func sysUnusedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUnusedOS_trampoline)), unsafe.Pointer(&v)) } func sysUnusedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysUsedOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysUsedOS_trampoline)), unsafe.Pointer(&v)) } func sysUsedOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysHugePageOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysHugePageOS_trampoline)), unsafe.Pointer(&v)) } func sysHugePageOS_trampoline(n uintptr, size uintptr) func sysNoHugePageOS(v unsafe.Pointer, n uintptr) { } func sysHugePageCollapseOS(v unsafe.Pointer, n uintptr) { } // Don't split the stack as this function may be invoked without a valid G, // which prevents us from allocating more stack. // //go:nosplit //go:cgo_unsafe_args func sysFreeOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFreeOS_trampoline)), unsafe.Pointer(&v)) } func sysFreeOS_trampoline(n uintptr, size uintptr) //go:nosplit //go:cgo_unsafe_args func sysFaultOS(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysFaultOS_trampoline)), unsafe.Pointer(&v)) } func sysFaultOS_trampoline(n uintptr, size uintptr) //go:nosplit func sysReserveOS(v unsafe.Pointer, n uintptr, vmaName string) (ptr unsafe.Pointer) { return sysReserveOSImpl(v, n) } //go:nosplit //go:cgo_unsafe_args func sysReserveOSImpl(v unsafe.Pointer, n uintptr) (ptr unsafe.Pointer) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysReserveOS_trampoline)), unsafe.Pointer(&v)) return } func sysReserveOS_trampoline(n uintptr, size uintptr) uintptr //go:nosplit func sysMapOS(v unsafe.Pointer, n uintptr, vmaName string) { sysMapOSImpl(v, n) } //go:nosplit //go:cgo_unsafe_args func sysMapOSImpl(v unsafe.Pointer, n uintptr) { libcCall(unsafe.Pointer(abi.FuncPCABI0(sysMapOS_trampoline)), unsafe.Pointer(&v)) } func sysMapOS_trampoline(n uintptr, size uintptr) func needZeroAfterSysUnusedOS() bool { return true } ================================================ FILE: 1.26_linux/runtime/memmove_linux_amd64_test.go.patch ================================================ //--from func TestMemmoveOverflow(t *testing.T) { //--to func TestMemmoveOverflow(t *testing.T) { t.Skip("file is not supported in this environment") ================================================ FILE: 1.26_linux/runtime/metrics_test.go.patch ================================================ //--from name: "runtime/debug.WriteHeapDump", fn: func(t *testing.T) { //--to name: "runtime/debug.WriteHeapDump", fn: func(t *testing.T) { t.Skip("debug.WriteHeapDump is not supported in this environment") ================================================ FILE: 1.26_linux/runtime/nbpipe_pipe2.go.patch ================================================ //--from //go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris //--to //go:build dragonfly || freebsd || netbsd || openbsd || solaris ================================================ FILE: 1.26_linux/runtime/nbpipe_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.26_linux/runtime/netpoll_epoll.go.patch ================================================ //--from //go:build linux //--to //go:build ignore ================================================ FILE: 1.26_linux/runtime/netpoll_fake.go.patch ================================================ //--from //go:build js && wasm //--to //go:build linux ================================================ FILE: 1.26_linux/runtime/nosan_linux_test.go.patch ================================================ //--from func TestNewOSProc0(t *testing.T) { //--to func TestNewOSProc0(t *testing.T) { t.Skip("newosproc0 is not supported in this environment") ================================================ FILE: 1.26_linux/runtime/os_linux.go.patch ================================================ //--from import ( "internal/abi" "internal/goarch" "internal/runtime/atomic" "internal/runtime/syscall/linux" "internal/strconv" "unsafe" ) //--to import ( "internal/abi" "internal/runtime/atomic" "internal/runtime/syscall/linux" "internal/strconv" "unsafe" ) //--from func sysargs(argc int32, argv **byte) { n := argc + 1 // skip over argv, envp to get to auxv for argv_index(argv, n) != nil { n++ } // skip NULL separator n++ // now argv+n is auxv auxvp := (*[1 << 28]uintptr)(add(unsafe.Pointer(argv), uintptr(n)*goarch.PtrSize)) if pairs := sysauxv(auxvp[:]); pairs != 0 { auxv = auxvp[: pairs*2 : pairs*2] return } // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } n = read(fd, noescape(unsafe.Pointer(&auxvreadbuf[0])), int32(unsafe.Sizeof(auxvreadbuf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. auxvreadbuf[len(auxvreadbuf)-2] = _AT_NULL pairs := sysauxv(auxvreadbuf[:]) auxv = auxvreadbuf[: pairs*2 : pairs*2] } //--to func sysargs(argc int32, argv **byte) { // argc/argv is not reliable on some machines. // Skip analysing them. // In some situations we don't get a loader-provided // auxv, such as when loaded as a library on Android. // Fall back to /proc/self/auxv. fd := open(&procAuxv[0], 0 /* O_RDONLY */, 0) if fd < 0 { // On Android, /proc/self/auxv might be unreadable (issue 9229), so we fallback to // try using mincore to detect the physical page size. // mincore should return EINVAL when address is not a multiple of system page size. const size = 256 << 10 // size of memory region to allocate p, err := mmap(nil, size, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_PRIVATE, -1, 0) if err != 0 { return } var n uintptr for n = 4 << 10; n < size; n <<= 1 { err := mincore(unsafe.Pointer(uintptr(p)+n), 1, &addrspace_vec[0]) if err == 0 { physPageSize = n break } } if physPageSize == 0 { physPageSize = size } munmap(p, size) return } n := read(fd, noescape(unsafe.Pointer(&auxvreadbuf[0])), int32(unsafe.Sizeof(auxvreadbuf))) closefd(fd) if n < 0 { return } // Make sure buf is terminated, even if we didn't read // the whole file. auxvreadbuf[len(auxvreadbuf)-2] = _AT_NULL pairs := sysauxv(auxvreadbuf[:]) auxv = auxvreadbuf[: pairs*2 : pairs*2] } //--from var urandom_dev = []byte("/dev/urandom\x00") func readRandom(r []byte) int { // Note that all supported Linux kernels should provide AT_RANDOM which // populates startupRand, so this fallback should be unreachable. fd := open(&urandom_dev[0], 0 /* O_RDONLY */, 0) n := read(fd, unsafe.Pointer(&r[0]), int32(len(r))) closefd(fd) return int(n) } //--to //go:nosplit func readRandom(r []byte) int { return 0 } //--from func gettid() uint32 //--to //go:nosplit //go:cgo_unsafe_args func gettid() (tid uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(gettid_trampoline)), unsafe.Pointer(&tid)) return } func gettid_trampoline() uint32 //--from //go:noescape func sigaltstack(new, old *stackt) //--to func sigaltstack(new, old *stackt) { // Do nothing. } //--from func sigprocmask(how int32, new, old *sigset) { rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--to func sigprocmask(how int32, new, old *sigset) { // Do nothing. // rtsigprocmask(how, new, old, int32(unsafe.Sizeof(*new))) } //--from func raise(sig uint32) //--to func raise(sig uint32) { // Do nothing } //--from func raiseproc(sig uint32) //--to func raiseproc(sig uint32) { // Do nothing } //--from //go:noescape func sched_getaffinity(pid, len uintptr, buf *byte) int32 //--to //go:nosplit //go:cgo_unsafe_args func sched_getaffinity(pid, len uintptr, buf *byte) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(sched_getaffinity_trampoline)), unsafe.Pointer(&pid)) } func sched_getaffinity_trampoline(pid, len uintptr, buf *byte) int32 //--from func osyield() //--to //go:nosplit //go:cgo_unsafe_args func osyield() { libcCall(unsafe.Pointer(abi.FuncPCABI0(osyield_trampoline)), nil) } func osyield_trampoline() //--from func sysSigaction(sig uint32, new, old *sigactiont) { //--to func sysSigaction(sig uint32, new, old *sigactiont) { // Do nothing. return //--from func signalM(mp *m, sig int) { tgkill(getpid(), int(mp.procid), sig) } //--to func signalM(mp *m, sig int) { // Do nothiing. } //--from func runPerThreadSyscall() { gp := getg() if gp.m.needPerThreadSyscall.Load() == 0 { return } args := perThreadSyscall r1, r2, errno := linux.Syscall6(args.trap, args.a1, args.a2, args.a3, args.a4, args.a5, args.a6) if GOARCH == "ppc64" || GOARCH == "ppc64le" { // TODO(https://go.dev/issue/51192 ): ppc64 doesn't use r2. r2 = 0 } if errno != 0 || r1 != args.r1 || r2 != args.r2 { print("trap:", args.trap, ", a123456=[", args.a1, ",", args.a2, ",", args.a3, ",", args.a4, ",", args.a5, ",", args.a6, "]\n") print("results: got {r1=", r1, ",r2=", r2, ",errno=", errno, "}, want {r1=", args.r1, ",r2=", args.r2, ",errno=0}\n") fatal("AllThreadsSyscall6 results differ between threads; runtime corrupted") } gp.m.needPerThreadSyscall.Store(0) } //--to func runPerThreadSyscall() { // Do nothing. // needPerThreadSyscall should never be 1 as syscall_runtime_doAllThreadsSyscall is not available with Cgo. } //--append //go:linkname hitsumabushi_closefd hitsumabushi_closefd //go:cgo_import_static hitsumabushi_closefd var hitsumabushi_closefd byte //go:linkname hitsumabushi_exit hitsumabushi_exit //go:cgo_import_static hitsumabushi_exit var hitsumabushi_exit byte //go:linkname hitsumabushi_gettid hitsumabushi_gettid //go:cgo_import_static hitsumabushi_gettid var hitsumabushi_gettid byte //go:linkname hitsumabushi_nanotime1 hitsumabushi_nanotime1 //go:cgo_import_static hitsumabushi_nanotime1 var hitsumabushi_nanotime1 byte //go:linkname hitsumabushi_open hitsumabushi_open //go:cgo_import_static hitsumabushi_open var hitsumabushi_open byte //go:linkname hitsumabushi_osyield hitsumabushi_osyield //go:cgo_import_static hitsumabushi_osyield var hitsumabushi_osyield byte //go:linkname hitsumabushi_read hitsumabushi_read //go:cgo_import_static hitsumabushi_read var hitsumabushi_read byte //go:linkname hitsumabushi_sched_getaffinity hitsumabushi_sched_getaffinity //go:cgo_import_static hitsumabushi_sched_getaffinity var hitsumabushi_sched_getaffinity byte //go:linkname hitsumabushi_usleep hitsumabushi_usleep //go:cgo_import_static hitsumabushi_usleep var hitsumabushi_usleep byte //go:linkname hitsumabushi_walltime1 hitsumabushi_walltime1 //go:cgo_import_static hitsumabushi_walltime1 var hitsumabushi_walltime1 byte //go:linkname hitsumabushi_write1 hitsumabushi_write1 //go:cgo_import_static hitsumabushi_write1 var hitsumabushi_write1 byte //go:nosplit //go:cgo_unsafe_args func fcntl1(fd, cmd, arg int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fcntl_trampoline)), unsafe.Pointer(&fd)) } func fcntl_trampoline() //go:nosplit //go:cgo_unsafe_args func fstat1(fd int, stat unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstat_trampoline)), unsafe.Pointer(&fd)) } func fstat_trampoline(fd int, stat unsafe.Pointer) int32 //go:nosplit //go:cgo_unsafe_args func lseek1(fd int, offset int64, whence int) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(lseek_trampoline)), unsafe.Pointer(&fd)) } func lseek_trampoline() //go:nosplit //go:cgo_unsafe_args func renameat(fd1 int, name1 unsafe.Pointer, fd2 int, name2 unsafe.Pointer) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(renameat_trampoline)), unsafe.Pointer(&fd1)) } func renameat_trampoline() //go:nosplit //go:cgo_unsafe_args func fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(fstatat_trampoline)), unsafe.Pointer(&fd)) } func fstatat_trampoline() ================================================ FILE: 1.26_linux/runtime/os_linux64.go.patch ================================================ //--from import ( "unsafe" ) //--to import ( "internal/abi" "unsafe" ) //--from //go:noescape func futex(addr unsafe.Pointer, op int32, val uint32, ts *timespec, addr2 unsafe.Pointer, val3 uint32) int32 //--to //go:nosplit //go:cgo_unsafe_args func futex(addr unsafe.Pointer, op int32, val uint32, ts *timespec, addr2 unsafe.Pointer, val3 uint32) int32 { ret := libcCall(unsafe.Pointer(abi.FuncPCABI0(futex_trampoline)), unsafe.Pointer(&addr)) return ret } func futex_trampoline(addr unsafe.Pointer, op int32, val uint32, ts *timespec, addr2 unsafe.Pointer, val3 uint32) int32 ================================================ FILE: 1.26_linux/runtime/panicnil_test.go.patch ================================================ //--from func TestPanicNil(t *testing.T) { //--to func TestPanicNil(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.26_linux/runtime/proc_test.go.patch ================================================ //--from func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) testGoroutineParallelism2(t, false, true) testGoroutineParallelism2(t, true, true) } //--to func TestGoroutineParallelism2(t *testing.T) { //testGoroutineParallelism2(t, false, false) testGoroutineParallelism2(t, true, false) //testGoroutineParallelism2(t, false, true) //testGoroutineParallelism2(t, true, true) } ================================================ FILE: 1.26_linux/runtime/rand_test.go.patch ================================================ //--from func TestReadRandom(t *testing.T) { //--to func TestReadRandom(t *testing.T) { t.Skip("readRandom is not available in this environment") ================================================ FILE: 1.26_linux/runtime/runtime1.go.patch ================================================ //--from func argv_index(argv **byte, i int32) *byte { return *(**byte)(add(unsafe.Pointer(argv), uintptr(i)*goarch.PtrSize)) } //--to func argv_index(argv **byte, i int32) *byte { return nil } //--from func args(c int32, v **byte) { argc = c argv = v sysargs(c, v) } //--to func args(c int32, v **byte) { // In the original code, physPageSize is determined at sysargs. // Hitsumabushi gives an initial value for physPageSize at its declaration, so sysargs doesn't have to be called. } //--append // Expose the entry point for some special environments. //go:cgo_export_static _rt0_amd64_linux_lib //go:cgo_export_dynamic _rt0_amd64_linux_lib ================================================ FILE: 1.26_linux/runtime/runtime_linux_test.go.patch ================================================ //--from func TestMincoreErrorSign(t *testing.T) { //--to func TestMincoreErrorSign(t *testing.T) { t.Skip("mincore is not supported in this environment") ================================================ FILE: 1.26_linux/runtime/runtime_mmap_test.go.patch ================================================ //--from //go:build unix //--to //go:build unix && !linux ================================================ FILE: 1.26_linux/runtime/runtime_test.go.patch ================================================ //--from func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { //--to func testSetPanicOnFault(t *testing.T, addr uintptr, nfault *int) { t.Skip("catching faults is not supported in this environment") ================================================ FILE: 1.26_linux/runtime/runtime_unix_test.go.patch ================================================ //--from //go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || plan9 //--to //go:build aix || darwin || dragonfly || freebsd || netbsd || openbsd || plan9 ================================================ FILE: 1.26_linux/runtime/stack_test.go.patch ================================================ //--from func TestDeferLeafSigpanic(t *testing.T) { //--to func TestDeferLeafSigpanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") //--from func TestStackWrapperStackPanic(t *testing.T) { //--to func TestStackWrapperStackPanic(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.26_linux/runtime/stubs2.go.patch ================================================ //--from import ( "internal/runtime/atomic" "unsafe" ) //--to import ( "internal/abi" "internal/runtime/atomic" "unsafe" ) //--from func read(fd int32, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func read(fd int32, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(read_trampoline)), unsafe.Pointer(&fd)) } func read_trampoline(fd int32, p unsafe.Pointer, n int32) int32 //--from func closefd(fd int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func closefd(fd int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(closefd_trampoline)), unsafe.Pointer(&fd)) } func closefd_trampoline(fd int32) int32 //--from func exit(code int32) //--to //go:nosplit //go:cgo_unsafe_args func exit(code int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(exit_trampoline)), unsafe.Pointer(&code)) } func exit_trampoline(code int32) //--from func usleep(usec uint32) //--to //go:nosplit //go:cgo_unsafe_args func usleep(usec uint32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } func usleep_trampoline(usec uint32) //--from //go:nosplit func usleep_no_g(usec uint32) { usleep(usec) } //--to //go:nosplit //go:cgo_unsafe_args func usleep_no_g(usec uint32) { asmcgocall_no_g(unsafe.Pointer(abi.FuncPCABI0(usleep_trampoline)), unsafe.Pointer(&usec)) } //--from //go:noescape func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func write1(fd uintptr, p unsafe.Pointer, n int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(write1_trampoline)), unsafe.Pointer(&fd)) } func write1_trampoline(fd uintptr, p unsafe.Pointer, n int32) int32 //--from //go:noescape func open(name *byte, mode, perm int32) int32 //--to //go:nosplit //go:cgo_unsafe_args func open(name *byte, mode, perm int32) int32 { return libcCall(unsafe.Pointer(abi.FuncPCABI0(open_trampoline)), unsafe.Pointer(&name)) } func open_trampoline(name *byte, mode, perm int32) int32 ================================================ FILE: 1.26_linux/runtime/stubs3.go.patch ================================================ //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func nanotime1() int64 //--to //go:nosplit //go:cgo_unsafe_args func nanotime1() (now int64) { libcCall(unsafe.Pointer(abi.FuncPCABI0(nanotime1_trampoline)), unsafe.Pointer(&now)) return } func nanotime1_trampoline() int64 ================================================ FILE: 1.26_linux/runtime/sys_libc.go.patch ================================================ //--from //go:build darwin || openbsd //--to //go:build darwin || openbsd || linux ================================================ FILE: 1.26_linux/runtime/sys_linux_amd64.s.patch ================================================ //--from TEXT runtime·open(SB),NOSPLIT,$0-20 // This uses openat instead of open, because Android O blocks open. MOVL $AT_FDCWD, DI // AT_FDCWD, so this acts like open MOVQ name+0(FP), SI MOVL mode+8(FP), DX MOVL perm+12(FP), R10 MOVL $SYS_openat, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVL 8(DI), SI // arg 2 flags MOVL 12(DI), DX // arg 3 mode MOVQ 0(DI), DI // arg 1 pathname XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_open(SB) MOVQ AX, 16(BX) POPQ BP RET //--from TEXT runtime·futex(SB),NOSPLIT,$0 MOVQ addr+0(FP), DI MOVL op+8(FP), SI MOVL val+12(FP), DX MOVQ ts+16(FP), R10 MOVQ addr2+24(FP), R8 MOVL val3+32(FP), R9 MOVL $SYS_futex, AX SYSCALL MOVL AX, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 addr MOVL 8(BX), SI // arg 2 op MOVL 12(BX), DX // arg 3 val MOVQ 16(BX), CX // arg 4 ts MOVQ 24(BX), R8 // arg 5 addr2 MOVL 32(BX), R9 // arg 6 val3 CALL hitsumabushi_futex(SB) MOVL AX, 40(BX) POPQ BP RET //--from TEXT runtime·exit(SB),NOSPLIT,$0-4 MOVL code+0(FP), DI MOVL $SYS_exit_group, AX SYSCALL RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 exit status CALL hitsumabushi_exit(SB) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·read(SB),NOSPLIT,$0-28 MOVL fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_read, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 0(BX), DI // arg 1 fd MOVQ 8(BX), SI // arg 2 buf MOVQ 16(BX), DX // arg 3 count CALL hitsumabushi_read(SB) MOVQ AX, 24(BX) // return value POPQ BP RET //--from TEXT runtime·closefd(SB),NOSPLIT,$0-12 MOVL fd+0(FP), DI MOVL $SYS_close, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $-1, AX MOVL AX, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 fd CALL hitsumabushi_closefd(SB) POPQ BP RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVL $SYS_gettid, AX SYSCALL MOVL AX, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_gettid(SB) POPQ BP RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT,$0 MOVQ new+0(FP), DI MOVQ old+8(FP), SI MOVQ $SYS_sigaltstack, AX SYSCALL CMPQ AX, $0xfffffffffffff001 JLS 2(PC) MOVL $0xf1, 0xf1 // crash RET //--to TEXT runtime·sigaltstack_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 old MOVQ 0(DI), DI // arg 1 new CALL hitsumabushi_sigaltstack(SB) TESTQ AX, AX JEQ 2(PC) MOVL $0xf1, 0xf1 // crash POPQ BP RET //--from TEXT runtime·raise(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, R12 MOVL $SYS_gettid, AX SYSCALL MOVL AX, SI // arg 2 tid MOVL R12, DI // arg 1 pid MOVL sig+0(FP), DX // arg 3 MOVL $SYS_tgkill, AX SYSCALL RET //--to TEXT runtime·raise_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 signal CALL hitsumabushi_raise(SB) POPQ BP RET //--from TEXT runtime·raiseproc(SB),NOSPLIT,$0 MOVL $SYS_getpid, AX SYSCALL MOVL AX, DI // arg 1 pid MOVL sig+0(FP), SI // arg 2 MOVL $SYS_kill, AX SYSCALL RET //--to TEXT runtime·raiseproc_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), BX // signal CALL hitsumabushi_getpid(SB) MOVL AX, DI // arg 1 pid MOVL BX, SI // arg 2 signal CALL hitsumabushi_kill(SB) POPQ BP RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT,$0 MOVQ pid+0(FP), DI MOVQ len+8(FP), SI MOVQ buf+16(FP), DX MOVL $SYS_sched_getaffinity, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 len MOVQ 16(DI), DX // arg 3 buf MOVQ 0(DI), DI // arg 1 pid CALL hitsumabushi_sched_getaffinity(SB) POPQ BP RET //--from TEXT runtime·osyield(SB),NOSPLIT,$0 MOVL $SYS_sched_yield, AX SYSCALL RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP CALL hitsumabushi_osyield(SB) POPQ BP RET //--from TEXT runtime·usleep(SB),NOSPLIT,$16 MOVL $0, DX MOVL usec+0(FP), AX MOVL $1000000, CX DIVL CX MOVQ AX, 0(SP) MOVL $1000, AX // usec to nsec MULL DX MOVQ AX, 8(SP) // nanosleep(&ts, 0) MOVQ SP, DI MOVL $0, SI MOVL $SYS_nanosleep, AX SYSCALL RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVL 0(DI), DI // arg 1 usec CALL hitsumabushi_usleep(SB) POPQ BP RET //--from TEXT runtime·write1(SB),NOSPLIT,$0-28 MOVQ fd+0(FP), DI MOVQ p+8(FP), SI MOVL n+16(FP), DX MOVL $SYS_write, AX SYSCALL MOVL AX, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 p MOVQ 16(DI), DX // arg 3 n MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_write1(SB) POPQ BP RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$16-8 // We don't know how much stack space the VDSO code will need, // so switch to g0. // In particular, a kernel configured with CONFIG_OPTIMIZE_INLINING=n // and hardening can use a full page of stack space in gettime_sym // due to stack probes inserted to avoid stack/heap collisions. // See issue #20427. #ifdef GOEXPERIMENT_runtimesecret // The kernel might spill our secrets onto g0 // erase our registers here. // TODO(dmo): what is the ABI guarantee here? we use // R14 later, but the function is ABI0 CMPL g_secret(R14), $0 JEQ nosecret CALL ·secretEraseRegisters(SB) nosecret: #endif MOVQ SP, R12 // Save old SP; R12 unchanged by C code. MOVQ g_m(R14), BX // BX unchanged by C code. // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVQ m_vdsoPC(BX), CX MOVQ m_vdsoSP(BX), DX MOVQ CX, 0(SP) MOVQ DX, 8(SP) LEAQ ret+0(FP), DX MOVQ -8(DX), CX MOVQ CX, m_vdsoPC(BX) MOVQ DX, m_vdsoSP(BX) CMPQ R14, m_curg(BX) // Only switch if on curg. JNE noswitch MOVQ m_g0(BX), DX MOVQ (g_sched+gobuf_sp)(DX), SP // Set SP to g0 stack noswitch: SUBQ $16, SP // Space for results ANDQ $~15, SP // Align for C code MOVL $1, DI // CLOCK_MONOTONIC LEAQ 0(SP), SI MOVQ runtime·vdsoClockgettimeSym(SB), AX CMPQ AX, $0 JEQ fallback CALL AX ret: MOVQ 0(SP), AX // sec MOVQ 8(SP), DX // nsec MOVQ R12, SP // Restore real SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVQ 8(SP), CX MOVQ CX, m_vdsoSP(BX) MOVQ 0(SP), CX MOVQ CX, m_vdsoPC(BX) // sec is in AX, nsec in DX // return nsec in AX IMULQ $1000000000, AX ADDQ DX, AX MOVQ AX, ret+0(FP) RET fallback: MOVQ $SYS_clock_gettime, AX SYSCALL JMP ret //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ DI, BX // BX is callee-saved MOVQ SP, BP CALL hitsumabushi_nanotime1(SB) MOVQ AX, 0(BX) POPQ BP RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(DI), DI CALL hitsumabushi_sysAllocOS(SB) MOVQ AX, 8(BX) POPQ BP RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUnusedOS(SB) POPQ BP RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysUsedOS(SB) POPQ BP RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysHugePageOS(SB) POPQ BP RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFreeOS(SB) POPQ BP RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysFaultOS(SB) POPQ BP RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysReserveOS(SB) MOVQ AX, 16(BX) POPQ BP RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_sysMapOS(SB) POPQ BP RET TEXT runtime·walltime1_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX // BX is callee-saved MOVQ 8(DI), SI MOVQ 0(DI), DI CALL hitsumabushi_walltime1(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ 8(DI), SI // arg 2 cmd MOVQ 16(DI), DX // arg 3 arg MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_fcntl(SB) POPQ BP RET TEXT runtime·fstat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 stat MOVQ 0(DI), DI // arg 1 fd CALL hitsumabushi_fstat(SB) MOVQ AX, 16(BX) // return value POPQ BP RET TEXT runtime·lseek_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 8(DI), SI // arg 2 offset MOVQ 16(DI), DX // arg 3 whence MOVQ 0(DI), DI // arg 1 fd XORL AX, AX // vararg: say "no float args" CALL hitsumabushi_lseek(SB) MOVQ AX, 24(BX) // return value POPQ BP RET TEXT runtime·renameat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_renameat(SB) MOVL AX, 32(BX) POPQ BP RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT|NOFRAME,$0 PUSHQ BP MOVQ SP, BP MOVQ DI, BX MOVQ 0(BX), DI // arg 1 MOVQ 8(BX), SI // arg 2 MOVQ 16(BX), DX // arg 3 MOVQ 24(BX), CX // arg 4 CALL hitsumabushi_fstatat(SB) MOVL AX, 32(BX) POPQ BP RET ================================================ FILE: 1.26_linux/runtime/sys_linux_arm64.s.patch ================================================ //--from #define SYS_exit 93 #define SYS_read 63 #define SYS_write 64 #define SYS_openat 56 #define SYS_close 57 #define SYS_pipe2 59 #define SYS_nanosleep 101 #define SYS_mmap 222 #define SYS_munmap 215 #define SYS_setitimer 103 #define SYS_clone 220 #define SYS_sched_yield 124 #define SYS_rt_sigreturn 139 #define SYS_rt_sigaction 134 #define SYS_rt_sigprocmask 135 #define SYS_sigaltstack 132 #define SYS_madvise 233 #define SYS_mincore 232 #define SYS_getpid 172 #define SYS_gettid 178 #define SYS_kill 129 #define SYS_tgkill 131 #define SYS_futex 98 #define SYS_sched_getaffinity 123 #define SYS_exit_group 94 #define SYS_clock_gettime 113 #define SYS_faccessat 48 #define SYS_socket 198 #define SYS_connect 203 #define SYS_brk 214 #define SYS_timer_create 107 #define SYS_timer_settime 110 #define SYS_timer_delete 111 //--to #define SYS_exit 2147483647 #define SYS_read 2147483647 #define SYS_write 2147483647 #define SYS_openat 2147483647 #define SYS_close 2147483647 #define SYS_pipe2 2147483647 #define SYS_nanosleep 2147483647 #define SYS_mmap 2147483647 #define SYS_munmap 2147483647 #define SYS_setitimer 2147483647 #define SYS_clone 2147483647 #define SYS_sched_yield 2147483647 #define SYS_rt_sigreturn 2147483647 #define SYS_rt_sigaction 2147483647 #define SYS_rt_sigprocmask 2147483647 #define SYS_sigaltstack 2147483647 #define SYS_madvise 2147483647 #define SYS_mincore 2147483647 #define SYS_getpid 2147483647 #define SYS_gettid 2147483647 #define SYS_kill 2147483647 #define SYS_tgkill 2147483647 #define SYS_futex 2147483647 #define SYS_sched_getaffinity 2147483647 #define SYS_exit_group 2147483647 #define SYS_clock_gettime 2147483647 #define SYS_faccessat 2147483647 #define SYS_socket 2147483647 #define SYS_connect 2147483647 #define SYS_brk 2147483647 #define SYS_timer_create 2147483647 #define SYS_timer_settime 2147483647 #define SYS_timer_delete 2147483647 //--from TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0-4 MOVW code+0(FP), R0 MOVD $SYS_exit_group, R8 SVC RET //--to TEXT runtime·exit_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_exit(SB) RET //--from TEXT runtime·open(SB),NOSPLIT|NOFRAME,$0-20 MOVD $AT_FDCWD, R0 MOVD name+0(FP), R1 MOVW mode+8(FP), R2 MOVW perm+12(FP), R3 MOVD $SYS_openat, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+16(FP) RET //--to TEXT runtime·open_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_open(SB) RET //--from TEXT runtime·closefd(SB),NOSPLIT|NOFRAME,$0-12 MOVW fd+0(FP), R0 MOVD $SYS_close, R8 SVC CMN $4095, R0 BCC done MOVW $-1, R0 done: MOVW R0, ret+8(FP) RET //--to TEXT runtime·closefd_trampoline(SB),NOSPLIT,$0-12 MOVW 0(R0), R0 BL hitsumabushi_closefd(SB) RET //--from TEXT runtime·write1(SB),NOSPLIT|NOFRAME,$0-28 MOVD fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_write, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·write1_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_write1(SB) RET //--from TEXT runtime·read(SB),NOSPLIT|NOFRAME,$0-28 MOVW fd+0(FP), R0 MOVD p+8(FP), R1 MOVW n+16(FP), R2 MOVD $SYS_read, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·read_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_read(SB) RET //--from TEXT runtime·usleep(SB),NOSPLIT,$24-4 MOVWU usec+0(FP), R3 MOVD R3, R5 MOVW $1000000, R4 UDIV R4, R3 MOVD R3, 8(RSP) MUL R3, R4 SUB R4, R5 MOVW $1000, R4 MUL R4, R5 MOVD R5, 16(RSP) // nanosleep(&ts, 0) ADD $8, RSP, R0 MOVD $0, R1 MOVD $SYS_nanosleep, R8 SVC RET //--to TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0 MOVW 0(R0), R0 BL hitsumabushi_usleep(SB) RET //--from TEXT runtime·gettid(SB),NOSPLIT,$0-4 MOVD $SYS_gettid, R8 SVC MOVW R0, ret+0(FP) RET //--to TEXT runtime·gettid_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_gettid(SB) MOVW R0, 0(R19) // return value RET //--from TEXT runtime·raise(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R19 MOVD $SYS_gettid, R8 SVC MOVW R0, R1 // arg 2 tid MOVW R19, R0 // arg 1 pid MOVW sig+0(FP), R2 // arg 3 MOVD $SYS_tgkill, R8 SVC RET //--to //--from TEXT runtime·raiseproc(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_getpid, R8 SVC MOVW R0, R0 // arg 1 pid MOVW sig+0(FP), R1 // arg 2 MOVD $SYS_kill, R8 SVC RET //--to //--from TEXT runtime·walltime(SB),NOSPLIT,$24-12 #ifdef GOEXPERIMENT_runtimesecret MOVW g_secret(g), R20 CBZ R20, nosecret BL ·secretEraseRegisters(SB) nosecret: #endif MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $16, R1 BIC $15, R1 // Align for C code MOVD R1, RSP MOVW $CLOCK_REALTIME, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) MOVD R3, sec+0(FP) MOVW R5, nsec+8(FP) RET //--to TEXT runtime·walltime1_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_walltime1(SB) RET //--from TEXT runtime·nanotime1(SB),NOSPLIT,$24-8 #ifdef GOEXPERIMENT_runtimesecret MOVW g_secret(g), R20 CBZ R20, nosecret BL ·secretEraseRegisters(SB) nosecret: #endif MOVD RSP, R20 // R20 is unchanged by C code MOVD RSP, R1 MOVD g_m(g), R21 // R21 = m // Set vdsoPC and vdsoSP for SIGPROF traceback. // Save the old values on stack and restore them on exit, // so this function is reentrant. MOVD m_vdsoPC(R21), R2 MOVD m_vdsoSP(R21), R3 MOVD R2, 8(RSP) MOVD R3, 16(RSP) MOVD $ret-8(FP), R2 // caller's SP MOVD LR, m_vdsoPC(R21) MOVD R2, m_vdsoSP(R21) MOVD m_curg(R21), R0 CMP g, R0 BNE noswitch MOVD m_g0(R21), R3 MOVD (g_sched+gobuf_sp)(R3), R1 // Set RSP to g0 stack noswitch: SUB $32, R1 BIC $15, R1 MOVD R1, RSP MOVW $CLOCK_MONOTONIC, R0 MOVD runtime·vdsoClockgettimeSym(SB), R2 CBZ R2, fallback // Store g on gsignal's stack, so if we receive a signal // during VDSO code we can find the g. // If we don't have a signal stack, we won't receive signal, // so don't bother saving g. // When using cgo, we already saved g on TLS, also don't save // g here. // Also don't save g if we are already on the signal stack. // We won't get a nested signal. MOVBU runtime·iscgo(SB), R22 CBNZ R22, nosaveg MOVD m_gsignal(R21), R22 // g.m.gsignal CBZ R22, nosaveg CMP g, R22 BEQ nosaveg MOVD (g_stack+stack_lo)(R22), R22 // g.m.gsignal.stack.lo MOVD g, (R22) BL (R2) MOVD ZR, (R22) // clear g slot, R22 is unchanged by C code B finish nosaveg: BL (R2) B finish fallback: MOVD $SYS_clock_gettime, R8 SVC finish: MOVD 0(RSP), R3 // sec MOVD 8(RSP), R5 // nsec MOVD R20, RSP // restore SP // Restore vdsoPC, vdsoSP // We don't worry about being signaled between the two stores. // If we are not in a signal handler, we'll restore vdsoSP to 0, // and no one will care about vdsoPC. If we are in a signal handler, // we cannot receive another signal. MOVD 16(RSP), R1 MOVD R1, m_vdsoSP(R21) MOVD 8(RSP), R1 MOVD R1, m_vdsoPC(R21) // sec is in R3, nsec in R5 // return nsec in R3 MOVD $1000000000, R4 MUL R4, R3 ADD R5, R3 MOVD R3, ret+0(FP) RET //--to TEXT runtime·nanotime1_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save BL hitsumabushi_nanotime1(SB) MOVD R0, 0(R19) // return value RET //--from TEXT runtime·futex(SB),NOSPLIT|NOFRAME,$0 MOVD addr+0(FP), R0 MOVW op+8(FP), R1 MOVW val+12(FP), R2 MOVD ts+16(FP), R3 MOVD addr2+24(FP), R4 MOVW val3+32(FP), R5 MOVD $SYS_futex, R8 SVC MOVW R0, ret+40(FP) RET //--to TEXT runtime·futex_trampoline(SB),NOSPLIT,$0 MOVW 8(R0), R1 MOVW 12(R0), R2 MOVD 16(R0), R3 MOVD 24(R0), R4 MOVW 32(R0), R5 MOVD 0(R0), R0 BL hitsumabushi_futex(SB) RET //--from TEXT runtime·sigaltstack(SB),NOSPLIT|NOFRAME,$0 MOVD new+0(FP), R0 MOVD old+8(FP), R1 MOVD $SYS_sigaltstack, R8 SVC CMN $4095, R0 BCC ok MOVD $0, R0 MOVD R0, (R0) // crash ok: RET //--to //--from TEXT runtime·osyield(SB),NOSPLIT|NOFRAME,$0 MOVD $SYS_sched_yield, R8 SVC RET //--to TEXT runtime·osyield_trampoline(SB),NOSPLIT,$0 BL hitsumabushi_osyield(SB) RET //--from TEXT runtime·sched_getaffinity(SB),NOSPLIT|NOFRAME,$0 MOVD pid+0(FP), R0 MOVD len+8(FP), R1 MOVD buf+16(FP), R2 MOVD $SYS_sched_getaffinity, R8 SVC MOVW R0, ret+24(FP) RET //--to TEXT runtime·sched_getaffinity_trampoline(SB),NOSPLIT,$0-28 MOVD 8(R0), R1 MOVD 16(R0), R2 MOVD 0(R0), R0 BL hitsumabushi_sched_getaffinity(SB) RET //--append TEXT runtime·sysAllocOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 0(R0), R0 BL hitsumabushi_sysAllocOS(SB) MOVD R0, 8(R19) // return value RET TEXT runtime·sysUnusedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUnusedOS(SB) RET TEXT runtime·sysUsedOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysUsedOS(SB) RET TEXT runtime·sysHugePageOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysHugePageOS(SB) RET TEXT runtime·sysFreeOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFreeOS(SB) RET TEXT runtime·sysFaultOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysFaultOS(SB) RET TEXT runtime·sysReserveOS_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysReserveOS(SB) MOVD R0, 16(R19) // return value RET TEXT runtime·sysMapOS_trampoline(SB),NOSPLIT,$0 MOVD 8(R0), R1 MOVD 0(R0), R0 BL hitsumabushi_sysMapOS(SB) RET TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVW 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_fcntl(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·fstat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 0(R0), R0 BL hitsumabushi_fstat(SB) MOVW R0, 16(R19) // return value RET TEXT runtime·lseek_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVW 16(R0), R2 MOVW 0(R0), R0 BL hitsumabushi_lseek(SB) MOVW R0, 24(R19) // return value RET TEXT runtime·renameat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_renameat(SB) MOVW R0, 32(R19) // return value RET TEXT runtime·fstatat_trampoline(SB),NOSPLIT,$0 MOVD R0, R19 // R19 is callee-save MOVD 8(R0), R1 MOVD 16(R0), R2 MOVW 24(R0), R3 MOVD 0(R0), R0 BL hitsumabushi_fstatat(SB) MOVW R0, 32(R19) // return value RET ================================================ FILE: 1.26_linux/runtime/time_linux_amd64.s.patch ================================================ //--from //go:build !faketime //--to //go:build ignore ================================================ FILE: 1.26_linux/runtime/timeasm.go.patch ================================================ //--from //go:build !faketime && (windows || (linux && amd64)) //--to //go:build !faketime && windows ================================================ FILE: 1.26_linux/runtime/timestub.go.patch ================================================ //--from //go:build !faketime && !windows && !(linux && amd64) && !plan9 //--to //go:build !faketime && !windows && !plan9 ================================================ FILE: 1.26_linux/runtime/timestub2.go.patch ================================================ //--from //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !wasip1 && !windows && !(linux && amd64) && !plan9 //--to //go:build !aix && !darwin && !freebsd && !openbsd && !solaris && !wasip1 && !windows && !plan9 //--from package runtime //--to package runtime import ( "internal/abi" "unsafe" ) //--from func walltime() (sec int64, nsec int32) //--to func walltime() (sec int64, nsec int32) { walltime1(&sec, &nsec) return } //go:nosplit //go:cgo_unsafe_args func walltime1(sec *int64, nsec *int32) { libcCall(unsafe.Pointer(abi.FuncPCABI0(walltime1_trampoline)), unsafe.Pointer(&sec)) } func walltime1_trampoline(sec *int64, nsec *int32) ================================================ FILE: 1.26_linux/runtime/traceback_test.go.patch ================================================ //--from func TestTracebackInlined(t *testing.T) { //--to func TestTracebackInlined(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.26_linux/sync/atomic/atomic_test.go.patch ================================================ //--from func TestStoreLoadSeqCst32(t *testing.T) { //--to func TestStoreLoadSeqCst32(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") //--from func TestStoreLoadSeqCst64(t *testing.T) { //--to func TestStoreLoadSeqCst64(t *testing.T) { t.Skip("didn't work on QEMU. see golang/go#50188") //--from func TestNilDeref(t *testing.T) { //--to func TestNilDeref(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.26_linux/syscall/hitsumabushi_stubs_linux_amd64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_FSTATAT = 0xffffffffffffffff // Stub: on amd64 Go uses SYS_NEWFSTATAT instead ) ================================================ FILE: 1.26_linux/syscall/hitsumabushi_stubs_linux_arm64.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 The Hitsumabushi Authors package syscall const ( SYS_NEWFSTATAT = 0xffffffffffffffff // Stub: on arm64 Go uses SYS_FSTATAT instead ) ================================================ FILE: 1.26_linux/syscall/rlimit.go.patch ================================================ //--from func init() { var lim Rlimit if err := Getrlimit(RLIMIT_NOFILE, &lim); err == nil && lim.Max > 0 && lim.Cur < lim.Max-1 { origRlimitNofile.Store(&lim) nlim := lim // We set Cur to Max - 1 so that we are more likely to // detect cases where another process uses prlimit // to change our resource limits. The theory is that // using prlimit to change to Cur == Max is more likely // than using prlimit to change to Cur == Max - 1. // The place we check for this is in exec_linux.go. nlim.Cur = nlim.Max - 1 adjustFileLimit(&nlim) setrlimit(RLIMIT_NOFILE, &nlim) } } //--to func init() { } ================================================ FILE: 1.26_linux/syscall/syscall_linux.go.patch ================================================ //--from func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() // N.B. Calling RawSyscall here is unsafe with atomic coverage // instrumentation and race mode. // // Coverage instrumentation will add a sync/atomic call to RawSyscall. // Race mode will add race instrumentation to sync/atomic. Race // instrumentation requires a P, which we no longer have. // // RawSyscall6 is fine because it is implemented in assembly and thus // has no coverage instrumentation. // // This is typically not a problem in the runtime because cmd/go avoids // adding coverage instrumentation to the runtime in race mode. r1, r2, err = RawSyscall6(trap, a1, a2, a3, 0, 0, 0) runtime_exitsyscall() return } //--to func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FCNTL: r = fcntl1(a1, a2, a3) case SYS_FSTAT: r = fstat1(a1, unsafe.Pointer(a2)) case SYS_READ: r = runtime_read(uintptr(a1), unsafe.Pointer(a2), int32(a3)) case SYS_WRITE: r = write1(a1, unsafe.Pointer(a2), int32(a3)) case SYS_LSEEK: r = lseek1(a1, int64(a2), int32(a3)) case SYS_CLOSE: r = runtime_closefd(int32(a1)) case SYS_MKDIRAT: println("syscall mkdirat() is not implemented") // Default to permission denied. TODO: implement this return 0, 0, EPERM case SYS_GETDENTS64: println("syscall getdents64() is not implemented") // Default to empty directory. TODO: implement this return 0, 0, 0 default: println("unimplemented syscall at runtime.Syscall", trap) panic("syscall.Syscall") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //go:linkname open runtime.open func open(name *byte, mode, perm int32) int32 //go:linkname write1 runtime.write1 func write1(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname fcntl1 runtime.fcntl1 func fcntl1(fd uintptr, a uintptr, b uintptr) int32 //go:linkname fstat1 runtime.fstat1 func fstat1(fd uintptr, p unsafe.Pointer) int32 //go:linkname lseek1 runtime.lseek1 func lseek1(fd uintptr, offset int64, whence int32) int32 //go:linkname runtime_read runtime.read func runtime_read(fd uintptr, p unsafe.Pointer, n int32) int32 //go:linkname runtime_closefd runtime.closefd func runtime_closefd(fd int32) int32 //go:linkname runtime_fstatat runtime.fstatat func runtime_fstatat(fd uintptr, name unsafe.Pointer, p unsafe.Pointer, n int32) int32 //go:linkname runtime_renameat runtime.renameat func runtime_renameat(fd1 uintptr, name1 unsafe.Pointer, fd2 uintptr, name2 unsafe.Pointer) int32 //--from func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { runtime_entersyscall() r1, r2, err = RawSyscall6(trap, a1, a2, a3, a4, a5, a6) runtime_exitsyscall() return } //--to func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) { var r int32 switch trap { case SYS_FSTATAT, SYS_NEWFSTATAT: r = runtime_fstatat(uintptr(a1), unsafe.Pointer(a2), unsafe.Pointer(a3), int32(a4)) case SYS_RENAMEAT: r = runtime_renameat(uintptr(a1), unsafe.Pointer(a2), uintptr(a3), unsafe.Pointer(a4)) default: println("unimplemented syscall at runtime.Syscall6", trap) panic("syscall.Syscall6") return 0, 0, ENOSYS } if r < 0 { return 0, 0, Errno(-r) } return uintptr(r), 0, 0 } //--from func Open(path string, mode int, perm uint32) (fd int, err error) { return openat(_AT_FDCWD, path, mode|O_LARGEFILE, perm) } //--to func Open(path string, mode int, perm uint32) (fd int, err error) { p0, err := BytePtrFromString(path) if err != nil { return -1, errnoErr(EINVAL) } fd = int(open(p0, int32(mode|O_LARGEFILE), int32(perm))) if fd < 0 { return -1, errnoErr(ENOENT) } return } ================================================ FILE: 1.26_linux/testing/run_example.go ================================================ package testing func runExample(eg InternalExample) (ok bool) { // Do nothing. // TODO: Implement os.Pipe2 and use this here. return true } ================================================ FILE: 1.26_linux/time/format_test.go.patch ================================================ //--from func TestParseInLocation(t *testing.T) { //--to func TestParseInLocation(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationZipFile(t *testing.T) { //--to func TestLoadLocationZipFile(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.26_linux/time/internal_test.go.patch ================================================ //--from func initTestingZone() { // For hermeticity, use only tzinfo source from the test's GOROOT, // not the system sources and not whatever GOROOT may happen to be // set in the process's environment (if any). // This test runs in GOROOT/src/time, so GOROOT is "../..", // but it is theoretically possible sources := []string{"../../lib/time/zoneinfo.zip"} z, err := loadLocation("America/Los_Angeles", sources) if err != nil { panic("cannot load America/Los_Angeles for testing: " + err.Error() + "; you may want to use -tags=timetzdata") } z.name = "Local" localLoc = *z } //--to func initTestingZone() { // Data from the playground. // https://go.dev/play/p/VGXU57KZZ-x // name is replaced with "Local". // cachStart, cacheEnd, and cacheZone are removed. localLoc = Location{name:"Local",zone:[]zone{zone{name:"LMT", offset:-28378, isDST:false}, zone{name:"PDT", offset:-25200, isDST:true}, zone{name:"PST", offset:-28800, isDST:false}, zone{name:"PWT", offset:-25200, isDST:true}, zone{name:"PPT", offset:-25200, isDST:true}}, tx:[]zoneTrans{zoneTrans{when:-576460752303423488, index:0x0, isstd:false, isutc:false}, zoneTrans{when:-2717640000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1633269600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-1615129200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-1601820000, index:0x1, isstd:true, isutc:true}, zoneTrans{when:-1583679600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-880207200, index:0x3, isstd:false, isutc:false}, zoneTrans{when:-769395600, index:0x4, isstd:false, isutc:false}, zoneTrans{when:-765385200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-687967140, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-662655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-620838000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-608137200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-589388400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-576082800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-557938800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-544633200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-526489200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-513183600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-495039600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-481734000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-463590000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-450284400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-431535600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-418230000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-400086000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-386780400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-368636400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-355330800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-337186800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-323881200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-305737200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-292431600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-273682800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-260982000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-242233200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-226508400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-210783600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-195058800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-179334000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-163609200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-147884400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-131554800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-116434800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-100105200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-84376800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-68655600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-52927200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-37206000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:-21477600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:-5756400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:9972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:25693200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:41421600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:57747600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:73476000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:89197200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:104925600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:120646800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:126698400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:152096400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:162381600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:183546000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:199274400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:215600400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:230724000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:247050000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:262778400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:278499600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:294228000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:309949200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:325677600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:341398800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:357127200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:372848400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:388576800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:404902800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:420026400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:436352400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:452080800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:467802000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:483530400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:499251600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:514980000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:530701200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:544615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:562150800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:576064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:594205200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:607514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:625654800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:638964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:657104400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:671018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:688554000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:702468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:720003600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:733917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:752058000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:765367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:783507600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:796816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:814957200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:828871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:846406800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:860320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:877856400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:891770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:909306000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:923220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:941360400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:954669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:972810000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:986119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1004259600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1018173600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1035709200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1049623200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1067158800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1081072800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1099213200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1112522400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1130662800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1143972000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1162112400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1173607200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1194166800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1205056800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1225616400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1236506400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1257066000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1268560800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1289120400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1300010400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1320570000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1331460000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1352019600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1362909600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1383469200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1394359200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1414918800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1425808800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1446368400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1457863200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1478422800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1489312800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1509872400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1520762400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1541322000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1552212000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1572771600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1583661600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1604221200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1615716000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1636275600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1647165600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1667725200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1678615200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1699174800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1710064800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1730624400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1741514400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1762074000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1772964000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1793523600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1805018400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1825578000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1836468000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1857027600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1867917600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1888477200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1899367200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1919926800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1930816800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1951376400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1962871200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:1983430800, index:0x2, isstd:false, isutc:false}, zoneTrans{when:1994320800, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2014880400, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2025770400, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2046330000, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2057220000, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2077779600, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2088669600, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2109229200, index:0x2, isstd:false, isutc:false}, zoneTrans{when:2120119200, index:0x1, isstd:false, isutc:false}, zoneTrans{when:2140678800, index:0x2, isstd:false, isutc:false}}, extend:"PST8PDT,M3.2.0,M11.1.0"} } ================================================ FILE: 1.26_linux/time/sleep_test.go.patch ================================================ //--from func TestSleep(t *testing.T) { //--to func TestSleep(t *testing.T) { t.Skip("Interrupt (syscall.Kill) is not supported in this environment") //--from func TestIssue5745(t *testing.T) { //--to func TestIssue5745(t *testing.T) { t.Skip("handling nil pointer access is not supported in this environment") ================================================ FILE: 1.26_linux/time/time_test.go.patch ================================================ //--from func TestLoadFixed(t *testing.T) { //--to func TestLoadFixed(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestTimeIsDST(t *testing.T) { //--to func TestTimeIsDST(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestTimeWithZoneTransition(t *testing.T) { //--to func TestTimeWithZoneTransition(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestMarshalBinaryVersion2(t *testing.T) { //--to func TestMarshalBinaryVersion2(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.26_linux/time/tzdata_test.go.patch ================================================ //--from func TestEmbeddedTZData(t *testing.T) { //--to func TestEmbeddedTZData(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.26_linux/time/zoneinfo_test.go.patch ================================================ //--from func TestEnvVarUsage(t *testing.T) { //--to func TestEnvVarUsage(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestBadLocationErrMsg(t *testing.T) { //--to func TestBadLocationErrMsg(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestVersion3(t *testing.T) { //--to func TestVersion3(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestFirstZone(t *testing.T) { //--to func TestFirstZone(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationFromTZData(t *testing.T) { //--to func TestLoadLocationFromTZData(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestEarlyLocation(t *testing.T) { //--to func TestEarlyLocation(t *testing.T) { t.Skip("location is not supported in this environment") //--from func TestLoadLocationFromTZDataSlim(t *testing.T) { //--to func TestLoadLocationFromTZDataSlim(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.26_linux/time/zoneinfo_unix.go.patch ================================================ //--from import ( "syscall" ) //--to //--from func initLocal() { // consult $TZ to find the time zone to use. // no $TZ means use the system default /etc/localtime. // $TZ="" means use UTC. // $TZ="foo" or $TZ=":foo" if foo is an absolute path, then the file pointed // by foo will be used to initialize timezone; otherwise, file // /usr/share/zoneinfo/foo will be used. tz, ok := syscall.Getenv("TZ") switch { case !ok: z, err := loadLocation("localtime", []string{"/etc"}) if err == nil { localLoc = *z localLoc.name = "Local" return } case tz != "": if tz[0] == ':' { tz = tz[1:] } if tz != "" && tz[0] == '/' { if z, err := loadLocation(tz, []string{""}); err == nil { localLoc = *z if tz == "/etc/localtime" { localLoc.name = "Local" } else { localLoc.name = tz } return } } else if tz != "" && tz != "UTC" { if z, err := loadLocation(tz, platformZoneSources); err == nil { localLoc = *z return } } } // Fall back to UTC. localLoc.name = "UTC" } //--to func initLocal() { localLoc.name = "UTC" } ================================================ FILE: 1.26_linux/time/zoneinfo_unix_test.go.patch ================================================ //--from func TestEnvTZUsage(t *testing.T) { //--to func TestEnvTZUsage(t *testing.T) { t.Skip("location is not supported in this environment") ================================================ FILE: 1.26_windows/internal/testenv/exec.go.patch ================================================ //--from var tryExec = sync.OnceValue(func() error { //--to var tryExec = sync.OnceValue(func() error { return fmt.Errorf("can't probe for exec support") ================================================ FILE: 1.26_windows/internal/testenv/testenv.go.patch ================================================ //--from func HasGoBuild() bool { //--to func HasGoBuild() bool { return false ================================================ FILE: 1.26_windows/runtime/cgo/gcc_windows_amd64.c.patch ================================================ //--from static unsigned long __stdcall threadentry(void *v) { ThreadStart ts; //--to static int getproccount() { static int proccount = 0; if (!proccount) { SYSTEM_INFO info; GetSystemInfo(&info); proccount = info.dwNumberOfProcessors; } return proccount; } static unsigned long __stdcall threadentry(void *v) { ThreadStart ts; SetThreadAffinityMask(GetCurrentThread(), (1< //--to //--append #define fprintf dummy_fprintf // TODO: Use OutputDebugMessage. #define dummy_fprintf(stream, format, ...) ================================================ FILE: 1.26_windows/runtime/os_windows.go.patch ================================================ //--from //go:cgo_import_dynamic runtime._GetConsoleMode GetConsoleMode%2 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._LoadLibraryExW LoadLibraryExW%3 "kernel32.dll" //--to //go:cgo_import_dynamic runtime._LoadLibraryExW LoadLibraryExW%3 "kernel32.dll" //go:cgo_import_dynamic runtime._LoadLibraryW LoadLibraryW%1 "kernel32.dll" //--from //go:cgo_import_dynamic runtime._SetConsoleCtrlHandler SetConsoleCtrlHandler%2 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._WerGetFlags WerGetFlags%2 "kernel32.dll" //go:cgo_import_dynamic runtime._WerSetFlags WerSetFlags%1 "kernel32.dll" //--to //--from //go:cgo_import_dynamic runtime._WriteConsoleW WriteConsoleW%5 "kernel32.dll" //--to //go:cgo_import_dynamic runtime._OutputDebugStringW OutputDebugStringW%1 "kernel32.dll" //--from _GetConsoleMode, //--to //--from _LoadLibraryExW, //--to _LoadLibraryExW, _LoadLibraryW, //--from _SetConsoleCtrlHandler, //--to //--from _WerGetFlags, _WerSetFlags, //--to //--from _WriteConsoleW, //--to _OutputDebugStringW, //--from // We call these all the way here, late in init, so that malloc works // for the callback functions these generate. var fn any = ctrlHandler ctrlHandlerPC := compileCallback(*efaceOf(&fn), true) stdcall(_SetConsoleCtrlHandler, ctrlHandlerPC, 1) //--to //--from func write1(fd uintptr, buf unsafe.Pointer, n int32) int32 { const ( _STD_OUTPUT_HANDLE = ^uintptr(10) // -11 _STD_ERROR_HANDLE = ^uintptr(11) // -12 ) var handle uintptr switch fd { case 1: handle = stdcall(_GetStdHandle, _STD_OUTPUT_HANDLE) case 2: handle = stdcall(_GetStdHandle, _STD_ERROR_HANDLE) default: // assume fd is real windows handle. handle = fd } isASCII := true b := (*[1 << 30]byte)(buf)[:n] for _, x := range b { if x >= 0x80 { isASCII = false break } } if !isASCII { var m uint32 isConsole := stdcall(_GetConsoleMode, handle, uintptr(unsafe.Pointer(&m))) != 0 // If this is a console output, various non-unicode code pages can be in use. // Use the dedicated WriteConsole call to ensure unicode is printed correctly. if isConsole { return int32(writeConsole(handle, buf, n)) } } var written uint32 stdcall(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--to func write1(fd uintptr, buf unsafe.Pointer, n int32) int32 { const ( _STD_OUTPUT_HANDLE = ^uintptr(10) // -11 _STD_ERROR_HANDLE = ^uintptr(11) // -12 ) var handle uintptr switch fd { case 1: handle = stdcall(_GetStdHandle, _STD_OUTPUT_HANDLE) case 2: handle = stdcall(_GetStdHandle, _STD_ERROR_HANDLE) default: // assume fd is real windows handle. handle = fd } if fd == 1 || fd == 2 { // Note that handle is not used anyway. return int32(writeConsole(handle, buf, n)) } var written uint32 stdcall(_WriteFile, handle, uintptr(buf), uintptr(n), uintptr(unsafe.Pointer(&written)), 0) return int32(written) } //--from func writeConsoleUTF16(handle uintptr, b []uint16) { l := uint32(len(b)) if l == 0 { return } var written uint32 stdcall(_WriteConsoleW, handle, uintptr(unsafe.Pointer(&b[0])), uintptr(l), uintptr(unsafe.Pointer(&written)), 0, ) return } //--to func writeConsoleUTF16(handle uintptr, b []uint16) { b = b[:len(b)+1] b[len(b)-1] = 0 l := uint32(len(b)) if l <= 1 { return } stdcall(_OutputDebugStringW, uintptr(unsafe.Pointer(&b[0])), ) return } ================================================ FILE: 1.26_windows/runtime/signal_windows.go.patch ================================================ //--from func preventErrorDialogs() { errormode := stdcall(_GetErrorMode) stdcall(_SetErrorMode, errormode|windows.SEM_FAILCRITICALERRORS|windows.SEM_NOGPFAULTERRORBOX|windows.SEM_NOOPENFILEERRORBOX) // Disable WER fault reporting UI. // Do this even if WER is disabled as a whole, // as WER might be enabled later with setTraceback("wer") // and we still want the fault reporting UI to be disabled if this happens. var werflags uintptr stdcall(_WerGetFlags, windows.CurrentProcess, uintptr(unsafe.Pointer(&werflags))) stdcall(_WerSetFlags, werflags|windows.WER_FAULT_REPORTING_NO_UI) } //--to func preventErrorDialogs() { errormode := stdcall(_GetErrorMode) stdcall(_SetErrorMode, errormode|windows.SEM_FAILCRITICALERRORS|windows.SEM_NOGPFAULTERRORBOX|windows.SEM_NOOPENFILEERRORBOX) } ================================================ FILE: 1.26_windows/runtime/syscall_windows.go.patch ================================================ //--from func syscall_syscalln(fn, n uintptr, args ...uintptr) (r1, r2, err uintptr) { //--to func syscall_syscalln(fn, n uintptr, args ...uintptr) (r1, r2, err uintptr) { if fn == 0 { panic("fn must not be 0 at SyscallN") } ================================================ FILE: 1.26_windows/runtime/syscall_windows_test.go.patch ================================================ //--from func TestNumCPU(t *testing.T) { //--to func TestNumCPU(t *testing.T) { t.Skip("creating a new process with os.Args[0] doesn't work in this environment") ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright {yyyy} {name of copyright owner} Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: README.md ================================================ # Hitsumabushi (ひつまぶし) Package hitsumabushi provides APIs to generate JSON for go-build's `-overlay` option. Hitsumabushi aims to make Go programs work on almost everywhere by overwriting system calls with C function calls. Now the generated JSON works only for Linux/Amd64, Linux/Arm64, and Windows/Amd64 so far. For GOOS=windows, Hitsumabushi replaces some functions that don't work on some special Windows-like systems. Go version: 1.19-1.25 ## Example On Arm Linux, run these commands: ``` cd example/helloworld ./run.sh ``` ## Tips With VC++, you might have to call `_rt0_amd64_windows_lib()` at the beginning of the entry point explicitly. See also https://github.com/golang/go/issues/42190. ================================================ FILE: doc.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2021 Hajime Hoshi // Package hitsumabushi provides APIs to generate JSON for go-build's `-overlay` option. // Hitsumabushi aims to make Go programs work on almost everywhere by overwriting system calls with C function calls. // Now the generated JSON works only for Linux/Amd64, Linux/Arm64, and Windows/Amd64 so far. // For GOOS=windows, Hitsumabushi replaces some functions that don't work on some special Windows-like systems. package hitsumabushi ================================================ FILE: example/helloworld/.gitignore ================================================ *.a helloworld.h ================================================ FILE: example/helloworld/genoverlayjson.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2022 Hajime Hoshi //go:build ignore package main import ( "fmt" "os" "github.com/hajimehoshi/hitsumabushi" ) func main() { if err := build(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } func build() error { options := []hitsumabushi.Option{ hitsumabushi.Args(os.Args...), hitsumabushi.GOOS("linux"), } overlayJSON, err := hitsumabushi.GenOverlayJSON(options...) if err != nil { return err } if _, err := os.Stdout.Write(overlayJSON); err != nil { return err } return nil } ================================================ FILE: example/helloworld/main.c ================================================ // SPDX-License-Identifier: Apache-2.0 //go:build ignore #include "helloworld.h" int main() { HelloWorld(); return 0; } ================================================ FILE: example/helloworld/main.go ================================================ // SPDX-License-Identifier: Apache-2.0 package main import "C" //export HelloWorld func HelloWorld() { println("Hello, World!") } func main() { // -buildmode=c-archive requires a main package. } ================================================ FILE: example/helloworld/run.sh ================================================ # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: 2022 Hajime Hoshi set -e go run genoverlayjson.go > /tmp/overlay.json env GOOS=linux GOARCH=arm64 CGO_ENABLED=1 \ CGO_CFLAGS='-fno-common -fno-short-enums -ffunction-sections -fdata-sections -fPIC -g -O3' \ go build -buildmode=c-archive -overlay=/tmp/overlay.json -o=helloworld.a gcc -o helloworld main.c helloworld.a -lpthread ./helloworld ================================================ FILE: example/helloworld/run_cross.sh ================================================ # SPDX-License-Identifier: Apache-2.0 # SPDX-FileCopyrightText: 2023 Hajime Hoshi set -e CC="aarch64-linux-gnu-gcc" go run genoverlayjson.go > /tmp/overlay.json env GOOS=linux GOARCH=arm64 CGO_ENABLED=1 CC=$CC \ CGO_CFLAGS='-fno-common -fno-short-enums -ffunction-sections -fdata-sections -fPIC -g -O3' \ go build -buildmode=c-archive -overlay=/tmp/overlay.json -o=helloworld.a $CC -o helloworld main.c helloworld.a -lpthread env QEMU_LD_PREFIX=/usr/aarch64-linux-gnu qemu-aarch64 ./helloworld ================================================ FILE: go.mod ================================================ module github.com/hajimehoshi/hitsumabushi go 1.19 ================================================ FILE: overlay.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2021 Hajime Hoshi package hitsumabushi import ( "bytes" "embed" "encoding/json" "errors" "fmt" "io" "io/fs" "os" "os/exec" "path" "path/filepath" "regexp" "runtime" "strconv" "strings" "unicode/utf16" ) type Option func(*config) type replaceString struct { from string to string } type config struct { testPkgs []string overlayDir string os string args []string pageSize int replaceDLLs []replaceString overlay []replaceString } // TestPkg represents a package for testing. // When generating a JSON, importing `runtime/cgo` is inserted in the testing package. func TestPkg(pkg string) Option { return func(cfg *config) { cfg.testPkgs = append(cfg.testPkgs, pkg) } } // OverlayDir sets the temporary working directory where overlay files are stored. func OverlayDir(dir string) Option { return func(cfg *config) { cfg.overlayDir = dir } } // Args is arguments when executing. // The first argument must be a program name. func Args(args ...string) Option { return func(cfg *config) { cfg.args = append(cfg.args, args...) } } // GOOS specifies GOOS to generate the JSON. // The default value is runtime.GOOS. func GOOS(os string) Option { return func(cfg *config) { cfg.os = os } } // PageSize specifies the page size. // The deafult value is 4096. // // This works only for Linux. func PageSize(pageSize int) Option { return func(cfg *config) { cfg.pageSize = pageSize } } // ReplaceDLL replaces a DLL file name loaded at LoadLibraryW and LoadLibraryExW. // // This works only for Windows. func ReplaceDLL(from, to string) Option { return func(cfg *config) { cfg.replaceDLLs = append(cfg.replaceDLLs, replaceString{ from: from, to: to, }) } } // Overlay adds or replaces an entry for the -overlay option. func Overlay(from, to string) Option { return func(cfg *config) { cfg.overlay = append(cfg.overlay, replaceString{ from: from, to: to, }) } } //go:embed 1.*_* var patchFiles embed.FS // reGoVersion represents a regular expression for Go version. // With gotip, the version might start with "devel ", so '^' is not used here. var reGoVersion = regexp.MustCompile(`go(\d+\.\d+)`) func goVersion() string { m := reGoVersion.FindStringSubmatch(runtime.Version()) return m[1] } func goMajorMinorVersion() (int, int) { tokens := strings.Split(goVersion(), ".") major, _ := strconv.Atoi(tokens[0]) minor, _ := strconv.Atoi(tokens[1]) return major, minor } // GenOverlayJSON generates a JSON file for go-build's `-overlay` option. // GenOverlayJSON returns a JSON file content, or an error if generating it fails. // // Now the generated JSON works only for Arm64 so far. func GenOverlayJSON(options ...Option) ([]byte, error) { type overlay struct { Replace map[string]string } cfg := config{ os: runtime.GOOS, pageSize: 4096, } for _, op := range options { op(&cfg) } root := goVersion() + "_" + cfg.os dir, err := patchFiles.Open(root) if err != nil { if errors.Is(err, fs.ErrNotExist) { return nil, fmt.Errorf("hitsumabushi: Hitsumabushi does not support the Go version %s and GOOS=%s", runtime.Version(), cfg.os) } return nil, err } dir.Close() subFiles, err := fs.Sub(patchFiles, root) if err != nil { return nil, err } tmpDir := cfg.overlayDir if tmpDir == "" { var err error tmpDir, err = os.MkdirTemp("", "") if err != nil { return nil, err } } replaces := map[string]string{} if err := fs.WalkDir(subFiles, ".", func(entryPath string, d fs.DirEntry, err error) error { if d.IsDir() { return nil } const ( modTypeReplace = ".replace" modTypeAppend = ".append" modTypePatch = ".patch" ) modType := modTypeReplace origFilename := path.Base(entryPath) for _, m := range []string{modTypeAppend, modTypePatch} { if strings.HasSuffix(origFilename, m) { origFilename = origFilename[:len(origFilename)-len(m)] modType = m break } } ext := path.Ext(origFilename) if ext != ".go" && ext != ".c" && ext != ".h" && ext != ".s" { return nil } pkg := path.Dir(entryPath) origDir, err := goPkgDir(pkg, cfg.os) if err != nil { return err } src, err := subFiles.Open(entryPath) if err != nil { return err } defer src.Close() if err := os.MkdirAll(filepath.Join(tmpDir, filepath.FromSlash(pkg)), 0755); err != nil { return err } dst, err := os.Create(filepath.Join(tmpDir, filepath.FromSlash(pkg), origFilename)) if err != nil { return err } defer dst.Close() origPath := filepath.Join(origDir, origFilename) defer func() { replaces[origPath] = dst.Name() }() switch modType { case modTypeReplace: if _, err := io.Copy(dst, src); err != nil { return err } case modTypeAppend: orig, err := os.Open(origPath) if err != nil { return err } defer orig.Close() if _, err := io.Copy(dst, io.MultiReader(orig, src)); err != nil { return err } case modTypePatch: orig, err := os.Open(origPath) if err != nil { return err } defer orig.Close() p, err := parsePatch(entryPath, src) if err != nil { return err } patched, err := p.apply(orig) if err != nil { return err } if _, err := io.Copy(dst, patched); err != nil { return err } default: return fmt.Errorf("hitsumabushi: unexpected modType: %s", modType) } return nil }); err != nil { return nil, err } switch cfg.os { case "linux": // Replace the arguments. { var strs []string for _, arg := range cfg.args { strs = append(strs, fmt.Sprintf(`%q`, arg)) } argvDef := "var __argv = [...]string{" + strings.Join(strs, ", ") + "}" old := `func goargs() { if GOOS == "windows" { return } argslice = make([]string, argc) for i := int32(0); i < argc; i++ { argslice[i] = gostringnocopy(argv_index(argv, i)) } }` new := fmt.Sprintf(`%s func goargs() { if GOOS == "windows" { return } argslice = make([]string, %[2]d) if len(argslice) == 0 { // os.Executable is not available here. Give a dummy name. argslice = []string{"hitsumabushi_app"} } else { for i := int32(0); i < %[2]d; i++ { argslice[i] = __argv[i] } } }`, argvDef, len(cfg.args)) if err := replace(tmpDir, replaces, "runtime", "runtime1.go", old, new, cfg.os); err != nil { return nil, err } } { old := `var physPageSize uintptr` new := fmt.Sprintf(`var physPageSize uintptr = %d`, cfg.pageSize) if err := replace(tmpDir, replaces, "runtime", "malloc.go", old, new, cfg.os); err != nil { return nil, err } } case "windows": // Replace the arguments. { var strs []string for _, arg := range cfg.args { strs = append(strs, fmt.Sprintf(`%q`, arg)) } argvDef := "var __argv = []string{" + strings.Join(strs, ", ") + "}" // It is hard to emulate GetCommandLine exactly. // See http://daviddeley.com/autohotkey/parameters/parameters.htm#WINARGV // Initialize os.Args directly instead. old := `func init() { cmd := windows.UTF16PtrToString(syscall.GetCommandLine()) if len(cmd) == 0 { arg0, _ := Executable() Args = []string{arg0} } else { Args = commandLineToArgv(cmd) } }` new := fmt.Sprintf(`%s func init() { if len(__argv) == 0 { arg0, _ := Executable() __argv = []string{arg0} } Args = __argv }`, argvDef) if err := replace(tmpDir, replaces, "os", "exec_windows.go", old, new, cfg.os); err != nil { return nil, err } major, minor := goMajorMinorVersion() if major != 1 { return nil, fmt.Errorf("hitsumabushi: unexpected major version: %d", major) } if minor >= 23 { if err := replace(tmpDir, replaces, "os", "exec_windows.go", `import ( "errors" "internal/syscall/windows" "runtime" "syscall" "time" )`, `import ( "errors" "runtime" "syscall" "time" )`, cfg.os); err != nil { return nil, err } } else { if err := replace(tmpDir, replaces, "os", "exec_windows.go", `import ( "errors" "internal/syscall/windows" "runtime" "sync/atomic" "syscall" "time" )`, `import ( "errors" "runtime" "sync/atomic" "syscall" "time" )`, cfg.os); err != nil { return nil, err } } } // Replace loaded DLLs if len(cfg.replaceDLLs) > 0 { var old string _, minor := goMajorMinorVersion() if minor <= 22 { old = "func syscall_SyscallN(trap uintptr, args ...uintptr) (r1, r2, err uintptr) {" } else if minor <= 25 { old = "func syscall_SyscallN(fn uintptr, args ...uintptr) (r1, r2, err uintptr) {" } else { old = "func syscall_syscalln(fn, n uintptr, args ...uintptr) (r1, r2, err uintptr) {" } new := `func _toLower(x uint16) uint16 { if 'A' <= x && x <= 'Z' { return x - 'A' + 'a' } return x } func _areUTF16StringsSame(a *uint16, b *uint16) bool { for _toLower(*a) == _toLower(*b) { a = (*uint16)(unsafe.Add(unsafe.Pointer(a), 2)) b = (*uint16)(unsafe.Add(unsafe.Pointer(b), 2)) if *a == 0 || *b == 0 { return *a == 0 && *b == 0 } } return false } var _replacingDLLFroms = [][]uint16{ {{.Froms}} } var _replacingDLLTos = [][]uint16{ {{.Tos}} } ` if minor <= 22 { new += ` func syscall_SyscallN(trap uintptr, args ...uintptr) (r1, r2, err uintptr) { if trap == getLoadLibrary() || trap == getLoadLibraryEx() { for i, from := range _replacingDLLFroms { if _areUTF16StringsSame((*uint16)(unsafe.Pointer(args[0])), &from[0]) { args[0] = uintptr(unsafe.Pointer(&_replacingDLLTos[i][0])) break } } }` } else if minor <= 25 { new += ` func syscall_SyscallN(fn uintptr, args ...uintptr) (r1, r2, err uintptr) { if fn == uintptr(unsafe.Pointer(_LoadLibraryW)) || fn == uintptr(unsafe.Pointer(_LoadLibraryExW)) { for i, from := range _replacingDLLFroms { if _areUTF16StringsSame((*uint16)(unsafe.Pointer(args[0])), &from[0]) { args[0] = uintptr(unsafe.Pointer(&_replacingDLLTos[i][0])) break } } }` } else { new += ` func syscall_syscalln(fn, n uintptr, args ...uintptr) (r1, r2, err uintptr) { if fn == uintptr(unsafe.Pointer(_LoadLibraryW)) || fn == uintptr(unsafe.Pointer(_LoadLibraryExW)) { for i, from := range _replacingDLLFroms { if _areUTF16StringsSame((*uint16)(unsafe.Pointer(args[0])), &from[0]) { args[0] = uintptr(unsafe.Pointer(&_replacingDLLTos[i][0])) break } } }` } var froms []string var tos []string for _, replace := range cfg.replaceDLLs { from, err := utf16FromString(replace.from) if err != nil { return nil, err } froms = append(froms, fmt.Sprintf("%#v,", from)) to, err := utf16FromString(replace.to) if err != nil { return nil, err } tos = append(tos, fmt.Sprintf("%#v,", to)) } new = strings.ReplaceAll(new, "{{.Froms}}", strings.Join(froms, "\n\t")) new = strings.ReplaceAll(new, "{{.Tos}}", strings.Join(tos, "\n\t")) if err := replace(tmpDir, replaces, "runtime", "syscall_windows.go", old, new, cfg.os); err != nil { return nil, err } } } // Add importing "runtime/cgo" for testing packages. for _, pkg := range cfg.testPkgs { origPath, err := goExternalTestFile(pkg) if err != nil { return nil, err } pkgName, err := goPkgName(pkg) if err != nil { return nil, err } // Read the source before opening the destination. // The destination might be the same as the source. srcPath := origPath if p, ok := replaces[origPath]; ok { srcPath = p } srcContent, err := os.ReadFile(srcPath) if err != nil { return nil, err } if err := os.MkdirAll(filepath.Join(tmpDir, filepath.FromSlash(pkg)), 0755); err != nil { return nil, err } dst, err := os.Create(filepath.Join(tmpDir, filepath.FromSlash(pkg), filepath.Base(origPath))) if err != nil { return nil, err } defer dst.Close() // This assumes that there is an external test package. old := "package " + pkgName + "_test" new := old + "\n\n" + `import _ "runtime/cgo"` replaced := strings.Replace(string(srcContent), old, new, 1) if _, err := io.Copy(dst, bytes.NewReader([]byte(replaced))); err != nil { return nil, err } replaces[origPath] = dst.Name() } for _, r := range cfg.overlay { replaces[r.from] = r.to } return json.Marshal(&overlay{Replace: replaces}) } func goPkgDir(pkg string, goos string) (string, error) { var buf bytes.Buffer cmd := exec.Command("go", "list", "-f", "{{.Dir}}", pkg) cmd.Env = append(os.Environ(), "GOOS="+goos) cmd.Stderr = &buf out, err := cmd.Output() if err != nil { return "", fmt.Errorf("hitsumabushi: %v\n%s", err, buf.String()) } return strings.TrimSpace(string(out)), nil } func goExternalTestFile(pkg string) (string, error) { idx := 0 for { var buf bytes.Buffer cmd := exec.Command("go", "list", "-f", "{{.Dir}}"+string(filepath.Separator)+fmt.Sprintf("{{index .XTestGoFiles %d}}", idx), pkg) cmd.Stderr = &buf out, err := cmd.Output() if err != nil { return "", fmt.Errorf("hitsumabushi: %v\n%s\nperhaps this package doesn't have an external test", err, buf.String()) } f := strings.TrimSpace(string(out)) // runtime/callers_test.go is very special and the line number matters. if pkg == "runtime" && filepath.Base(f) == "callers_test.go" { idx++ continue } return f, nil } } func goPkgName(pkg string) (string, error) { var buf bytes.Buffer cmd := exec.Command("go", "list", "-f", "{{.Name}}", pkg) cmd.Stderr = &buf out, err := cmd.Output() if err != nil { return "", fmt.Errorf("hitsumabushi: %v\n%s", err, buf.String()) } return strings.TrimSpace(string(out)), nil } func replace(tmpDir string, replaces map[string]string, pkg string, filename string, old, new string, goos string) error { origDir, err := goPkgDir(pkg, goos) if err != nil { return err } origPath := filepath.Join(origDir, filename) // Read the source before opening the destination. // The destination might be the same as the source. srcPath := origPath if p, ok := replaces[origPath]; ok { srcPath = p } srcContent, err := os.ReadFile(srcPath) if err != nil { return err } if err := os.MkdirAll(filepath.Join(tmpDir, filepath.FromSlash(pkg)), 0755); err != nil { return err } dst, err := os.Create(filepath.Join(tmpDir, filepath.FromSlash(pkg), filepath.Base(origPath))) if err != nil { return err } defer dst.Close() if !strings.Contains(string(srcContent), old) { return fmt.Errorf("hitsumabushi: replacing %s/%s failed: %s", pkg, filename, old) } replaced := strings.Replace(string(srcContent), old, new, 1) if string(srcContent) == replaced { return fmt.Errorf("hitsumabushi: replacing %s/%s failed: replacing result is the same", pkg, filename) } if _, err := io.Copy(dst, bytes.NewReader([]byte(replaced))); err != nil { return err } replaces[origPath] = dst.Name() return nil } func utf16FromString(s string) ([]uint16, error) { if strings.IndexByte(s, 0) != -1 { return nil, fmt.Errorf("hitsumabushi: the given string must not include a NUL character") } // TODO: Use golang.org/x/sys/windows.UTF16FromString, but be careful that this is available only on Windows. // See https://github.com/golang/go/issues/59971 return utf16.Encode([]rune(s + "\x00")), nil } func replacementFilePath(fn, pkg, os, file string) (string, error) { if os != "linux" { return "", fmt.Errorf("hitsumabushi: %s() is not available in this environment: GOOS: %s", fn, os) } tokens := strings.Split(goVersion(), ".") major, err := strconv.Atoi(tokens[0]) if err != nil { return "", err } minor, err := strconv.Atoi(tokens[1]) if err != nil { return "", err } if major == 1 && minor < 19 { return "", fmt.Errorf("hitsumabushi: %s() is not available in this environment: Go version: %s", fn, runtime.Version()) } dir, err := goPkgDir(pkg, os) if err != nil { return "", err } return filepath.Join(dir, file), nil } // ClockFilePath returns a C file's path for the clock functions. // This file works only when linux is specified as the GOOS option. // // The file includes this function: // // - int hitsumabushi_clock_gettime(clockid_t clk_id, struct timespec *tp) // // The default implementation calls clock_gettime. func ClockFilePath(os string) (string, error) { return replacementFilePath("ClockFilePath", "runtime/cgo", os, "hitsumabushi_clock_"+os+".c") } // FutexFilePath returns a C file's path for the futex functions. // This file works only when linux is specified as the GOOS option. // // The file includes this function: // // - int32_t hitsumabushi_futex(uint32_t *uaddr, int32_t futex_op, uint32_t val, const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3) // // The default implementation is a pseudo futex by pthread. func FutexFilePath(os string) (string, error) { return replacementFilePath("FutexFilePath", "runtime/cgo", os, "hitsumabushi_futex_"+os+".c") } // FilesystemFilePath returns a C file's path for the filesystem functions. // This file works only when linux is specified as the GOOS option. // // The file includes these functions: // // - int32_t hitsumabushi_closefd(int32_t fd) // - int32_t hitsumabushi_open(char *name, int32_t mode, int32_t perm) // - int32_t hitsumabushi_read(int32_t fd, void *p, int32_t n) // - int32_t hitsumabushi_write1(uintptr_t fd, void *p, int32_t n) // - int32_t hitsumabushi_lseek(uintptr_t fd, off_t offset, int32_t whence) // - int32_t hitsumabushi_fcntl(int32_t fd, int32_t cmd, int32_t arg) // - int32_t hitsumabushi_fstat(int32_t fd, struct stat *stat) // - int32_t hitsumabushi_renameat(int32_t fd1, char* name1, int32_t fd2, char* name2) // - int32_t hitsumabushi_fstatat(int32_t fd, char* name, struct stat* p, int32_t flags) // // The default implementation only handles stdout, stderr, and some pseudo-files. func FilesystemFilePath(os string) (string, error) { return replacementFilePath("FilesystemFilePath", "runtime/cgo", os, "hitsumabushi_filesystem_"+os+".c") } // MemoryFilePath returns a C file's path for the memory functions. // This file works only when linux is specified as the GOOS option. // // The file includes these functions: // // - void* hitsumabushi_sysAllocOS(uintptr_t n) // - void hitsumabushi_sysUnusedOS(void* v, uintptr_t n) // - void hitsumabushi_sysUsedOS(void* v, uintptr_t n) // - void hitsumabushi_sysHugePageOS(void* v, uintptr_t n) // - void hitsumabushi_sysFreeOS(void* v, uintptr_t n) // - void hitsumabushi_sysFaultOS(void* v, uintptr_t n) // - void* hitsumabushi_sysReserveOS(void* v, uintptr_t n) // - void hitsumabushi_sysMapOS(void* v, uintptr_t n) // // The default implementation is a pseudo allocation by calloc without free. // // For the implementation details, see https://cs.opensource.google/go/go/+/master:src/runtime/mem.go . // // Note that allocated memory address must be aligned to 1 << 9 bytes as of Go 1.25. func MemoryFilePath(os string) (string, error) { return replacementFilePath("MemoryFilePath", "runtime/cgo", os, "hitsumabushi_mem_"+os+".c") } // CPUFilePath returns a C file's path for the CPU functions. // This file works only when linux is specified as the GOOS option. // // The file includes this function: // // - int32_t hitsumabushi_getproccount() // // The default implementation uses 1. func CPUFilePath(os string) (string, error) { return replacementFilePath("CPUFilePath", "runtime/cgo", os, "hitsumabushi_cpu_"+os+".c") } func ThreadFilePath(os string) (string, error) { return replacementFilePath("ThreadFilePath", "runtime/cgo", os, "hitsumabushi_thread_"+os+".c") } ================================================ FILE: patch.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2021 Hajime Hoshi package hitsumabushi import ( "bufio" "bytes" "fmt" "io" "strings" ) type patch struct { name string replaces map[string]string append string } func parsePatch(name string, r io.Reader) (*patch, error) { p := &patch{ name: name, replaces: map[string]string{}, } var from string var to string const ( phaseInit = iota phaseFrom phaseTo phaseAppend ) var phase int s := bufio.NewScanner(r) var i int for s.Scan() { switch line := s.Text(); line { case "//--from": if phase == phaseFrom { return nil, fmt.Errorf("unexpected //--from at %s:L%d", p.name, i) } if phase != phaseInit { p.replaces[from] = to from = "" to = "" } phase = phaseFrom case "//--to": if phase != phaseFrom { return nil, fmt.Errorf("unexpected //--to at %s:L%d", p.name, i) } phase = phaseTo case "//--append": if phase == phaseFrom { return nil, fmt.Errorf("unexpected //--append at %s:L%d", p.name, i) } if phase != phaseInit { p.replaces[from] = to from = "" to = "" } phase = phaseAppend default: switch phase { case phaseInit: return nil, fmt.Errorf("unexpected content at %s:L%d", p.name, i) case phaseFrom: from += line + "\n" case phaseTo: to += line + "\n" case phaseAppend: p.append += line + "\n" } } i++ } if from != "" { p.replaces[from] = to } return p, nil } func (p *patch) apply(r io.Reader) (io.Reader, error) { buf, err := io.ReadAll(r) if err != nil { return nil, err } str := string(buf) for from, to := range p.replaces { if !strings.Contains(str, from) { return nil, fmt.Errorf("hitsumabushi: patching %s failed: %s", p.name, from[:strings.IndexByte(from, '\n')]) } old := str new := strings.Replace(old, from, to, 1) if old == new { return nil, fmt.Errorf("hitsumabushi: patching %s failed: replacing result is the same", p.name) } str = new } str += p.append return bytes.NewBufferString(str), nil } ================================================ FILE: test.go ================================================ // SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2021 Hajime Hoshi //go:build ignore package main import ( "flag" "fmt" "os" "os/exec" "path/filepath" "runtime" "strings" "github.com/hajimehoshi/hitsumabushi" ) var ( flagArgs = flag.String("args", "", "arguments") flagQEMU = flag.Bool("qemu", false, "use QEMU") ) func main() { flag.Parse() if err := run(); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } } func run() error { args, err := splitArgs(*flagArgs) if err != nil { return err } path, err := createJSON(args) if err != nil { return err } if err := buildTestBinary(path, args); err != nil { return err } dir, err := pkgDir(args[len(args)-1]) if err != nil { return err } if err := runTestBinary(dir); err != nil { return err } return nil } func createJSON(args []string) (string, error) { args = append([]string{"hitsumabushi_program"}, args...) options := []hitsumabushi.Option{ hitsumabushi.Args(args...), hitsumabushi.TestPkg(args[len(args)-1]), } if runtime.GOOS == "windows" { // TODO: Test with a real DLL. options = append(options, hitsumabushi.ReplaceDLL("foofoo.dll", "barbar.dll")) } overlayJSON, err := hitsumabushi.GenOverlayJSON(options...) if err != nil { return "", err } f, err := os.CreateTemp("", "*.json") if err != nil { return "", err } defer f.Close() if _, err := f.Write(overlayJSON); err != nil { return "", err } return f.Name(), nil } func buildTestBinary(jsonPath string, args []string) error { // Create a temporary working directory to use a fixed Go version for go.mod. // go.mod's Go version matters as this might change some Go's behavior (e.g. runtime.TestPanicNil). tmp, err := os.MkdirTemp("", "hitsumabushi-*") if err != nil { return err } defer os.RemoveAll(tmp) cmd := exec.Command("go", "mod", "init", "hitsumabushitest") cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.Dir = tmp if err := cmd.Run(); err != nil { return err } wd, err := os.Getwd() if err != nil { return err } bin := filepath.Join(wd, "test") if runtime.GOOS == "windows" { bin += ".exe" } cmd = exec.Command("go", "test", "-c", "-vet=off", "-overlay="+jsonPath, "-o="+bin) cmd.Args = append(cmd.Args, args...) cmd.Env = append(os.Environ(), "CGO_ENABLED=1", "CGO_CFLAGS=-fno-common -fno-short-enums -ffunction-sections -fdata-sections -fPIC -g -O3") if *flagQEMU { cmd.Env = append(cmd.Env, "CC=aarch64-linux-gnu-gcc") } cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.Dir = tmp if err := cmd.Run(); err != nil { return err } return nil } func runTestBinary(dir string) error { binFilename := "test" if runtime.GOOS == "windows" { binFilename += ".exe" } bin, err := filepath.Abs(binFilename) if err != nil { return err } var cmd *exec.Cmd if *flagQEMU { cmd = exec.Command("qemu-aarch64", bin) cmd.Env = append(os.Environ(), "QEMU_LD_PREFIX=/usr/aarch64-linux-gnu") } else { cmd = exec.Command(bin) } cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.Dir = dir if err := cmd.Run(); err != nil { return err } return nil } func isSpaceByte(c byte) bool { return c == ' ' || c == '\t' || c == '\n' || c == '\r' } func splitArgs(s string) ([]string, error) { // Copied from cmd/internal/quoted/quoted.go // Split fields allowing '' or "" around elements. // Quotes further inside the string do not count. var f []string for len(s) > 0 { for len(s) > 0 && isSpaceByte(s[0]) { s = s[1:] } if len(s) == 0 { break } // Accepted quoted string. No unescaping inside. if s[0] == '"' || s[0] == '\'' { quote := s[0] s = s[1:] i := 0 for i < len(s) && s[i] != quote { i++ } if i >= len(s) { return nil, fmt.Errorf("unterminated %c string", quote) } f = append(f, s[:i]) s = s[i+1:] continue } i := 0 for i < len(s) && !isSpaceByte(s[i]) { i++ } f = append(f, s[:i]) s = s[i:] } return f, nil } func pkgDir(pkg string) (string, error) { cmd := exec.Command("go", "list", "-f", "{{.Dir}}", pkg) out, err := cmd.Output() if err != nil { return "", err } return strings.TrimSpace(string(out)), nil }