已开启
Sw64: Add sw64 architecture support. #563
lc-compiler创建于 2025年11月14日
Sw64: Add sw64 architecture support. #563
已开启
从refs/pull/563/head合入到openEuler-24.03-LTS-SP1
共 17 个文件变更+47988-4
| @@ -0,0 +1,203 @@ | |||
| 1 | +From 0c4c471bfb0ce547bad0ba3bf25b66a73014cd38 Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: swcompiler <lc@wxiat.com> | ||
| 3 | +Date: Fri, 21 Feb 2025 14:19:21 +0800 | ||
| 4 | +Subject: [PATCH 04/16] cmd/asm: Add sw64 port | ||
| 5 | + | ||
| 6 | +--- | ||
| 7 | + src/cmd/asm/internal/arch/arch.go | 2 + | ||
| 8 | + src/cmd/asm/internal/arch/sw64.go | 95 ++++++++++++++++++++++++ | ||
| 9 | + src/cmd/asm/internal/asm/asm.go | 20 +++++ | ||
| 10 | + src/cmd/asm/internal/asm/testdata/sw64.s | 21 ++++++ | ||
| 11 | + 4 files changed, 138 insertions(+) | ||
| 12 | + create mode 100644 src/cmd/asm/internal/arch/sw64.go | ||
| 13 | + create mode 100644 src/cmd/asm/internal/asm/testdata/sw64.s | ||
| 14 | + | ||
| 15 | +diff --git a/src/cmd/asm/internal/arch/arch.go b/src/cmd/asm/internal/arch/arch.go | ||
| 16 | +index 11bb7af..ee22016 100644 | ||
| 17 | +--- a/src/cmd/asm/internal/arch/arch.go | ||
| 18 | ++++ b/src/cmd/asm/internal/arch/arch.go | ||
| 19 | +@@ -81,6 +81,8 @@ func Set(GOARCH string, shared bool) *Arch { | ||
| 20 | + return archS390x() | ||
| 21 | + case "wasm": | ||
| 22 | + return archWasm() | ||
| 23 | ++ case "sw64": | ||
| 24 | ++ return archSW64() | ||
| 25 | + } | ||
| 26 | + return nil | ||
| 27 | + } | ||
| 28 | +diff --git a/src/cmd/asm/internal/arch/sw64.go b/src/cmd/asm/internal/arch/sw64.go | ||
| 29 | +new file mode 100644 | ||
| 30 | +index 0000000..3857b4e | ||
| 31 | +--- /dev/null | ||
| 32 | ++++ b/src/cmd/asm/internal/arch/sw64.go | ||
| 33 | +@@ -0,0 +1,95 @@ | ||
| 34 | ++// Copyright 2018 The Go Authors. All rights reserved. | ||
| 35 | ++// Use of this source code is governed by a BSD-style | ||
| 36 | ++// license that can be found in the LICENSE file. | ||
| 37 | ++ | ||
| 38 | ++// This file encapsulates some of the odd characteristics of the | ||
| 39 | ++// sw64 instruction set, to minimize its interaction | ||
| 40 | ++// with the core of the assembler. | ||
| 41 | ++ | ||
| 42 | ++package arch | ||
| 43 | ++ | ||
| 44 | ++import ( | ||
| 45 | ++ "cmd/internal/obj" | ||
| 46 | ++ "cmd/internal/obj/sw64" | ||
| 47 | ++ "fmt" | ||
| 48 | ++) | ||
| 49 | ++ | ||
| 50 | ++func jumpSW64(word string) bool { | ||
| 51 | ++ switch word { | ||
| 52 | ++ case "CALL", "JMP", | ||
| 53 | ++ "BR", "BSR", | ||
| 54 | ++ "BEQ", "BNE", "BLT", "BLE", "BGT", "BGE", | ||
| 55 | ++ "BLBC", "BLBS", "FBEQ", "FBNE", "FBLT", | ||
| 56 | ++ "FBGT", "FBGE": | ||
| 57 | ++ return true | ||
| 58 | ++ } | ||
| 59 | ++ return false | ||
| 60 | ++} | ||
| 61 | ++ | ||
| 62 | ++func sw64RegisterNumber(name string, n int16) (int16, bool) { | ||
| 63 | ++ //snyh_TODO: update by cmd/internal/obj/sw64/a.out.go | ||
| 64 | ++ switch name { | ||
| 65 | ++ case "R": | ||
| 66 | ++ if 0 <= n && n <= 32 { | ||
| 67 | ++ return sw64.REG_R0 + n, true | ||
| 68 | ++ } | ||
| 69 | ++ case "F": | ||
| 70 | ++ if 0 <= n && n <= 32 { | ||
| 71 | ++ return sw64.REG_F0 + n, true | ||
| 72 | ++ } | ||
| 73 | ++ case "V": | ||
| 74 | ++ if 0 <= n && n <= 32 { | ||
| 75 | ++ return sw64.REG_V0 + n, true | ||
| 76 | ++ } | ||
| 77 | ++ } | ||
| 78 | ++ return 0, false | ||
| 79 | ++} | ||
| 80 | ++ | ||
| 81 | ++func archSW64() *Arch { | ||
| 82 | ++ register := make(map[string]int16) | ||
| 83 | ++ for i := sw64.REG_R0; i <= sw64.REG_R31; i++ { | ||
| 84 | ++ register[obj.Rconv(i)] = int16(i) | ||
| 85 | ++ } | ||
| 86 | ++ for i := sw64.REG_R0; i <= sw64.REG_R31; i++ { | ||
| 87 | ++ register[fmt.Sprintf("R%d", i-sw64.REG_R0)] = int16(i) | ||
| 88 | ++ } | ||
| 89 | ++ for i := sw64.REG_F0; i <= sw64.REG_F31; i++ { | ||
| 90 | ++ register[obj.Rconv(i)] = int16(i) | ||
| 91 | ++ } | ||
| 92 | ++ for i := sw64.REG_V0; i <= sw64.REG_V31; i++ { | ||
| 93 | ++ register[obj.Rconv(i)] = int16(i) | ||
| 94 | ++ } | ||
| 95 | ++ | ||
| 96 | ++ // Pseudo-registers. | ||
| 97 | ++ register["SB"] = RSB | ||
| 98 | ++ register["FP"] = RFP | ||
| 99 | ++ register["PC"] = RPC | ||
| 100 | ++ | ||
| 101 | ++ registerPrefix := map[string]bool{ | ||
| 102 | ++ "T": true, | ||
| 103 | ++ "S": true, | ||
| 104 | ++ "A": true, | ||
| 105 | ++ "F": true, | ||
| 106 | ++ "R": true, | ||
| 107 | ++ "V": true, | ||
| 108 | ++ } | ||
| 109 | ++ | ||
| 110 | ++ instructions := make(map[string]obj.As) | ||
| 111 | ++ for i, s := range obj.Anames { | ||
| 112 | ++ instructions[s] = obj.As(i) | ||
| 113 | ++ } | ||
| 114 | ++ for i, s := range sw64.Anames { | ||
| 115 | ++ if obj.As(i) >= obj.A_ARCHSPECIFIC { | ||
| 116 | ++ instructions[s] = obj.As(i) + obj.ABaseSW64 | ||
| 117 | ++ } | ||
| 118 | ++ } | ||
| 119 | ++ | ||
| 120 | ++ return &Arch{ | ||
| 121 | ++ LinkArch: &sw64.LinkSW64, | ||
| 122 | ++ Instructions: instructions, | ||
| 123 | ++ Register: register, | ||
| 124 | ++ RegisterPrefix: registerPrefix, | ||
| 125 | ++ RegisterNumber: sw64RegisterNumber, | ||
| 126 | ++ IsJump: jumpSW64, | ||
| 127 | ++ } | ||
| 128 | ++} | ||
| 129 | +diff --git a/src/cmd/asm/internal/asm/asm.go b/src/cmd/asm/internal/asm/asm.go | ||
| 130 | +index 563e794..2b41934 100644 | ||
| 131 | +--- a/src/cmd/asm/internal/asm/asm.go | ||
| 132 | ++++ b/src/cmd/asm/internal/asm/asm.go | ||
| 133 | +@@ -557,6 +557,9 @@ func (p *Parser) asmJump(op obj.As, cond string, a []obj.Addr) { | ||
| 134 | + case target.Type == obj.TYPE_CONST: | ||
| 135 | + // JMP $4 | ||
| 136 | + *targetAddr = a[0] | ||
| 137 | ++ if p.arch.Family == sys.SW64 { | ||
| 138 | ++ *targetAddr = a[1] | ||
| 139 | ++ } | ||
| 140 | + case target.Type == obj.TYPE_NONE: | ||
| 141 | + // JMP | ||
| 142 | + default: | ||
| 143 | +@@ -774,6 +777,17 @@ func (p *Parser) asmInstruction(op obj.As, cond string, a []obj.Addr) { | ||
| 144 | + prog.AddRestSource(a[1]) | ||
| 145 | + } | ||
| 146 | + prog.To = a[2] | ||
| 147 | ++ case sys.SW64: | ||
| 148 | ++ prog.From = a[0] | ||
| 149 | ++ | ||
| 150 | ++ if a[1].Type == obj.TYPE_REG { | ||
| 151 | ++ prog.Reg = p.getRegister(prog, op, &a[1]) | ||
| 152 | ++ } else { | ||
| 153 | ++ prog.AddRestSourceArgs([]obj.Addr{a[1]}) | ||
| 154 | ++ } | ||
| 155 | ++ | ||
| 156 | ++ prog.To = a[2] | ||
| 157 | ++ | ||
| 158 | + default: | ||
| 159 | + p.errorf("TODO: implement three-operand instructions for this architecture") | ||
| 160 | + return | ||
| 161 | +@@ -808,6 +822,12 @@ func (p *Parser) asmInstruction(op obj.As, cond string, a []obj.Addr) { | ||
| 162 | + prog.To = a[3] | ||
| 163 | + break | ||
| 164 | + } | ||
| 165 | ++ if p.arch.Family == sys.SW64 { | ||
| 166 | ++ prog.From = a[0] | ||
| 167 | ++ prog.AddRestSourceArgs([]obj.Addr{a[1], a[2]}) | ||
| 168 | ++ prog.To = a[3] | ||
| 169 | ++ break | ||
| 170 | ++ } | ||
| 171 | + if p.arch.Family == sys.ARM64 { | ||
| 172 | + prog.From = a[0] | ||
| 173 | + prog.Reg = p.getRegister(prog, op, &a[1]) | ||
| 174 | +diff --git a/src/cmd/asm/internal/asm/testdata/sw64.s b/src/cmd/asm/internal/asm/testdata/sw64.s | ||
| 175 | +new file mode 100644 | ||
| 176 | +index 0000000..0ce5473 | ||
| 177 | +--- /dev/null | ||
| 178 | ++++ b/src/cmd/asm/internal/asm/testdata/sw64.s | ||
| 179 | +@@ -0,0 +1,21 @@ | ||
| 180 | ++#include "../../../../../runtime/textflag.h" | ||
| 181 | ++TEXT foo(SB), NOSPLIT, $0 | ||
| 182 | ++ ADDW R17, $0x4d, R0 //00 a0 29 4a | ||
| 183 | ++ S4ADDW R17, R3, R1 // 41 00 23 42 | ||
| 184 | ++ S4SUBL R3, R9, R11 // 6b 01 69 40 | ||
| 185 | ++ S8SUBL R3, $0, R11 // 6b 01 60 48 | ||
| 186 | ++ STB R3, 4(R0) // 04 00 60 a0 | ||
| 187 | ++ SYS_CALL $1 // 01 00 00 02 | ||
| 188 | ++ BSR R2, $52 // 0d 00 40 14 | ||
| 189 | ++ DIVW R1, R2, R3 | ||
| 190 | ++ UDIVW R1, R2, R3 | ||
| 191 | ++ REMW R1, R2, R3 | ||
| 192 | ++ UREMW R1, R2, R3 | ||
| 193 | ++ DIVL R1, R2, R3 | ||
| 194 | ++ UDIVL R1, R2, R3 | ||
| 195 | ++ REML R1, R2, R3 | ||
| 196 | ++ UREML R1, R2, R3 | ||
| 197 | ++ ADDPI $_rt0_sw64_lib_go(SB), R1 | ||
| 198 | ++ ADDPIS $_rt0_sw64_lib_go(SB), R1 | ||
| 199 | ++ SBT R1, R2, R3 | ||
| 200 | ++ CBT R1, R2, R3 | ||
| 201 | +-- | ||
| 202 | +2.33.0 | ||
| 203 | + | ||
| @@ -0,0 +1,242 @@ | |||
| 1 | +From b98255ffabb1b52bf4a8f94de2a602e87a5e4708 Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: swcompiler <lc@wxiat.com> | ||
| 3 | +Date: Fri, 21 Feb 2025 14:29:17 +0800 | ||
| 4 | +Subject: [PATCH 07/16] cmd/dist: Add sw64 port | ||
| 5 | + | ||
| 6 | +--- | ||
| 7 | + src/cmd/dist/build.go | 15 ++++++++++++++- | ||
| 8 | + src/cmd/dist/buildruntime.go | 1 + | ||
| 9 | + src/cmd/dist/main.go | 8 ++++++++ | ||
| 10 | + src/cmd/dist/test.go | 8 ++++---- | ||
| 11 | + src/cmd/dist/udiv_default.s | 10 ++++++++++ | ||
| 12 | + src/cmd/dist/udiv_sw64.s | 12 ++++++++++++ | ||
| 13 | + src/cmd/dist/util.go | 17 +++++++++++++++++ | ||
| 14 | + src/cmd/dist/util_gc.go | 5 +++++ | ||
| 15 | + 8 files changed, 71 insertions(+), 5 deletions(-) | ||
| 16 | + create mode 100644 src/cmd/dist/udiv_default.s | ||
| 17 | + create mode 100644 src/cmd/dist/udiv_sw64.s | ||
| 18 | + | ||
| 19 | +diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go | ||
| 20 | +index 8973a87..969398f 100644 | ||
| 21 | +--- a/src/cmd/dist/build.go | ||
| 22 | ++++ b/src/cmd/dist/build.go | ||
| 23 | +@@ -38,6 +38,7 @@ var ( | ||
| 24 | + gomips string | ||
| 25 | + gomips64 string | ||
| 26 | + goppc64 string | ||
| 27 | ++ gosw64 string | ||
| 28 | + goroot string | ||
| 29 | + goroot_final string | ||
| 30 | + goextlinkenabled string | ||
| 31 | +@@ -79,6 +80,7 @@ var okgoarch = []string{ | ||
| 32 | + "s390x", | ||
| 33 | + "sparc64", | ||
| 34 | + "wasm", | ||
| 35 | ++ "sw64", | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + // The known operating systems. | ||
| 39 | +@@ -177,6 +179,12 @@ func xinit() { | ||
| 40 | + } | ||
| 41 | + goppc64 = b | ||
| 42 | + | ||
| 43 | ++ b = os.Getenv("GOSW64") | ||
| 44 | ++ if b == "" { | ||
| 45 | ++ b = xgetgosw64() | ||
| 46 | ++ } | ||
| 47 | ++ gosw64 = b | ||
| 48 | ++ | ||
| 49 | + if p := pathf("%s/src/all.bash", goroot); !isfile(p) { | ||
| 50 | + fatalf("$GOROOT is not set correctly or not exported\n"+ | ||
| 51 | + "\tGOROOT=%s\n"+ | ||
| 52 | +@@ -236,6 +244,7 @@ func xinit() { | ||
| 53 | + os.Setenv("GOMIPS", gomips) | ||
| 54 | + os.Setenv("GOMIPS64", gomips64) | ||
| 55 | + os.Setenv("GOPPC64", goppc64) | ||
| 56 | ++ os.Setenv("GOSW64", gosw64) | ||
| 57 | + os.Setenv("GOROOT", goroot) | ||
| 58 | + os.Setenv("GOROOT_FINAL", goroot_final) | ||
| 59 | + | ||
| 60 | +@@ -578,7 +587,7 @@ func mustLinkExternal(goos, goarch string, cgoEnabled bool) bool { | ||
| 61 | + switch goarch { | ||
| 62 | + case "loong64", | ||
| 63 | + "mips", "mipsle", "mips64", "mips64le", | ||
| 64 | +- "riscv64": | ||
| 65 | ++ "riscv64", "sw64": | ||
| 66 | + // Internally linking cgo is incomplete on some architectures. | ||
| 67 | + // https://golang.org/issue/14449 | ||
| 68 | + return true | ||
| 69 | +@@ -1242,6 +1251,9 @@ func cmdenv() { | ||
| 70 | + if goarch == "ppc64" || goarch == "ppc64le" { | ||
| 71 | + xprintf(format, "GOPPC64", goppc64) | ||
| 72 | + } | ||
| 73 | ++ if goarch == "sw64" { | ||
| 74 | ++ xprintf(format, "GOSW64", gosw64) | ||
| 75 | ++ } | ||
| 76 | + xprintf(format, "GOWORK", "off") | ||
| 77 | + | ||
| 78 | + if *path { | ||
| 79 | +@@ -1714,6 +1726,7 @@ var cgoEnabled = map[string]bool{ | ||
| 80 | + "linux/riscv64": true, | ||
| 81 | + "linux/s390x": true, | ||
| 82 | + "linux/sparc64": true, | ||
| 83 | ++ "linux/sw64": true, | ||
| 84 | + "android/386": true, | ||
| 85 | + "android/amd64": true, | ||
| 86 | + "android/arm": true, | ||
| 87 | +diff --git a/src/cmd/dist/buildruntime.go b/src/cmd/dist/buildruntime.go | ||
| 88 | +index 1de78f0..53997ea 100644 | ||
| 89 | +--- a/src/cmd/dist/buildruntime.go | ||
| 90 | ++++ b/src/cmd/dist/buildruntime.go | ||
| 91 | +@@ -57,6 +57,7 @@ func mkbuildcfg(file string) { | ||
| 92 | + fmt.Fprintf(&buf, "const defaultGOMIPS = `%s`\n", gomips) | ||
| 93 | + fmt.Fprintf(&buf, "const defaultGOMIPS64 = `%s`\n", gomips64) | ||
| 94 | + fmt.Fprintf(&buf, "const defaultGOPPC64 = `%s`\n", goppc64) | ||
| 95 | ++ fmt.Fprintf(&buf, "const defaultGOSW64 = `%s`\n", gosw64) | ||
| 96 | + fmt.Fprintf(&buf, "const defaultGOEXPERIMENT = `%s`\n", goexperiment) | ||
| 97 | + fmt.Fprintf(&buf, "const defaultGO_EXTLINK_ENABLED = `%s`\n", goextlinkenabled) | ||
| 98 | + fmt.Fprintf(&buf, "const defaultGO_LDSO = `%s`\n", defaultldso) | ||
| 99 | +diff --git a/src/cmd/dist/main.go b/src/cmd/dist/main.go | ||
| 100 | +index f3425a9..3b687ad 100644 | ||
| 101 | +--- a/src/cmd/dist/main.go | ||
| 102 | ++++ b/src/cmd/dist/main.go | ||
| 103 | +@@ -130,6 +130,8 @@ func main() { | ||
| 104 | + gohostarch = "riscv64" | ||
| 105 | + case strings.Contains(out, "s390x"): | ||
| 106 | + gohostarch = "s390x" | ||
| 107 | ++ case strings.Contains(out, "sw_64"), strings.Contains(out, "sw64"): | ||
| 108 | ++ gohostarch = "sw64" | ||
| 109 | + case gohostos == "darwin", gohostos == "ios": | ||
| 110 | + if strings.Contains(run("", CheckExit, "uname", "-v"), "RELEASE_ARM64_") { | ||
| 111 | + gohostarch = "arm64" | ||
| 112 | +@@ -168,6 +170,12 @@ func main() { | ||
| 113 | + os.Exit(0) | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | ++ if len(os.Args) > 1 && os.Args[1] == "-check-gosw64" { | ||
| 117 | ++ useUIDVv1() // might fail with SIGILL | ||
| 118 | ++ println("UDIVv1 OK.") | ||
| 119 | ++ os.Exit(0) | ||
| 120 | ++ } | ||
| 121 | ++ | ||
| 122 | + xinit() | ||
| 123 | + xmain() | ||
| 124 | + xexit(0) | ||
| 125 | +diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go | ||
| 126 | +index 36a20e8..ddf826e 100644 | ||
| 127 | +--- a/src/cmd/dist/test.go | ||
| 128 | ++++ b/src/cmd/dist/test.go | ||
| 129 | +@@ -1062,7 +1062,7 @@ func (t *tester) internalLink() bool { | ||
| 130 | + // Internally linking cgo is incomplete on some architectures. | ||
| 131 | + // https://golang.org/issue/10373 | ||
| 132 | + // https://golang.org/issue/14449 | ||
| 133 | +- if goarch == "loong64" || goarch == "mips64" || goarch == "mips64le" || goarch == "mips" || goarch == "mipsle" || goarch == "riscv64" { | ||
| 134 | ++ if goarch == "loong64" || goarch == "mips64" || goarch == "mips64le" || goarch == "mips" || goarch == "mipsle" || goarch == "riscv64" || goarch == "sw64" { | ||
| 135 | + return false | ||
| 136 | + } | ||
| 137 | + if goos == "aix" { | ||
| 138 | +@@ -1563,7 +1563,7 @@ func buildModeSupported(compiler, buildmode, goos, goarch string) bool { | ||
| 139 | + return true | ||
| 140 | + case "linux": | ||
| 141 | + switch goarch { | ||
| 142 | +- case "386", "amd64", "arm", "armbe", "arm64", "arm64be", "loong64", "ppc64le", "riscv64", "s390x": | ||
| 143 | ++ case "386", "amd64", "arm", "armbe", "arm64", "arm64be", "loong64", "ppc64le", "riscv64", "s390x", "sw64": | ||
| 144 | + // linux/ppc64 not supported because it does | ||
| 145 | + // not support external linking mode yet. | ||
| 146 | + return true | ||
| 147 | +@@ -1583,7 +1583,7 @@ func buildModeSupported(compiler, buildmode, goos, goarch string) bool { | ||
| 148 | + | ||
| 149 | + case "c-shared": | ||
| 150 | + switch platform { | ||
| 151 | +- case "linux/amd64", "linux/arm", "linux/arm64", "linux/loong64", "linux/386", "linux/ppc64le", "linux/riscv64", "linux/s390x", | ||
| 152 | ++ case "linux/amd64", "linux/arm", "linux/arm64", "linux/loong64", "linux/386", "linux/ppc64le", "linux/riscv64", "linux/s390x", "linux/sw64", | ||
| 153 | + "android/amd64", "android/arm", "android/arm64", "android/386", | ||
| 154 | + "freebsd/amd64", | ||
| 155 | + "darwin/amd64", "darwin/arm64", | ||
| 156 | +@@ -1620,7 +1620,7 @@ func buildModeSupported(compiler, buildmode, goos, goarch string) bool { | ||
| 157 | + | ||
| 158 | + case "plugin": | ||
| 159 | + switch platform { | ||
| 160 | +- case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x", "linux/ppc64le", | ||
| 161 | ++ case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x", "linux/ppc64le", "linux/sw64", | ||
| 162 | + "android/amd64", "android/386", | ||
| 163 | + "darwin/amd64", "darwin/arm64", | ||
| 164 | + "freebsd/amd64": | ||
| 165 | +diff --git a/src/cmd/dist/udiv_default.s b/src/cmd/dist/udiv_default.s | ||
| 166 | +new file mode 100644 | ||
| 167 | +index 0000000..371dcd9 | ||
| 168 | +--- /dev/null | ||
| 169 | ++++ b/src/cmd/dist/udiv_default.s | ||
| 170 | +@@ -0,0 +1,10 @@ | ||
| 171 | ++// Copyright 2015 The Go Authors. All rights reserved. | ||
| 172 | ++// Use of this source code is governed by a BSD-style | ||
| 173 | ++// license that can be found in the LICENSE file. | ||
| 174 | ++ | ||
| 175 | ++// +build !sw64,gc | ||
| 176 | ++ | ||
| 177 | ++#include "textflag.h" | ||
| 178 | ++ | ||
| 179 | ++TEXT ·useUIDVv1(SB),NOSPLIT,$0 | ||
| 180 | ++ RET | ||
| 181 | +diff --git a/src/cmd/dist/udiv_sw64.s b/src/cmd/dist/udiv_sw64.s | ||
| 182 | +new file mode 100644 | ||
| 183 | +index 0000000..8d7155f | ||
| 184 | +--- /dev/null | ||
| 185 | ++++ b/src/cmd/dist/udiv_sw64.s | ||
| 186 | +@@ -0,0 +1,12 @@ | ||
| 187 | ++// Copyright 2015 The Go Authors. All rights reserved. | ||
| 188 | ++// Use of this source code is governed by a BSD-style | ||
| 189 | ++// license that can be found in the LICENSE file. | ||
| 190 | ++ | ||
| 191 | ++// +build sw64,gc | ||
| 192 | ++ | ||
| 193 | ++#include "textflag.h" | ||
| 194 | ++ | ||
| 195 | ++// try to run "vmov.f64 d0, d0" instruction | ||
| 196 | ++TEXT ·useUIDVv1(SB),NOSPLIT,$0 | ||
| 197 | ++ WORD $0x400003E0 // vmov.f64 d0, d0 | ||
| 198 | ++ RET | ||
| 199 | +diff --git a/src/cmd/dist/util.go b/src/cmd/dist/util.go | ||
| 200 | +index 2eeab18..54f467f 100644 | ||
| 201 | +--- a/src/cmd/dist/util.go | ||
| 202 | ++++ b/src/cmd/dist/util.go | ||
| 203 | +@@ -405,6 +405,23 @@ func xgetgoarm() string { | ||
| 204 | + return "7" | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | ++func xgetgosw64() string { | ||
| 208 | ++ if gohostarch != "sw64" || goos != gohostos { | ||
| 209 | ++ // Conservative default for cross-compilation. | ||
| 210 | ++ return "swv3" | ||
| 211 | ++ } | ||
| 212 | ++ // Try to exec ourselves in a mode to detect DIV,REM support. | ||
| 213 | ++ // Seeing how far it gets determines which instructions failed. | ||
| 214 | ++ // The test is OS-agnostic. | ||
| 215 | ++ out := run("", 0, os.Args[0], "-check-gosw64") | ||
| 216 | ++ v1ok := strings.Contains(out, "UDIVv1 OK.") | ||
| 217 | ++ | ||
| 218 | ++ if v1ok { | ||
| 219 | ++ return "swv4" | ||
| 220 | ++ } | ||
| 221 | ++ return "swv3" | ||
| 222 | ++} | ||
| 223 | ++ | ||
| 224 | + func min(a, b int) int { | ||
| 225 | + if a < b { | ||
| 226 | + return a | ||
| 227 | +diff --git a/src/cmd/dist/util_gc.go b/src/cmd/dist/util_gc.go | ||
| 228 | +index 875784d..595e41c 100644 | ||
| 229 | +--- a/src/cmd/dist/util_gc.go | ||
| 230 | ++++ b/src/cmd/dist/util_gc.go | ||
| 231 | +@@ -19,3 +19,8 @@ func useVFPv3() | ||
| 232 | + // It will crash the current process if it doesn't implement | ||
| 233 | + // ARMv6K or above. | ||
| 234 | + func useARMv6K() | ||
| 235 | ++ | ||
| 236 | ++// useUIDVv1 tries to run core4 instructions on SW64. | ||
| 237 | ++// It will crash the current process if it doesn't implement | ||
| 238 | ++// Core4 or above. | ||
| 239 | ++func useUIDVv1() | ||
| 240 | +-- | ||
| 241 | +2.33.0 | ||
| 242 | + | ||
| @@ -0,0 +1,93 @@ | |||
| 1 | +From 9c5b75630ecdec6f3002bff6042378790f63e731 Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: swcompiler <lc@wxiat.com> | ||
| 3 | +Date: Fri, 21 Feb 2025 14:30:30 +0800 | ||
| 4 | +Subject: [PATCH 08/16] cmd/cgo: Add sw64 port | ||
| 5 | + | ||
| 6 | +--- | ||
| 7 | + .../cgo/internal/test/issue9400/asm_sw64.s | 30 +++++++++++++++++++ | ||
| 8 | + .../cgo/internal/testsanitizers/cc_test.go | 4 +++ | ||
| 9 | + src/cmd/cgo/main.go | 2 ++ | ||
| 10 | + 3 files changed, 36 insertions(+) | ||
| 11 | + create mode 100644 src/cmd/cgo/internal/test/issue9400/asm_sw64.s | ||
| 12 | + | ||
| 13 | +diff --git a/src/cmd/cgo/internal/test/issue9400/asm_sw64.s b/src/cmd/cgo/internal/test/issue9400/asm_sw64.s | ||
| 14 | +new file mode 100644 | ||
| 15 | +index 0000000..05eab55 | ||
| 16 | +--- /dev/null | ||
| 17 | ++++ b/src/cmd/cgo/internal/test/issue9400/asm_sw64.s | ||
| 18 | +@@ -0,0 +1,30 @@ | ||
| 19 | ++// Copyright 2016 The Go Authors. All rights reserved. | ||
| 20 | ++// Use of this source code is governed by a BSD-style | ||
| 21 | ++// license that can be found in the LICENSE file. | ||
| 22 | ++ | ||
| 23 | ++// +build sw64 | ||
| 24 | ++// +build !gccgo | ||
| 25 | ++ | ||
| 26 | ++#include "textflag.h" | ||
| 27 | ++ | ||
| 28 | ++TEXT ·RewindAndSetgid(SB), NOSPLIT|NOFRAME, $0-0 | ||
| 29 | ++ // Rewind stack pointer so anything that happens on the stack | ||
| 30 | ++ // will clobber the test pattern created by the caller | ||
| 31 | ++ LDI SP, $(1024*8)(SP) | ||
| 32 | ++ | ||
| 33 | ++ // Ask signaller to setgid | ||
| 34 | ++ LDI R1, $1 | ||
| 35 | ++ MEMB | ||
| 36 | ++ STW R1, ·Baton(SB) | ||
| 37 | ++ MEMB | ||
| 38 | ++ | ||
| 39 | ++ // Wait for setgid completion | ||
| 40 | ++loop: | ||
| 41 | ++ MEMB | ||
| 42 | ++ LDW R1, ·Baton(SB) | ||
| 43 | ++ NOOP // hint that we're in a spin loop | ||
| 44 | ++ BNE R1, loop | ||
| 45 | ++ MEMB | ||
| 46 | ++ | ||
| 47 | ++ LDI SP, $-(1024*8)(SP) | ||
| 48 | ++ RET | ||
| 49 | +diff --git a/src/cmd/cgo/internal/testsanitizers/cc_test.go b/src/cmd/cgo/internal/testsanitizers/cc_test.go | ||
| 50 | +index 6eb5a64..1041838 100644 | ||
| 51 | +--- a/src/cmd/cgo/internal/testsanitizers/cc_test.go | ||
| 52 | ++++ b/src/cmd/cgo/internal/testsanitizers/cc_test.go | ||
| 53 | +@@ -20,6 +20,7 @@ import ( | ||
| 54 | + "os/exec" | ||
| 55 | + "path/filepath" | ||
| 56 | + "regexp" | ||
| 57 | ++ "runtime" | ||
| 58 | + "strconv" | ||
| 59 | + "strings" | ||
| 60 | + "sync" | ||
| 61 | +@@ -421,6 +422,9 @@ int LLVMFuzzerTestOneInput(char *data, size_t size) { | ||
| 62 | + `) | ||
| 63 | + | ||
| 64 | + func (c *config) checkCSanitizer() (skip bool, err error) { | ||
| 65 | ++ if runtime.GOARCH == "sw64" { | ||
| 66 | ++ return true, fmt.Errorf("skip sw64 gcc sanitizer because of some known issue") | ||
| 67 | ++ } | ||
| 68 | + dir, err := os.MkdirTemp("", c.sanitizer) | ||
| 69 | + if err != nil { | ||
| 70 | + return false, fmt.Errorf("failed to create temp directory: %v", err) | ||
| 71 | +diff --git a/src/cmd/cgo/main.go b/src/cmd/cgo/main.go | ||
| 72 | +index 78020ae..68a5e27 100644 | ||
| 73 | +--- a/src/cmd/cgo/main.go | ||
| 74 | ++++ b/src/cmd/cgo/main.go | ||
| 75 | +@@ -191,6 +191,7 @@ var ptrSizeMap = map[string]int64{ | ||
| 76 | + "shbe": 4, | ||
| 77 | + "sparc": 4, | ||
| 78 | + "sparc64": 8, | ||
| 79 | ++ "sw64": 8, | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + var intSizeMap = map[string]int64{ | ||
| 83 | +@@ -217,6 +218,7 @@ var intSizeMap = map[string]int64{ | ||
| 84 | + "shbe": 4, | ||
| 85 | + "sparc": 4, | ||
| 86 | + "sparc64": 8, | ||
| 87 | ++ "sw64": 8, | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + var cPrefix string | ||
| 91 | +-- | ||
| 92 | +2.33.0 | ||
| 93 | + | ||
| @@ -0,0 +1,177 @@ | |||
| 1 | +From 0f8f160a925f1d2a47d08c98cd77b2af8c70e203 Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: swcompiler <lc@wxiat.com> | ||
| 3 | +Date: Fri, 21 Feb 2025 14:31:33 +0800 | ||
| 4 | +Subject: [PATCH 09/16] reflect: Add sw64 port | ||
| 5 | + | ||
| 6 | +--- | ||
| 7 | + src/reflect/asm_sw64.s | 77 ++++++++++++++++++++ | ||
| 8 | + src/reflect/float32reg_generic.go | 2 +- | ||
| 9 | + src/reflect/float32reg_sw64.s | 28 +++++++ | ||
| 10 | + src/reflect/stubs_sw64.go | 8 ++ | ||
| 11 | + src/vendor/golang.org/x/sys/cpu/byteorder.go | 3 +- | ||
| 12 | + 5 files changed, 116 insertions(+), 2 deletions(-) | ||
| 13 | + create mode 100644 src/reflect/asm_sw64.s | ||
| 14 | + create mode 100644 src/reflect/float32reg_sw64.s | ||
| 15 | + create mode 100644 src/reflect/stubs_sw64.go | ||
| 16 | + | ||
| 17 | +diff --git a/src/reflect/asm_sw64.s b/src/reflect/asm_sw64.s | ||
| 18 | +new file mode 100644 | ||
| 19 | +index 0000000..3df3001 | ||
| 20 | +--- /dev/null | ||
| 21 | ++++ b/src/reflect/asm_sw64.s | ||
| 22 | +@@ -0,0 +1,77 @@ | ||
| 23 | ++// Copyright 2018 The Go Authors. All rights reserved. | ||
| 24 | ++// Use of this source code is governed by a BSD-style | ||
| 25 | ++// license that can be found in the LICENSE file. | ||
| 26 | ++ | ||
| 27 | ++#include "textflag.h" | ||
| 28 | ++#include "funcdata.h" | ||
| 29 | ++ | ||
| 30 | ++// The frames of each of the two functions below contain two locals, at offsets | ||
| 31 | ++// that are known to the runtime. | ||
| 32 | ++// | ||
| 33 | ++// The first local is a bool called retValid with a whole pointer-word reserved | ||
| 34 | ++// for it on the stack. The purpose of this word is so that the runtime knows | ||
| 35 | ++// whether the stack-allocated return space contains valid values for stack | ||
| 36 | ++// scanning. | ||
| 37 | ++// | ||
| 38 | ++// The second local is an abi.RegArgs value whose offset is also known to the | ||
| 39 | ++// runtime, so that a stack map for it can be constructed, since it contains | ||
| 40 | ++// pointers visible to the GC. | ||
| 41 | ++#define LOCAL_RETVALID 40 | ||
| 42 | ++#define LOCAL_REGARGS 48 | ||
| 43 | ++ | ||
| 44 | ++// The frame size of the functions below is | ||
| 45 | ++// 32 (args of callReflect/callMethod) + (8 bool with padding) + 224 (abi.RegArgs) = 264. | ||
| 46 | ++ | ||
| 47 | ++// makeFuncStub is the code half of the function returned by MakeFunc. | ||
| 48 | ++// See the comment on the declaration of makeFuncStub in makefunc.go | ||
| 49 | ++// for more details. | ||
| 50 | ++// No arg size here, runtime pulls arg map out of the func value. | ||
| 51 | ++//TEXT ·makeFuncStub(SB), (NOSPLIT|WRAPPER), $40 | ||
| 52 | ++TEXT ·makeFuncStub(SB), (NOSPLIT|WRAPPER), $264 | ||
| 53 | ++ NO_LOCAL_POINTERS | ||
| 54 | ++ ADDL SP, $LOCAL_REGARGS, R9 // spillArgs using R9 | ||
| 55 | ++ CALL runtime·spillArgs(SB) | ||
| 56 | ++ STL REGCTXT, 32(SP) // save CTXT > args of moveMakeFuncArgPtrs < LOCAL_REGARGS | ||
| 57 | ++ STL REGCTXT, 8(SP) | ||
| 58 | ++ STL R9, 16(SP) | ||
| 59 | ++ CALL ·moveMakeFuncArgPtrs(SB) | ||
| 60 | ++ LDL REGCTXT, 32(SP) // restore CTXT | ||
| 61 | ++ STL REGCTXT, 8(SP) | ||
| 62 | ++ LDI R1, $argframe+0(FP) | ||
| 63 | ++ STL R1, 16(SP) | ||
| 64 | ++ STB ZERO, $LOCAL_RETVALID(SP) | ||
| 65 | ++ ADDL SP, $LOCAL_RETVALID, R1 | ||
| 66 | ++ STL R1, 24(SP) | ||
| 67 | ++ ADDL SP, $LOCAL_REGARGS, R1 | ||
| 68 | ++ STL R1, 32(SP) | ||
| 69 | ++ CALL ·callReflect(SB) | ||
| 70 | ++ ADDL SP, $LOCAL_REGARGS, R9 // unspillArgs using R9 | ||
| 71 | ++ CALL runtime·unspillArgs(SB) | ||
| 72 | ++ RET | ||
| 73 | ++ | ||
| 74 | ++// methodValueCall is the code half of the function returned by makeMethodValue. | ||
| 75 | ++// See the comment on the declaration of methodValueCall in makefunc.go | ||
| 76 | ++// for more details. | ||
| 77 | ++// No arg size here; runtime pulls arg map out of the func value. | ||
| 78 | ++//TEXT ·methodValueCall(SB), (NOSPLIT|WRAPPER), $40 | ||
| 79 | ++TEXT ·methodValueCall(SB), (NOSPLIT|WRAPPER), $264 | ||
| 80 | ++ NO_LOCAL_POINTERS | ||
| 81 | ++ ADDL SP, $LOCAL_REGARGS, R9 // spillArgs using R9 | ||
| 82 | ++ CALL runtime·spillArgs(SB) | ||
| 83 | ++ STL REGCTXT, 32(SP) // save CTXT | ||
| 84 | ++ STL REGCTXT, 8(SP) | ||
| 85 | ++ STL R9, 16(SP) | ||
| 86 | ++ CALL ·moveMakeFuncArgPtrs(SB) | ||
| 87 | ++ LDL REGCTXT, 32(SP) // restore CTXT | ||
| 88 | ++ STL REGCTXT, 8(SP) | ||
| 89 | ++ LDI R1, $argframe+0(FP) | ||
| 90 | ++ STL R1, 16(SP) | ||
| 91 | ++ STB ZERO, $LOCAL_RETVALID(SP) | ||
| 92 | ++ ADDL SP, $LOCAL_RETVALID, R1 | ||
| 93 | ++ STL R1, 24(SP) | ||
| 94 | ++ ADDL SP, $LOCAL_REGARGS, R1 | ||
| 95 | ++ STL R1, 32(SP) // frame size to 32+SP as callreflect args | ||
| 96 | ++ CALL ·callMethod(SB) | ||
| 97 | ++ ADDL SP, $LOCAL_REGARGS, R9 // unspillArgs using R9 | ||
| 98 | ++ CALL runtime·unspillArgs(SB) | ||
| 99 | ++ RET | ||
| 100 | +diff --git a/src/reflect/float32reg_generic.go b/src/reflect/float32reg_generic.go | ||
| 101 | +index 23ad4bf..2643bab 100644 | ||
| 102 | +--- a/src/reflect/float32reg_generic.go | ||
| 103 | ++++ b/src/reflect/float32reg_generic.go | ||
| 104 | +@@ -2,7 +2,7 @@ | ||
| 105 | + // Use of this source code is governed by a BSD-style | ||
| 106 | + // license that can be found in the LICENSE file. | ||
| 107 | + | ||
| 108 | +-//go:build !ppc64 && !ppc64le && !riscv64 | ||
| 109 | ++//go:build !ppc64 && !ppc64le && !riscv64 && !sw64 | ||
| 110 | + | ||
| 111 | + package reflect | ||
| 112 | + | ||
| 113 | +diff --git a/src/reflect/float32reg_sw64.s b/src/reflect/float32reg_sw64.s | ||
| 114 | +new file mode 100644 | ||
| 115 | +index 0000000..5168fb1 | ||
| 116 | +--- /dev/null | ||
| 117 | ++++ b/src/reflect/float32reg_sw64.s | ||
| 118 | +@@ -0,0 +1,28 @@ | ||
| 119 | ++// Copyright 2021 The Go Authors. All rights reserved. | ||
| 120 | ++// Use of this source code is governed by a BSD-style | ||
| 121 | ++// license that can be found in the LICENSE file. | ||
| 122 | ++ | ||
| 123 | ++#include "textflag.h" | ||
| 124 | ++ | ||
| 125 | ++// On SW64, the float32 has 35 valid bits | ||
| 126 | ++// when loaded in a register, different from | ||
| 127 | ++// other platforms. These functions are | ||
| 128 | ++// needed to ensure correct conversions on SW64. | ||
| 129 | ++ | ||
| 130 | ++// Convert float32->uint64 | ||
| 131 | ++TEXT ·archFloat32ToReg(SB),NOSPLIT,$0-16 | ||
| 132 | ++ FLDS F1, val+0(FP) | ||
| 133 | ++ FSTD F1, ret+8(FP) | ||
| 134 | ++ RET | ||
| 135 | ++ | ||
| 136 | ++// Convert uint64->float32 | ||
| 137 | ++TEXT ·archFloat32FromReg(SB),NOSPLIT,$0-12 | ||
| 138 | ++ FLDD F1, reg+0(FP) | ||
| 139 | ++ // Normally a float64->float32 conversion | ||
| 140 | ++ // would need rounding, but that is not needed | ||
| 141 | ++ // here since the uint64 was originally converted | ||
| 142 | ++ // from float32, and should be avoided to | ||
| 143 | ++ // preserve SNaN values. | ||
| 144 | ++ FSTS F1, ret+8(FP) | ||
| 145 | ++ RET | ||
| 146 | ++ | ||
| 147 | +diff --git a/src/reflect/stubs_sw64.go b/src/reflect/stubs_sw64.go | ||
| 148 | +new file mode 100644 | ||
| 149 | +index 0000000..a72ebab | ||
| 150 | +--- /dev/null | ||
| 151 | ++++ b/src/reflect/stubs_sw64.go | ||
| 152 | +@@ -0,0 +1,8 @@ | ||
| 153 | ++// Copyright 2022 The Go Authors. All rights reserved. | ||
| 154 | ++// Use of this source code is governed by a BSD-style | ||
| 155 | ++// license that can be found in the LICENSE file. | ||
| 156 | ++ | ||
| 157 | ++package reflect | ||
| 158 | ++ | ||
| 159 | ++func archFloat32FromReg(reg uint64) float32 | ||
| 160 | ++func archFloat32ToReg(val float32) uint64 | ||
| 161 | +diff --git a/src/vendor/golang.org/x/sys/cpu/byteorder.go b/src/vendor/golang.org/x/sys/cpu/byteorder.go | ||
| 162 | +index 271055b..a1d69f2 100644 | ||
| 163 | +--- a/src/vendor/golang.org/x/sys/cpu/byteorder.go | ||
| 164 | ++++ b/src/vendor/golang.org/x/sys/cpu/byteorder.go | ||
| 165 | +@@ -51,7 +51,8 @@ func hostByteOrder() byteOrder { | ||
| 166 | + "nios2", | ||
| 167 | + "ppc64le", | ||
| 168 | + "riscv", "riscv64", | ||
| 169 | +- "sh": | ||
| 170 | ++ "sh", | ||
| 171 | ++ "sw64": | ||
| 172 | + return littleEndian{} | ||
| 173 | + case "armbe", "arm64be", | ||
| 174 | + "m68k", | ||
| 175 | +-- | ||
| 176 | +2.33.0 | ||
| 177 | + | ||
| @@ -0,0 +1,112 @@ | |||
| 1 | +From 3976a8b2179362034469b044998130b92910e79d Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: swcompiler <lc@wxiat.com> | ||
| 3 | +Date: Fri, 21 Feb 2025 14:33:19 +0800 | ||
| 4 | +Subject: [PATCH 11/16] cmd/go, go: Add sw64 port | ||
| 5 | + | ||
| 6 | +--- | ||
| 7 | + src/cmd/go/internal/cfg/cfg.go | 1 + | ||
| 8 | + src/cmd/go/internal/imports/build.go | 1 + | ||
| 9 | + src/cmd/go/internal/modindex/syslist.go | 1 + | ||
| 10 | + ..._toolchain_v0.0.1-go1.999testmod.linux-sw64.txt | 14 ++++++++++++++ | ||
| 11 | + src/go/build/syslist.go | 1 + | ||
| 12 | + src/go/types/gccgosizes.go | 1 + | ||
| 13 | + src/go/types/sizes.go | 3 ++- | ||
| 14 | + 7 files changed, 21 insertions(+), 1 deletion(-) | ||
| 15 | + create mode 100644 src/cmd/go/testdata/mod/golang.org_toolchain_v0.0.1-go1.999testmod.linux-sw64.txt | ||
| 16 | + | ||
| 17 | +diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go | ||
| 18 | +index 8caa22a..32cc4b3 100644 | ||
| 19 | +--- a/src/cmd/go/internal/cfg/cfg.go | ||
| 20 | ++++ b/src/cmd/go/internal/cfg/cfg.go | ||
| 21 | +@@ -415,6 +415,7 @@ var ( | ||
| 22 | + GOMIPS = envOr("GOMIPS", buildcfg.GOMIPS) | ||
| 23 | + GOMIPS64 = envOr("GOMIPS64", buildcfg.GOMIPS64) | ||
| 24 | + GOPPC64 = envOr("GOPPC64", fmt.Sprintf("%s%d", "power", buildcfg.GOPPC64)) | ||
| 25 | ++ GOSW64 = envOr("GOSW64", fmt.Sprintf("%s%d", "core", buildcfg.GOSW64)) | ||
| 26 | + GOWASM = envOr("GOWASM", fmt.Sprint(buildcfg.GOWASM)) | ||
| 27 | + | ||
| 28 | + GOPROXY = envOr("GOPROXY", "") | ||
| 29 | +diff --git a/src/cmd/go/internal/imports/build.go b/src/cmd/go/internal/imports/build.go | ||
| 30 | +index 3a4a66b..4cc231c 100644 | ||
| 31 | +--- a/src/cmd/go/internal/imports/build.go | ||
| 32 | ++++ b/src/cmd/go/internal/imports/build.go | ||
| 33 | +@@ -371,4 +371,5 @@ var KnownArch = map[string]bool{ | ||
| 34 | + "sparc": true, | ||
| 35 | + "sparc64": true, | ||
| 36 | + "wasm": true, | ||
| 37 | ++ "sw64": true, | ||
| 38 | + } | ||
| 39 | +diff --git a/src/cmd/go/internal/modindex/syslist.go b/src/cmd/go/internal/modindex/syslist.go | ||
| 40 | +index 41adcc5..1707acf 100644 | ||
| 41 | +--- a/src/cmd/go/internal/modindex/syslist.go | ||
| 42 | ++++ b/src/cmd/go/internal/modindex/syslist.go | ||
| 43 | +@@ -75,4 +75,5 @@ var knownArch = map[string]bool{ | ||
| 44 | + "sparc": true, | ||
| 45 | + "sparc64": true, | ||
| 46 | + "wasm": true, | ||
| 47 | ++ "sw64": true, | ||
| 48 | + } | ||
| 49 | +diff --git a/src/cmd/go/testdata/mod/golang.org_toolchain_v0.0.1-go1.999testmod.linux-sw64.txt b/src/cmd/go/testdata/mod/golang.org_toolchain_v0.0.1-go1.999testmod.linux-sw64.txt | ||
| 50 | +new file mode 100644 | ||
| 51 | +index 0000000..0deea82 | ||
| 52 | +--- /dev/null | ||
| 53 | ++++ b/src/cmd/go/testdata/mod/golang.org_toolchain_v0.0.1-go1.999testmod.linux-sw64.txt | ||
| 54 | +@@ -0,0 +1,14 @@ | ||
| 55 | ++golang.org/toolchain@v0.0.1-go1.999testmod.linux-sw64 | ||
| 56 | ++ | ||
| 57 | ++-- .mod -- | ||
| 58 | ++module golang.org/toolchain | ||
| 59 | ++-- .info -- | ||
| 60 | ++{"Version":"v0.0.1-go1.999testmod.linux-sw64"} | ||
| 61 | ++-- go.mod -- | ||
| 62 | ++module golang.org/toolchain | ||
| 63 | ++-- bin/go -- | ||
| 64 | ++#!/bin/sh | ||
| 65 | ++echo go1.999testmod here! | ||
| 66 | ++-- bin/gofmt -- | ||
| 67 | ++echo i am unused | ||
| 68 | ++-- pkg/tool/fake -- | ||
| 69 | +diff --git a/src/go/build/syslist.go b/src/go/build/syslist.go | ||
| 70 | +index 783bbe6..7730553 100644 | ||
| 71 | +--- a/src/go/build/syslist.go | ||
| 72 | ++++ b/src/go/build/syslist.go | ||
| 73 | +@@ -78,4 +78,5 @@ var knownArch = map[string]bool{ | ||
| 74 | + "sparc": true, | ||
| 75 | + "sparc64": true, | ||
| 76 | + "wasm": true, | ||
| 77 | ++ "sw64": true, | ||
| 78 | + } | ||
| 79 | +diff --git a/src/go/types/gccgosizes.go b/src/go/types/gccgosizes.go | ||
| 80 | +index 9152c81..e74e501 100644 | ||
| 81 | +--- a/src/go/types/gccgosizes.go | ||
| 82 | ++++ b/src/go/types/gccgosizes.go | ||
| 83 | +@@ -40,4 +40,5 @@ var gccgoArchSizes = map[string]*StdSizes{ | ||
| 84 | + "sparc": {4, 8}, | ||
| 85 | + "sparc64": {8, 8}, | ||
| 86 | + "wasm": {8, 8}, | ||
| 87 | ++ "sw64": {8, 8}, | ||
| 88 | + } | ||
| 89 | +diff --git a/src/go/types/sizes.go b/src/go/types/sizes.go | ||
| 90 | +index 2dcaebe..3c79687 100644 | ||
| 91 | +--- a/src/go/types/sizes.go | ||
| 92 | ++++ b/src/go/types/sizes.go | ||
| 93 | +@@ -246,6 +246,7 @@ var gcArchSizes = map[string]*StdSizes{ | ||
| 94 | + "s390x": {8, 8}, | ||
| 95 | + "sparc64": {8, 8}, | ||
| 96 | + "wasm": {8, 8}, | ||
| 97 | ++ "sw64": {8, 8}, | ||
| 98 | + // When adding more architectures here, | ||
| 99 | + // update the doc string of SizesFor below. | ||
| 100 | + } | ||
| 101 | +@@ -255,7 +256,7 @@ var gcArchSizes = map[string]*StdSizes{ | ||
| 102 | + // | ||
| 103 | + // Supported architectures for compiler "gc": | ||
| 104 | + // "386", "amd64", "amd64p32", "arm", "arm64", "loong64", "mips", "mipsle", | ||
| 105 | +-// "mips64", "mips64le", "ppc64", "ppc64le", "riscv64", "s390x", "sparc64", "wasm". | ||
| 106 | ++// "mips64", "mips64le", "ppc64", "ppc64le", "riscv64", "s390x", "sparc64", "wasm", "sw64". | ||
| 107 | + func SizesFor(compiler, arch string) Sizes { | ||
| 108 | + var m map[string]*StdSizes | ||
| 109 | + switch compiler { | ||
| 110 | +-- | ||
| 111 | +2.33.0 | ||
| 112 | + | ||
| @@ -0,0 +1,332 @@ | |||
| 1 | +From b9270809b4afa35c4fecbc1d2af94f8617e0fded Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: swcompiler <lc@wxiat.com> | ||
| 3 | +Date: Fri, 21 Feb 2025 14:35:02 +0800 | ||
| 4 | +Subject: [PATCH 13/16] crypto, hash, math: Add sw64 port | ||
| 5 | + | ||
| 6 | +--- | ||
| 7 | + src/crypto/subtle/xor_generic.go | 2 +- | ||
| 8 | + src/crypto/subtle/xor_sw64.go | 10 +++ | ||
| 9 | + src/crypto/subtle/xor_sw64.s | 55 ++++++++++++++++ | ||
| 10 | + src/hash/crc32/crc32_otherarch.go | 2 +- | ||
| 11 | + src/hash/crc32/crc32_sw64.go | 50 +++++++++++++++ | ||
| 12 | + src/hash/crc32/crc32_sw64.s | 103 ++++++++++++++++++++++++++++++ | ||
| 13 | + src/math/big/arith_sw64.s | 35 ++++++++++ | ||
| 14 | + 7 files changed, 255 insertions(+), 2 deletions(-) | ||
| 15 | + create mode 100644 src/crypto/subtle/xor_sw64.go | ||
| 16 | + create mode 100644 src/crypto/subtle/xor_sw64.s | ||
| 17 | + create mode 100644 src/hash/crc32/crc32_sw64.go | ||
| 18 | + create mode 100644 src/hash/crc32/crc32_sw64.s | ||
| 19 | + create mode 100644 src/math/big/arith_sw64.s | ||
| 20 | + | ||
| 21 | +diff --git a/src/crypto/subtle/xor_generic.go b/src/crypto/subtle/xor_generic.go | ||
| 22 | +index 7dc89e3..d8009ba 100644 | ||
| 23 | +--- a/src/crypto/subtle/xor_generic.go | ||
| 24 | ++++ b/src/crypto/subtle/xor_generic.go | ||
| 25 | +@@ -2,7 +2,7 @@ | ||
| 26 | + // Use of this source code is governed by a BSD-style | ||
| 27 | + // license that can be found in the LICENSE file. | ||
| 28 | + | ||
| 29 | +-//go:build (!amd64 && !arm64 && !ppc64 && !ppc64le) || purego | ||
| 30 | ++//go:build (!amd64 && !arm64 && !ppc64 && !ppc64le && !sw64) || purego | ||
| 31 | + | ||
| 32 | + package subtle | ||
| 33 | + | ||
| 34 | +diff --git a/src/crypto/subtle/xor_sw64.go b/src/crypto/subtle/xor_sw64.go | ||
| 35 | +new file mode 100644 | ||
| 36 | +index 0000000..65bab4c | ||
| 37 | +--- /dev/null | ||
| 38 | ++++ b/src/crypto/subtle/xor_sw64.go | ||
| 39 | +@@ -0,0 +1,10 @@ | ||
| 40 | ++// Copyright 2020 The Go Authors. All rights reserved. | ||
| 41 | ++// Use of this source code is governed by a BSD-style | ||
| 42 | ++// license that can be found in the LICENSE file. | ||
| 43 | ++ | ||
| 44 | ++//go:build !purego | ||
| 45 | ++ | ||
| 46 | ++package subtle | ||
| 47 | ++ | ||
| 48 | ++//go:noescape | ||
| 49 | ++func xorBytes(dst, a, b *byte, n int) | ||
| 50 | +diff --git a/src/crypto/subtle/xor_sw64.s b/src/crypto/subtle/xor_sw64.s | ||
| 51 | +new file mode 100644 | ||
| 52 | +index 0000000..a113979 | ||
| 53 | +--- /dev/null | ||
| 54 | ++++ b/src/crypto/subtle/xor_sw64.s | ||
| 55 | +@@ -0,0 +1,55 @@ | ||
| 56 | ++//go:build !purego | ||
| 57 | ++ | ||
| 58 | ++#include "textflag.h" | ||
| 59 | ++ | ||
| 60 | ++// func xorBytes(dst, a, b *byte n int) | ||
| 61 | ++TEXT ·xorBytes(SB), NOSPLIT, $0 | ||
| 62 | ++ LDL R0, dst+0(FP) | ||
| 63 | ++ LDL R1, a+8(FP) | ||
| 64 | ++ LDL R2, b+16(FP) | ||
| 65 | ++ LDL R3, n+24(FP) | ||
| 66 | ++ CMPLT R3, $8, R4 | ||
| 67 | ++ BNE R4, less_than8 | ||
| 68 | ++loop_8: | ||
| 69 | ++ LDL R11, (R1) | ||
| 70 | ++ LDL R12, (R2) | ||
| 71 | ++ LDI R1, 8(R1) // addr(a) + 8 | ||
| 72 | ++ LDI R2, 8(R2) // addr(b) + 8 | ||
| 73 | ++ XOR R11, R12, R12 | ||
| 74 | ++ STL R12, (R0) | ||
| 75 | ++ LDI R0, 8(R0) // addr(dst) +8 | ||
| 76 | ++ LDI R3, -8(R3) // n - 8 | ||
| 77 | ++ CMPLT R3, $8, R4 | ||
| 78 | ++ BEQ R4, loop_8 | ||
| 79 | ++less_than8: | ||
| 80 | ++ BEQ R3, end | ||
| 81 | ++ CMPLT R3, $4, R4 | ||
| 82 | ++ BNE R4, less_than4 | ||
| 83 | ++ LDW R13, (R1) | ||
| 84 | ++ LDW R14, (R2) | ||
| 85 | ++ LDI R1, 4(R1) | ||
| 86 | ++ LDI R2, 4(R2) | ||
| 87 | ++ XOR R13, R14, R14 | ||
| 88 | ++ STW R14, (R0) | ||
| 89 | ++ LDI R0, 4(R0) | ||
| 90 | ++ LDI R3, -4(R3) // n - 4 | ||
| 91 | ++less_than4: | ||
| 92 | ++ CMPLT R3, $2, R4 | ||
| 93 | ++ BNE R4, less_than2 | ||
| 94 | ++ LDHU R16, (R1) | ||
| 95 | ++ LDHU R17, (R2) | ||
| 96 | ++ LDI R1, 2(R1) | ||
| 97 | ++ LDI R2, 2(R2) | ||
| 98 | ++ XOR R16, R17, R17 | ||
| 99 | ++ STH R17, (R0) | ||
| 100 | ++ LDI R0, 2(R0) | ||
| 101 | ++ LDI R3, -2(R3) // n - 2 | ||
| 102 | ++less_than2: | ||
| 103 | ++ BEQ R3, end | ||
| 104 | ++ LDBU R18, (R1) | ||
| 105 | ++ LDBU R19, (R2) | ||
| 106 | ++ XOR R18, R19, R19 | ||
| 107 | ++ STB R19, (R0) | ||
| 108 | ++end: | ||
| 109 | ++ RET | ||
| 110 | ++ | ||
| 111 | +diff --git a/src/hash/crc32/crc32_otherarch.go b/src/hash/crc32/crc32_otherarch.go | ||
| 112 | +index 7625152..d178fa4 100644 | ||
| 113 | +--- a/src/hash/crc32/crc32_otherarch.go | ||
| 114 | ++++ b/src/hash/crc32/crc32_otherarch.go | ||
| 115 | +@@ -2,7 +2,7 @@ | ||
| 116 | + // Use of this source code is governed by a BSD-style | ||
| 117 | + // license that can be found in the LICENSE file. | ||
| 118 | + | ||
| 119 | +-//go:build !amd64 && !s390x && !ppc64le && !arm64 | ||
| 120 | ++//go:build !amd64 && !s390x && !ppc64le && !arm64 && !sw64 | ||
| 121 | + | ||
| 122 | + package crc32 | ||
| 123 | + | ||
| 124 | +diff --git a/src/hash/crc32/crc32_sw64.go b/src/hash/crc32/crc32_sw64.go | ||
| 125 | +new file mode 100644 | ||
| 126 | +index 0000000..92a05a2 | ||
| 127 | +--- /dev/null | ||
| 128 | ++++ b/src/hash/crc32/crc32_sw64.go | ||
| 129 | +@@ -0,0 +1,50 @@ | ||
| 130 | ++// Copyright 2017 The Go Authors. All rights reserved. | ||
| 131 | ++// Use of this source code is governed by a BSD-style | ||
| 132 | ++// license that can be found in the LICENSE file. | ||
| 133 | ++ | ||
| 134 | ++// SW64-specific hardware-assisted CRC32 algorithms. See crc32.go for a | ||
| 135 | ++// description of the interface that each architecture-specific file | ||
| 136 | ++// implements. | ||
| 137 | ++ | ||
| 138 | ++package crc32 | ||
| 139 | ++ | ||
| 140 | ++import "internal/cpu" | ||
| 141 | ++ | ||
| 142 | ++func castagnoliUpdate(crc uint32, p []byte) uint32 | ||
| 143 | ++func ieeeUpdate(crc uint32, p []byte) uint32 | ||
| 144 | ++ | ||
| 145 | ++func archAvailableCastagnoli() bool { | ||
| 146 | ++ return cpu.SW64.HasCRC | ||
| 147 | ++} | ||
| 148 | ++ | ||
| 149 | ++func archInitCastagnoli() { | ||
| 150 | ++ if !cpu.SW64.HasCRC { | ||
| 151 | ++ panic("arch-specific crc32 instruction for Catagnoli not available") | ||
| 152 | ++ } | ||
| 153 | ++} | ||
| 154 | ++ | ||
| 155 | ++func archUpdateCastagnoli(crc uint32, p []byte) uint32 { | ||
| 156 | ++ if !cpu.SW64.HasCRC { | ||
| 157 | ++ panic("arch-specific crc32 instruction for Castagnoli not available") | ||
| 158 | ++ } | ||
| 159 | ++ | ||
| 160 | ++ return ^castagnoliUpdate(^crc, p) | ||
| 161 | ++} | ||
| 162 | ++ | ||
| 163 | ++func archAvailableIEEE() bool { | ||
| 164 | ++ return cpu.SW64.HasCRC | ||
| 165 | ++} | ||
| 166 | ++ | ||
| 167 | ++func archInitIEEE() { | ||
| 168 | ++ if !cpu.SW64.HasCRC { | ||
| 169 | ++ panic("arch-specific crc32 instruction for IEEE not available") | ||
| 170 | ++ } | ||
| 171 | ++} | ||
| 172 | ++ | ||
| 173 | ++func archUpdateIEEE(crc uint32, p []byte) uint32 { | ||
| 174 | ++ if !cpu.SW64.HasCRC { | ||
| 175 | ++ panic("arch-specific crc32 instruction for IEEE not available") | ||
| 176 | ++ } | ||
| 177 | ++ | ||
| 178 | ++ return ^ieeeUpdate(^crc, p) | ||
| 179 | ++} | ||
| 180 | +diff --git a/src/hash/crc32/crc32_sw64.s b/src/hash/crc32/crc32_sw64.s | ||
| 181 | +new file mode 100644 | ||
| 182 | +index 0000000..6580364 | ||
| 183 | +--- /dev/null | ||
| 184 | ++++ b/src/hash/crc32/crc32_sw64.s | ||
| 185 | +@@ -0,0 +1,103 @@ | ||
| 186 | ++// Copyright 2017 The Go Authors. All rights reserved. | ||
| 187 | ++// Use of this source code is governed by a BSD-style | ||
| 188 | ++// license that can be found in the LICENSE file. | ||
| 189 | ++ | ||
| 190 | ++#include "textflag.h" | ||
| 191 | ++ | ||
| 192 | ++// castagnoliUpdate updates the non-inverted crc with the given data. | ||
| 193 | ++ | ||
| 194 | ++// func castagnoliUpdate(crc uint32, p []byte) uint32 | ||
| 195 | ++TEXT ·castagnoliUpdate(SB),NOSPLIT,$0-36 | ||
| 196 | ++ LDW R9, crc+0(FP) // CRC value | ||
| 197 | ++ LDL R13, p+8(FP) // data pointer | ||
| 198 | ++ LDL R11, p_len+16(FP) // len(p) | ||
| 199 | ++ ZAPNOT R9, $15, R9 | ||
| 200 | ++ | ||
| 201 | ++ CMPLT R11, $8, R8 | ||
| 202 | ++ BNE R8, less_than_8 | ||
| 203 | ++ | ||
| 204 | ++update: | ||
| 205 | ++ LDLA R10, 8(R13) | ||
| 206 | ++ CRC32CL R9, R10, R9 | ||
| 207 | ++ SUBL R11, $8, R11 | ||
| 208 | ++ | ||
| 209 | ++ CMPLT R11, $8, R8 | ||
| 210 | ++ BNE R8, less_than_8 | ||
| 211 | ++ | ||
| 212 | ++ JMP update | ||
| 213 | ++ | ||
| 214 | ++less_than_8: | ||
| 215 | ++ AND R11, $4, R8 | ||
| 216 | ++ BEQ R8, less_than_4 | ||
| 217 | ++ | ||
| 218 | ++ LDWA R10, 4(R13) | ||
| 219 | ++ ZAPNOT R10, $15, R10 | ||
| 220 | ++ CRC32CW R9, R10, R9 | ||
| 221 | ++ SUBL R11, $4, R11 | ||
| 222 | ++ | ||
| 223 | ++less_than_4: | ||
| 224 | ++ AND R11, $2, R8 | ||
| 225 | ++ BEQ R8, less_than_2 | ||
| 226 | ++ | ||
| 227 | ++ LDHUA R10, 2(R13) | ||
| 228 | ++ CRC32CH R9, R10, R9 | ||
| 229 | ++ SUBL R11, $2, R11 | ||
| 230 | ++ | ||
| 231 | ++less_than_2: | ||
| 232 | ++ BEQ R11, done | ||
| 233 | ++ | ||
| 234 | ++ LDBU R10, (R13) | ||
| 235 | ++ CRC32CB R9, R10, R9 | ||
| 236 | ++ | ||
| 237 | ++done: | ||
| 238 | ++ STW R9, ret+32(FP) | ||
| 239 | ++ RET | ||
| 240 | ++ | ||
| 241 | ++// ieeeUpdate updates the non-inverted crc with the given data. | ||
| 242 | ++ | ||
| 243 | ++// func ieeeUpdate(crc uint32, p []byte) uint32 | ||
| 244 | ++TEXT ·ieeeUpdate(SB),NOSPLIT,$0-36 | ||
| 245 | ++ LDW R9, crc+0(FP) // CRC value | ||
| 246 | ++ LDL R13, p+8(FP) // data pointer | ||
| 247 | ++ LDL R11, p_len+16(FP) // len(p) | ||
| 248 | ++ ZAPNOT R9, $15, R9 | ||
| 249 | ++ | ||
| 250 | ++ CMPLT R11, $8, R8 | ||
| 251 | ++ BNE R8, less_than_8 | ||
| 252 | ++ | ||
| 253 | ++update: | ||
| 254 | ++ LDLA R10, 8(R13) | ||
| 255 | ++ CRC32L R9, R10, R9 | ||
| 256 | ++ SUBL R11, $8, R11 | ||
| 257 | ++ | ||
| 258 | ++ CMPLT R11, $8, R8 | ||
| 259 | ++ BNE R8, less_than_8 | ||
| 260 | ++ | ||
| 261 | ++ JMP update | ||
| 262 | ++ | ||
| 263 | ++less_than_8: | ||
| 264 | ++ CMPLT R11, $4, R8 | ||
| 265 | ++ BNE R8, less_than_4 | ||
| 266 | ++ | ||
| 267 | ++ LDWA R10, 4(R13) | ||
| 268 | ++ ZAPNOT R10, $15, R10 | ||
| 269 | ++ CRC32W R9, R10, R9 | ||
| 270 | ++ SUBL R11, $4, R11 | ||
| 271 | ++ | ||
| 272 | ++less_than_4: | ||
| 273 | ++ CMPLT R11, $2, R8 | ||
| 274 | ++ BNE R8, less_than_2 | ||
| 275 | ++ | ||
| 276 | ++ LDHUA R10, 2(R13) | ||
| 277 | ++ CRC32H R9, R10, R9 | ||
| 278 | ++ SUBL R11, $2, R11 | ||
| 279 | ++ | ||
| 280 | ++less_than_2: | ||
| 281 | ++ BEQ R11, done | ||
| 282 | ++ | ||
| 283 | ++ LDBU R10, (R13) | ||
| 284 | ++ CRC32B R9, R10, R9 | ||
| 285 | ++ | ||
| 286 | ++done: | ||
| 287 | ++ STW R9, ret+32(FP) | ||
| 288 | ++ RET | ||
| 289 | +diff --git a/src/math/big/arith_sw64.s b/src/math/big/arith_sw64.s | ||
| 290 | +new file mode 100644 | ||
| 291 | +index 0000000..cd85f24 | ||
| 292 | +--- /dev/null | ||
| 293 | ++++ b/src/math/big/arith_sw64.s | ||
| 294 | +@@ -0,0 +1,35 @@ | ||
| 295 | ++// Copyright 2013 The Go Authors. All rights reserved. | ||
| 296 | ++// Use of this source code is governed by a BSD-style | ||
| 297 | ++// license that can be found in the LICENSE file. | ||
| 298 | ++ | ||
| 299 | ++//go:build sw64 && !math_big_pure_go | ||
| 300 | ++// +build sw64,!math_big_pure_go | ||
| 301 | ++ | ||
| 302 | ++#include "textflag.h" | ||
| 303 | ++ | ||
| 304 | ++// This file provides fast assembly versions for the elementary | ||
| 305 | ++// arithmetic operations on vectors implemented in arith.go. | ||
| 306 | ++ | ||
| 307 | ++TEXT ·addVV(SB), NOFRAME|NOSPLIT, $0 | ||
| 308 | ++ JMP ·addVV_g(SB) | ||
| 309 | ++ | ||
| 310 | ++TEXT ·subVV(SB), NOFRAME|NOSPLIT, $0 | ||
| 311 | ++ JMP ·subVV_g(SB) | ||
| 312 | ++ | ||
| 313 | ++TEXT ·addVW(SB), NOFRAME|NOSPLIT, $0 | ||
| 314 | ++ JMP ·addVW_g(SB) | ||
| 315 | ++ | ||
| 316 | ++TEXT ·subVW(SB), NOFRAME|NOSPLIT, $0 | ||
| 317 | ++ JMP ·subVW_g(SB) | ||
| 318 | ++ | ||
| 319 | ++TEXT ·shlVU(SB), NOFRAME|NOSPLIT, $0 | ||
| 320 | ++ JMP ·shlVU_g(SB) | ||
| 321 | ++ | ||
| 322 | ++TEXT ·shrVU(SB), NOFRAME|NOSPLIT, $0 | ||
| 323 | ++ JMP ·shrVU_g(SB) | ||
| 324 | ++ | ||
| 325 | ++TEXT ·mulAddVWW(SB), NOFRAME|NOSPLIT, $0 | ||
| 326 | ++ JMP ·mulAddVWW_g(SB) | ||
| 327 | ++ | ||
| 328 | ++TEXT ·addMulVVW(SB), NOFRAME|NOSPLIT, $0 | ||
| 329 | ++ JMP ·addMulVVW_g(SB) | ||
| 330 | +-- | ||
| 331 | +2.33.0 | ||
| 332 | + | ||
| @@ -0,0 +1,133 @@ | |||
| 1 | +From 3b5346acc6485cc26ea5e04250475e20bb9fe372 Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: swcompiler <lc@wxiat.com> | ||
| 3 | +Date: Fri, 21 Feb 2025 14:35:46 +0800 | ||
| 4 | +Subject: [PATCH 14/16] api: Add sw64 port | ||
| 5 | + | ||
| 6 | +--- | ||
| 7 | + api/go1.16.txt | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 8 | + api/go1.18.txt | 8 +++++ | ||
| 9 | + 2 files changed, 101 insertions(+) | ||
| 10 | + | ||
| 11 | +diff --git a/api/go1.16.txt b/api/go1.16.txt | ||
| 12 | +index e12a050..ea2e022 100644 | ||
| 13 | +--- a/api/go1.16.txt | ||
| 14 | ++++ b/api/go1.16.txt | ||
| 15 | +@@ -219,6 +219,99 @@ pkg debug/elf, const PT_SUNWSTACK = 1879048187 | ||
| 16 | + pkg debug/elf, const PT_SUNWSTACK ProgType | ||
| 17 | + pkg debug/elf, const PT_SUNW_EH_FRAME = 1685382480 | ||
| 18 | + pkg debug/elf, const PT_SUNW_EH_FRAME ProgType | ||
| 19 | ++pkg debug/elf, const EM_SW64 = 39190 | ||
| 20 | ++pkg debug/elf, const EM_SW64 Machine | ||
| 21 | ++pkg debug/elf, const R_SW64_BR26ADDR = 42 | ||
| 22 | ++pkg debug/elf, const R_SW64_BR26ADDR R_SW64 | ||
| 23 | ++pkg debug/elf, const R_SW64_BRADDR = 7 | ||
| 24 | ++pkg debug/elf, const R_SW64_BRADDR R_SW64 | ||
| 25 | ++pkg debug/elf, const R_SW64_BRSGP = 28 | ||
| 26 | ++pkg debug/elf, const R_SW64_BRSGP R_SW64 | ||
| 27 | ++pkg debug/elf, const R_SW64_COPY = 24 | ||
| 28 | ++pkg debug/elf, const R_SW64_COPY R_SW64 | ||
| 29 | ++pkg debug/elf, const R_SW64_DTPMOD64 = 31 | ||
| 30 | ++pkg debug/elf, const R_SW64_DTPMOD64 R_SW64 | ||
| 31 | ++pkg debug/elf, const R_SW64_DTPREL16 = 36 | ||
| 32 | ++pkg debug/elf, const R_SW64_DTPREL16 R_SW64 | ||
| 33 | ++pkg debug/elf, const R_SW64_DTPREL64 = 33 | ||
| 34 | ++pkg debug/elf, const R_SW64_DTPREL64 R_SW64 | ||
| 35 | ++pkg debug/elf, const R_SW64_DTPRELHI = 34 | ||
| 36 | ++pkg debug/elf, const R_SW64_DTPRELHI R_SW64 | ||
| 37 | ++pkg debug/elf, const R_SW64_DTPRELLO = 35 | ||
| 38 | ++pkg debug/elf, const R_SW64_DTPRELLO R_SW64 | ||
| 39 | ++pkg debug/elf, const R_SW64_GLOB_DAT = 25 | ||
| 40 | ++pkg debug/elf, const R_SW64_GLOB_DAT R_SW64 | ||
| 41 | ++pkg debug/elf, const R_SW64_GOTDTPREL = 32 | ||
| 42 | ++pkg debug/elf, const R_SW64_GOTDTPREL R_SW64 | ||
| 43 | ++pkg debug/elf, const R_SW64_GOTTPREL = 37 | ||
| 44 | ++pkg debug/elf, const R_SW64_GOTTPREL R_SW64 | ||
| 45 | ++pkg debug/elf, const R_SW64_GPDISP = 6 | ||
| 46 | ++pkg debug/elf, const R_SW64_GPDISP R_SW64 | ||
| 47 | ++pkg debug/elf, const R_SW64_GPREL16 = 19 | ||
| 48 | ++pkg debug/elf, const R_SW64_GPREL16 R_SW64 | ||
| 49 | ++pkg debug/elf, const R_SW64_GPREL32 = 3 | ||
| 50 | ++pkg debug/elf, const R_SW64_GPREL32 R_SW64 | ||
| 51 | ++pkg debug/elf, const R_SW64_GPRELHIGH = 17 | ||
| 52 | ++pkg debug/elf, const R_SW64_GPRELHIGH R_SW64 | ||
| 53 | ++pkg debug/elf, const R_SW64_GPRELLOW = 18 | ||
| 54 | ++pkg debug/elf, const R_SW64_GPRELLOW R_SW64 | ||
| 55 | ++pkg debug/elf, const R_SW64_GPVALUE = 16 | ||
| 56 | ++pkg debug/elf, const R_SW64_GPVALUE R_SW64 | ||
| 57 | ++pkg debug/elf, const R_SW64_HINT = 8 | ||
| 58 | ++pkg debug/elf, const R_SW64_HINT R_SW64 | ||
| 59 | ++pkg debug/elf, const R_SW64_IMMED_BR_HI32 = 22 | ||
| 60 | ++pkg debug/elf, const R_SW64_IMMED_BR_HI32 R_SW64 | ||
| 61 | ++pkg debug/elf, const R_SW64_IMMED_GP_HI32 = 20 | ||
| 62 | ++pkg debug/elf, const R_SW64_IMMED_GP_HI32 R_SW64 | ||
| 63 | ++pkg debug/elf, const R_SW64_IMMED_LO32 = 23 | ||
| 64 | ++pkg debug/elf, const R_SW64_IMMED_LO32 R_SW64 | ||
| 65 | ++pkg debug/elf, const R_SW64_IMMED_SCN_HI32 = 21 | ||
| 66 | ++pkg debug/elf, const R_SW64_IMMED_SCN_HI32 R_SW64 | ||
| 67 | ++pkg debug/elf, const R_SW64_JMP_SLOT = 26 | ||
| 68 | ++pkg debug/elf, const R_SW64_JMP_SLOT R_SW64 | ||
| 69 | ++pkg debug/elf, const R_SW64_LITERAL = 4 | ||
| 70 | ++pkg debug/elf, const R_SW64_LITERAL R_SW64 | ||
| 71 | ++pkg debug/elf, const R_SW64_LITERAL_GOT = 43 | ||
| 72 | ++pkg debug/elf, const R_SW64_LITERAL_GOT R_SW64 | ||
| 73 | ++pkg debug/elf, const R_SW64_LITUSE = 5 | ||
| 74 | ++pkg debug/elf, const R_SW64_LITUSE R_SW64 | ||
| 75 | ++pkg debug/elf, const R_SW64_NONE = 0 | ||
| 76 | ++pkg debug/elf, const R_SW64_NONE R_SW64 | ||
| 77 | ++pkg debug/elf, const R_SW64_OP_PRSHIFT = 15 | ||
| 78 | ++pkg debug/elf, const R_SW64_OP_PRSHIFT R_SW64 | ||
| 79 | ++pkg debug/elf, const R_SW64_OP_PSUB = 14 | ||
| 80 | ++pkg debug/elf, const R_SW64_OP_PSUB R_SW64 | ||
| 81 | ++pkg debug/elf, const R_SW64_OP_PUSH = 12 | ||
| 82 | ++pkg debug/elf, const R_SW64_OP_PUSH R_SW64 | ||
| 83 | ++pkg debug/elf, const R_SW64_OP_STORE = 13 | ||
| 84 | ++pkg debug/elf, const R_SW64_OP_STORE R_SW64 | ||
| 85 | ++pkg debug/elf, const R_SW64_REFLONG = 1 | ||
| 86 | ++pkg debug/elf, const R_SW64_REFLONG R_SW64 | ||
| 87 | ++pkg debug/elf, const R_SW64_REFQUAD = 2 | ||
| 88 | ++pkg debug/elf, const R_SW64_REFQUAD R_SW64 | ||
| 89 | ++pkg debug/elf, const R_SW64_RELATIVE = 27 | ||
| 90 | ++pkg debug/elf, const R_SW64_RELATIVE R_SW64 | ||
| 91 | ++pkg debug/elf, const R_SW64_SREL16 = 9 | ||
| 92 | ++pkg debug/elf, const R_SW64_SREL16 R_SW64 | ||
| 93 | ++pkg debug/elf, const R_SW64_SREL32 = 10 | ||
| 94 | ++pkg debug/elf, const R_SW64_SREL32 R_SW64 | ||
| 95 | ++pkg debug/elf, const R_SW64_SREL64 = 11 | ||
| 96 | ++pkg debug/elf, const R_SW64_SREL64 R_SW64 | ||
| 97 | ++pkg debug/elf, const R_SW64_TLSGD = 29 | ||
| 98 | ++pkg debug/elf, const R_SW64_TLSGD R_SW64 | ||
| 99 | ++pkg debug/elf, const R_SW64_TLSLDM = 30 | ||
| 100 | ++pkg debug/elf, const R_SW64_TLSLDM R_SW64 | ||
| 101 | ++pkg debug/elf, const R_SW64_TPREL16 = 41 | ||
| 102 | ++pkg debug/elf, const R_SW64_TPREL16 R_SW64 | ||
| 103 | ++pkg debug/elf, const R_SW64_TPREL64 = 38 | ||
| 104 | ++pkg debug/elf, const R_SW64_TPREL64 R_SW64 | ||
| 105 | ++pkg debug/elf, const R_SW64_TPRELHI = 39 | ||
| 106 | ++pkg debug/elf, const R_SW64_TPRELHI R_SW64 | ||
| 107 | ++pkg debug/elf, const R_SW64_TPRELLO = 40 | ||
| 108 | ++pkg debug/elf, const R_SW64_TPRELLO R_SW64 | ||
| 109 | ++pkg debug/elf, method (R_SW64) GoString() string | ||
| 110 | ++pkg debug/elf, method (R_SW64) String() string | ||
| 111 | ++pkg debug/elf, type R_SW64 int | ||
| 112 | + pkg embed, method (FS) Open(string) (fs.File, error) | ||
| 113 | + pkg embed, method (FS) ReadDir(string) ([]fs.DirEntry, error) | ||
| 114 | + pkg embed, method (FS) ReadFile(string) ([]uint8, error) | ||
| 115 | +diff --git a/api/go1.18.txt b/api/go1.18.txt | ||
| 116 | +index 5040c95..9f4fc91 100644 | ||
| 117 | +--- a/api/go1.18.txt | ||
| 118 | ++++ b/api/go1.18.txt | ||
| 119 | +@@ -251,3 +251,11 @@ pkg text/template/parse, type ContinueNode struct, Line int | ||
| 120 | + pkg text/template/parse, type ContinueNode struct, embedded NodeType | ||
| 121 | + pkg text/template/parse, type ContinueNode struct, embedded Pos | ||
| 122 | + pkg unicode/utf8, func AppendRune([]uint8, int32) []uint8 | ||
| 123 | ++pkg debug/elf, const R_SW64_ADD_ABS_LO_16 = 47 | ||
| 124 | ++pkg debug/elf, const R_SW64_ADD_ABS_LO_16 R_SW64 | ||
| 125 | ++pkg debug/elf, const R_SW64_ADD_PCREL_HI_13 = 45 | ||
| 126 | ++pkg debug/elf, const R_SW64_ADD_PCREL_HI_13 R_SW64 | ||
| 127 | ++pkg debug/elf, const R_SW64_ADD_PCREL_LO_13 = 46 | ||
| 128 | ++pkg debug/elf, const R_SW64_ADD_PCREL_LO_13 R_SW64 | ||
| 129 | ++pkg debug/elf, const R_SW64_CALL26 = 48 | ||
| 130 | ++pkg debug/elf, const R_SW64_CALL26 R_SW64 | ||
| 131 | +-- | ||
| 132 | +2.33.0 | ||
| 133 | + | ||
| @@ -0,0 +1,228 @@ | |||
| 1 | +From f9a6d049284caf4462b23609fc2a6644b0332844 Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: swcompiler <lc@wxiat.com> | ||
| 3 | +Date: Fri, 21 Feb 2025 14:36:39 +0800 | ||
| 4 | +Subject: [PATCH 15/16] debug: Add sw64 port | ||
| 5 | + | ||
| 6 | +--- | ||
| 7 | + src/debug/elf/elf.go | 109 ++++++++++++++++++++++++++++++++++++++ | ||
| 8 | + src/debug/elf/elf_test.go | 1 + | ||
| 9 | + src/debug/elf/file.go | 50 +++++++++++++++++ | ||
| 10 | + 3 files changed, 160 insertions(+) | ||
| 11 | + | ||
| 12 | +diff --git a/src/debug/elf/elf.go b/src/debug/elf/elf.go | ||
| 13 | +index c982c68..108c88b 100644 | ||
| 14 | +--- a/src/debug/elf/elf.go | ||
| 15 | ++++ b/src/debug/elf/elf.go | ||
| 16 | +@@ -391,6 +391,7 @@ const ( | ||
| 17 | + EM_MIPS_RS4_BE Machine = 10 /* MIPS R4000 Big-Endian */ | ||
| 18 | + EM_ALPHA_STD Machine = 41 /* Digital Alpha (standard value). */ | ||
| 19 | + EM_ALPHA Machine = 0x9026 /* Alpha (written in the absence of an ABI) */ | ||
| 20 | ++ EM_SW64 Machine = 0x9916 | ||
| 21 | + ) | ||
| 22 | + | ||
| 23 | + var machineStrings = []intName{ | ||
| 24 | +@@ -583,6 +584,7 @@ var machineStrings = []intName{ | ||
| 25 | + {10, "EM_MIPS_RS4_BE"}, | ||
| 26 | + {41, "EM_ALPHA_STD"}, | ||
| 27 | + {0x9026, "EM_ALPHA"}, | ||
| 28 | ++ {0x9916, "EM_SW64"}, | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + func (i Machine) String() string { return stringName(uint32(i), machineStrings, false) } | ||
| 32 | +@@ -2972,6 +2974,113 @@ var rppc64Strings = []intName{ | ||
| 33 | + func (i R_PPC64) String() string { return stringName(uint32(i), rppc64Strings, false) } | ||
| 34 | + func (i R_PPC64) GoString() string { return stringName(uint32(i), rppc64Strings, true) } | ||
| 35 | + | ||
| 36 | ++// Relocation types for SW64. | ||
| 37 | ++type R_SW64 int | ||
| 38 | ++ | ||
| 39 | ++const ( | ||
| 40 | ++ R_SW64_NONE R_SW64 = 0 /* No reloc */ | ||
| 41 | ++ R_SW64_REFLONG R_SW64 = 1 /* Direct 32 bit */ | ||
| 42 | ++ R_SW64_REFQUAD R_SW64 = 2 /* Direct 64 bit */ | ||
| 43 | ++ R_SW64_GPREL32 R_SW64 = 3 /* GP relative 32 bit */ | ||
| 44 | ++ R_SW64_LITERAL R_SW64 = 4 /* GP relative 16 bit w/optimization */ | ||
| 45 | ++ R_SW64_LITUSE R_SW64 = 5 /* Optimization hint for LITERAL */ | ||
| 46 | ++ R_SW64_GPDISP R_SW64 = 6 /* Add displacement to GP */ | ||
| 47 | ++ R_SW64_BRADDR R_SW64 = 7 /* PC+4 relative 23 bit shifted */ | ||
| 48 | ++ R_SW64_HINT R_SW64 = 8 /* PC+4 relative 16 bit shifted */ | ||
| 49 | ++ R_SW64_SREL16 R_SW64 = 9 /* PC relative 16 bit */ | ||
| 50 | ++ R_SW64_SREL32 R_SW64 = 10 /* PC relative 32 bit */ | ||
| 51 | ++ R_SW64_SREL64 R_SW64 = 11 /* PC relative 64 bit */ | ||
| 52 | ++ R_SW64_OP_PUSH R_SW64 = 12 /* OP stack push */ /* Skip 12 - 16 on sw64; deprecated ECOFF relocs. Now copy 12 - 16 of ALPHA*/ | ||
| 53 | ++ R_SW64_OP_STORE R_SW64 = 13 /* OP stack pop and store */ | ||
| 54 | ++ R_SW64_OP_PSUB R_SW64 = 14 /* OP stack subtract */ | ||
| 55 | ++ R_SW64_OP_PRSHIFT R_SW64 = 15 /* OP stack right shift */ | ||
| 56 | ++ R_SW64_GPVALUE R_SW64 = 16 | ||
| 57 | ++ R_SW64_GPRELHIGH R_SW64 = 17 /* GP relative 32 bit, high 16 bits */ | ||
| 58 | ++ R_SW64_GPRELLOW R_SW64 = 18 /* GP relative 32 bit, low 16 bits */ | ||
| 59 | ++ R_SW64_GPREL16 R_SW64 = 19 /* GP relative 16 bit */ | ||
| 60 | ++ R_SW64_IMMED_GP_HI32 R_SW64 = 20 /* Skip 20 - 23 on sw64; deprecated ECOFF relocs. Now copy 20 - 23 of ALPHA*/ | ||
| 61 | ++ R_SW64_IMMED_SCN_HI32 R_SW64 = 21 | ||
| 62 | ++ R_SW64_IMMED_BR_HI32 R_SW64 = 22 | ||
| 63 | ++ R_SW64_IMMED_LO32 R_SW64 = 23 | ||
| 64 | ++ R_SW64_COPY R_SW64 = 24 /* Copy symbol at runtime */ | ||
| 65 | ++ R_SW64_GLOB_DAT R_SW64 = 25 /* Create GOT entry */ | ||
| 66 | ++ R_SW64_JMP_SLOT R_SW64 = 26 /* Create PLT entry */ | ||
| 67 | ++ R_SW64_RELATIVE R_SW64 = 27 /* Adjust by program base */ | ||
| 68 | ++ R_SW64_BRSGP R_SW64 = 28 /* Like BRADDR, but assert that the source and target object file share the same GP value, and adjust the target address for STO_SW64_STD_GPLOAD. */ | ||
| 69 | ++ R_SW64_TLSGD R_SW64 = 29 /* 29 - 41 Thread-Local Storage. */ | ||
| 70 | ++ R_SW64_TLSLDM R_SW64 = 30 | ||
| 71 | ++ R_SW64_DTPMOD64 R_SW64 = 31 | ||
| 72 | ++ R_SW64_GOTDTPREL R_SW64 = 32 | ||
| 73 | ++ R_SW64_DTPREL64 R_SW64 = 33 | ||
| 74 | ++ R_SW64_DTPRELHI R_SW64 = 34 | ||
| 75 | ++ R_SW64_DTPRELLO R_SW64 = 35 | ||
| 76 | ++ R_SW64_DTPREL16 R_SW64 = 36 | ||
| 77 | ++ R_SW64_GOTTPREL R_SW64 = 37 | ||
| 78 | ++ R_SW64_TPREL64 R_SW64 = 38 | ||
| 79 | ++ R_SW64_TPRELHI R_SW64 = 39 | ||
| 80 | ++ R_SW64_TPRELLO R_SW64 = 40 | ||
| 81 | ++ R_SW64_TPREL16 R_SW64 = 41 | ||
| 82 | ++ R_SW64_BR26ADDR R_SW64 = 42 | ||
| 83 | ++ R_SW64_LITERAL_GOT R_SW64 = 43 | ||
| 84 | ++ R_SW64_ADD_PCREL_HI_13 R_SW64 = 45 | ||
| 85 | ++ R_SW64_ADD_PCREL_LO_13 R_SW64 = 46 | ||
| 86 | ++ R_SW64_ADD_ABS_LO_16 R_SW64 = 47 | ||
| 87 | ++ R_SW64_CALL26 R_SW64 = 48 | ||
| 88 | ++) | ||
| 89 | ++ | ||
| 90 | ++var rsw64Strings = []intName{ | ||
| 91 | ++ {0, "R_SW64_NONE"}, | ||
| 92 | ++ {1, "R_SW64_REFLONG"}, | ||
| 93 | ++ {2, "R_SW64_REFQUAD"}, | ||
| 94 | ++ {3, "R_SW64_GPREL32"}, | ||
| 95 | ++ {4, "R_SW64_LITERAL"}, | ||
| 96 | ++ {5, "R_SW64_LITUSE"}, | ||
| 97 | ++ {6, "R_SW64_GPDISP"}, | ||
| 98 | ++ {7, "R_SW64_BRADDR"}, | ||
| 99 | ++ {8, "R_SW64_HINT"}, | ||
| 100 | ++ {9, "R_SW64_SREL16"}, | ||
| 101 | ++ {10, "R_SW64_SREL32"}, | ||
| 102 | ++ {11, "R_SW64_SREL64"}, | ||
| 103 | ++ {12, "R_SW64_OP_PUSH"}, | ||
| 104 | ++ {13, "R_SW64_OP_STORE"}, | ||
| 105 | ++ {14, "R_SW64_OP_PSUB"}, | ||
| 106 | ++ {15, "R_SW64_OP_PRSHIFT"}, | ||
| 107 | ++ {16, "R_SW64_GPVALUE"}, | ||
| 108 | ++ {17, "R_SW64_GPRELHIGH"}, | ||
| 109 | ++ {18, "R_SW64_GPRELLOW"}, | ||
| 110 | ++ {19, "R_SW64_GPREL16"}, | ||
| 111 | ++ {20, "R_SW64_IMMED_GP_HI32"}, | ||
| 112 | ++ {21, "R_SW64_IMMED_SCN_HI32"}, | ||
| 113 | ++ {22, "R_SW64_IMMED_BR_HI32"}, | ||
| 114 | ++ {23, "R_SW64_IMMED_LO32"}, | ||
| 115 | ++ {24, "R_SW64_COPY"}, | ||
| 116 | ++ {25, "R_SW64_GLOB_DAT"}, | ||
| 117 | ++ {26, "R_SW64_JMP_SLOT"}, | ||
| 118 | ++ {27, "R_SW64_RELATIVE"}, | ||
| 119 | ++ {28, "R_SW64_BRSGP"}, | ||
| 120 | ++ {29, "R_SW64_TLSGD"}, | ||
| 121 | ++ {30, "R_SW64_TLSLDM"}, | ||
| 122 | ++ {31, "R_SW64_DTPMOD64"}, | ||
| 123 | ++ {32, "R_SW64_GOTDTPREL"}, | ||
| 124 | ++ {33, "R_SW64_DTPREL64"}, | ||
| 125 | ++ {34, "R_SW64_DTPRELHI"}, | ||
| 126 | ++ {35, "R_SW64_DTPRELLO"}, | ||
| 127 | ++ {36, "R_SW64_DTPREL16"}, | ||
| 128 | ++ {37, "R_SW64_GOTTPREL"}, | ||
| 129 | ++ {38, "R_SW64_TPREL64"}, | ||
| 130 | ++ {39, "R_SW64_TPRELHI"}, | ||
| 131 | ++ {40, "R_SW64_TPRELLO"}, | ||
| 132 | ++ {41, "R_SW64_TPREL16"}, | ||
| 133 | ++ {42, "R_SW64_BR26ADDR"}, | ||
| 134 | ++ {43, "R_SW64_LITERAL_GOT"}, | ||
| 135 | ++ {45, "R_SW64_ADD_PCREL_HI_13"}, | ||
| 136 | ++ {46, "R_SW64_ADD_PCREL_LO_13"}, | ||
| 137 | ++ {47, "R_SW64_ADD_ABS_LO_16"}, | ||
| 138 | ++} | ||
| 139 | ++ | ||
| 140 | ++func (i R_SW64) String() string { return stringName(uint32(i), rsw64Strings, false) } | ||
| 141 | ++func (i R_SW64) GoString() string { return stringName(uint32(i), rsw64Strings, true) } | ||
| 142 | ++ | ||
| 143 | + // Relocation types for RISC-V processors. | ||
| 144 | + type R_RISCV int | ||
| 145 | + | ||
| 146 | +diff --git a/src/debug/elf/elf_test.go b/src/debug/elf/elf_test.go | ||
| 147 | +index 0350d53..81151a2 100644 | ||
| 148 | +--- a/src/debug/elf/elf_test.go | ||
| 149 | ++++ b/src/debug/elf/elf_test.go | ||
| 150 | +@@ -32,6 +32,7 @@ var nameTests = []nameTest{ | ||
| 151 | + {STV_HIDDEN, "STV_HIDDEN"}, | ||
| 152 | + {R_X86_64_PC32, "R_X86_64_PC32"}, | ||
| 153 | + {R_ALPHA_OP_PUSH, "R_ALPHA_OP_PUSH"}, | ||
| 154 | ++ {R_SW64_OP_PUSH, "R_SW64_OP_PUSH"}, | ||
| 155 | + {R_ARM_THM_ABS5, "R_ARM_THM_ABS5"}, | ||
| 156 | + {R_386_GOT32, "R_386_GOT32"}, | ||
| 157 | + {R_PPC_GOT16_HI, "R_PPC_GOT16_HI"}, | ||
| 158 | +diff --git a/src/debug/elf/file.go b/src/debug/elf/file.go | ||
| 159 | +index 7485337..62f9651 100644 | ||
| 160 | +--- a/src/debug/elf/file.go | ||
| 161 | ++++ b/src/debug/elf/file.go | ||
| 162 | +@@ -768,6 +768,8 @@ func (f *File) applyRelocations(dst []byte, rels []byte) error { | ||
| 163 | + return f.applyRelocationss390x(dst, rels) | ||
| 164 | + case f.Class == ELFCLASS64 && f.Machine == EM_SPARCV9: | ||
| 165 | + return f.applyRelocationsSPARC64(dst, rels) | ||
| 166 | ++ case f.Class == ELFCLASS64 && f.Machine == EM_SW64: | ||
| 167 | ++ return f.applyRelocationsSW64(dst, rels) | ||
| 168 | + default: | ||
| 169 | + return errors.New("applyRelocations: not implemented") | ||
| 170 | + } | ||
| 171 | +@@ -1321,6 +1323,54 @@ func (f *File) applyRelocationsSPARC64(dst []byte, rels []byte) error { | ||
| 172 | + return nil | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | ++func (f *File) applyRelocationsSW64(dst []byte, rels []byte) error { | ||
| 176 | ++ // 24 is the size of Rela64. | ||
| 177 | ++ if len(rels)%24 != 0 { | ||
| 178 | ++ return errors.New("length of relocation section is not a multiple of 24") | ||
| 179 | ++ } | ||
| 180 | ++ | ||
| 181 | ++ symbols, _, err := f.getSymbols(SHT_SYMTAB) | ||
| 182 | ++ if err != nil { | ||
| 183 | ++ return err | ||
| 184 | ++ } | ||
| 185 | ++ | ||
| 186 | ++ b := bytes.NewReader(rels) | ||
| 187 | ++ var rela Rela64 | ||
| 188 | ++ | ||
| 189 | ++ for b.Len() > 0 { | ||
| 190 | ++ binary.Read(b, f.ByteOrder, &rela) | ||
| 191 | ++ symNo := rela.Info >> 32 | ||
| 192 | ++ t := R_SW64(rela.Info & 0xffff) | ||
| 193 | ++ | ||
| 194 | ++ if symNo == 0 || symNo > uint64(len(symbols)) { | ||
| 195 | ++ continue | ||
| 196 | ++ } | ||
| 197 | ++ | ||
| 198 | ++ sym := &symbols[symNo-1] | ||
| 199 | ++ if !canApplyRelocation(sym) { | ||
| 200 | ++ // We don't handle non-section relocations for now. | ||
| 201 | ++ continue | ||
| 202 | ++ } | ||
| 203 | ++ switch t { | ||
| 204 | ++ case R_SW64_REFQUAD: | ||
| 205 | ++ if rela.Off+8 >= uint64(len(dst)) || rela.Addend < 0 { | ||
| 206 | ++ continue | ||
| 207 | ++ } | ||
| 208 | ++ val64 := sym.Value + uint64(rela.Addend) | ||
| 209 | ++ f.ByteOrder.PutUint64(dst[rela.Off:rela.Off+8], val64) | ||
| 210 | ++ case R_SW64_REFLONG: | ||
| 211 | ++ if rela.Off+4 >= uint64(len(dst)) || rela.Addend < 0 { | ||
| 212 | ++ continue | ||
| 213 | ++ } | ||
| 214 | ++ val32 := uint32(sym.Value) + uint32(rela.Addend) | ||
| 215 | ++ f.ByteOrder.PutUint32(dst[rela.Off:rela.Off+4], val32) | ||
| 216 | ++ } | ||
| 217 | ++ } | ||
| 218 | ++ | ||
| 219 | ++ return nil | ||
| 220 | ++} | ||
| 221 | ++ | ||
| 222 | ++ | ||
| 223 | + func (f *File) DWARF() (*dwarf.Data, error) { | ||
| 224 | + dwarfSuffix := func(s *Section) string { | ||
| 225 | + switch { | ||
| 226 | +-- | ||
| 227 | +2.33.0 | ||
| 228 | + | ||
| @@ -0,0 +1,39 @@ | |||
| 1 | +From f289163cd6cb41ec1ee7304cfb66a4aa9b7d69db Mon Sep 17 00:00:00 2001 | ||
| 2 | +From: swcompiler <lc@wxiat.com> | ||
| 3 | +Date: Fri, 21 Feb 2025 14:37:26 +0800 | ||
| 4 | +Subject: [PATCH 16/16] encoding,os: sw64 add var NativeEndian | ||
| 5 | + | ||
| 6 | +--- | ||
| 7 | + src/encoding/binary/native_endian_little.go | 2 +- | ||
| 8 | + src/os/endian_little.go | 2 +- | ||
| 9 | + 2 files changed, 2 insertions(+), 2 deletions(-) | ||
| 10 | + | ||
| 11 | +diff --git a/src/encoding/binary/native_endian_little.go b/src/encoding/binary/native_endian_little.go | ||
| 12 | +index 67b41ae..bb904d9 100644 | ||
| 13 | +--- a/src/encoding/binary/native_endian_little.go | ||
| 14 | ++++ b/src/encoding/binary/native_endian_little.go | ||
| 15 | +@@ -2,7 +2,7 @@ | ||
| 16 | + // Use of this source code is governed by a BSD-style | ||
| 17 | + // license that can be found in the LICENSE file. | ||
| 18 | + | ||
| 19 | +-//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh || wasm | ||
| 20 | ++//go:build 386 || amd64 || amd64p32 || alpha || arm || arm64 || loong64 || mipsle || mips64le || mips64p32le || nios2 || ppc64le || riscv || riscv64 || sh || wasm || sw64 | ||
| 21 | + | ||
| 22 | + package binary | ||
| 23 | + | ||
| 24 | +diff --git a/src/os/endian_little.go b/src/os/endian_little.go | ||
| 25 | +index a7cf1cd..ebf2fd7 100644 | ||
| 26 | +--- a/src/os/endian_little.go | ||
| 27 | ++++ b/src/os/endian_little.go | ||
| 28 | +@@ -2,7 +2,7 @@ | ||
| 29 | + // Use of this source code is governed by a BSD-style | ||
| 30 | + // license that can be found in the LICENSE file. | ||
| 31 | + // | ||
| 32 | +-//go:build 386 || amd64 || arm || arm64 || loong64 || ppc64le || mips64le || mipsle || riscv64 || wasm | ||
| 33 | ++//go:build 386 || amd64 || arm || arm64 || loong64 || ppc64le || mips64le || mipsle || riscv64 || wasm || sw64 | ||
| 34 | + | ||
| 35 | + package os | ||
| 36 | + | ||
| 37 | +-- | ||
| 38 | +2.33.0 | ||
| 39 | + | ||
| @@ -12,19 +12,19 @@ | |||
| 12 | %define __find_requires %{nil} | 12 | %define __find_requires %{nil} |
| 13 | 13 | ||
| 14 | %bcond_with bootstrap | 14 | %bcond_with bootstrap |
| 15 | -%ifarch x86_64 aarch64 riscv64 loongarch64 ppc64le | 15 | +%ifarch x86_64 aarch64 riscv64 loongarch64 ppc64le sw64 |
| 16 | %bcond_without ignore_tests | 16 | %bcond_without ignore_tests |
| 17 | %else | 17 | %else |
| 18 | %bcond_with ignore_tests | 18 | %bcond_with ignore_tests |
| 19 | %endif | 19 | %endif |
| 20 | 20 | ||
| 21 | -%ifarch x86_64 aarch64 riscv64 loongarch64 ppc64le | 21 | +%ifarch x86_64 aarch64 riscv64 loongarch64 ppc64le sw64 |
| 22 | %global external_linker 1 | 22 | %global external_linker 1 |
| 23 | %else | 23 | %else |
| 24 | %global external_linker 0 | 24 | %global external_linker 0 |
| 25 | %endif | 25 | %endif |
| 26 | 26 | ||
| 27 | -%ifarch x86_64 aarch64 riscv64 loongarch64 ppc64le | 27 | +%ifarch x86_64 aarch64 riscv64 loongarch64 ppc64le sw64 |
| 28 | %global cgo_enabled 1 | 28 | %global cgo_enabled 1 |
| 29 | %else | 29 | %else |
| 30 | %global cgo_enabled 0 | 30 | %global cgo_enabled 0 |
| @@ -63,10 +63,13 @@ | |||
| 63 | %ifarch loongarch64 | 63 | %ifarch loongarch64 |
| 64 | %global gohostarch loong64 | 64 | %global gohostarch loong64 |
| 65 | %endif | 65 | %endif |
| 66 | +%ifarch sw_64 | ||
| 67 | +%global gohostarch sw64 | ||
| 68 | +%endif | ||
| 66 | 69 | ||
| 67 | Name: golang | 70 | Name: golang |
| 68 | Version: 1.21.4 | 71 | Version: 1.21.4 |
| 69 | -Release: 39 | 72 | +Release: 40 |
| 70 | Summary: The Go Programming Language | 73 | Summary: The Go Programming Language |
| 71 | License: BSD and Public Domain | 74 | License: BSD and Public Domain |
| 72 | URL: https://golang.org/ | 75 | URL: https://golang.org/ |
| @@ -165,6 +168,27 @@ Patch6042: backport-0042-CVE-2025-58187-crypto-x509-improve-domain-name-verific | |||
| 165 | Patch6043: backport-0043-CVE-2025-58187-crypto-x509-rework-fix-for-CVE-2025-58187.patch | 168 | Patch6043: backport-0043-CVE-2025-58187-crypto-x509-rework-fix-for-CVE-2025-58187.patch |
| 166 | Patch6044: backport-0044-CVE-2025-61723-encoding-pem-make-Decode-complexity-linear.patch | 169 | Patch6044: backport-0044-CVE-2025-61723-encoding-pem-make-Decode-complexity-linear.patch |
| 167 | 170 | ||
| 171 | +# Part 1001 ~ 1999 | ||
| 172 | +#sw arch specified | ||
| 173 | +%ifarch sw_64 | ||
| 174 | +Patch1001: 1001-cmd-comile-Add-sw64-port-not-upstream.patch | ||
| 175 | +Patch1002: 1002-cmd-internal-obj-Add-sw64-port-not-upstream.patch | ||
| 176 | +Patch1003: 1003-cmd-link-Add-sw64-port-not-upstream.patch | ||
| 177 | +Patch1004: 1004-cmd-asm-Add-sw64-port-not-upstream.patch | ||
| 178 | +Patch1005: 1005-runtime-Add-sw64-port-not-upstream.patch | ||
| 179 | +Patch1006: 1006-syscall-Add-sw64-port-not-upstream.patch | ||
| 180 | +Patch1007: 1007-cmd-dist-Add-sw64-port-not-upstream.patch | ||
| 181 | +Patch1008: 1008-cmd-cgo-Add-sw64-port-not-upstream.patch | ||
| 182 | +Patch1009: 1009-reflect-Add-sw64-port-not-upstream.patch | ||
| 183 | +Patch1010: 1010-cmd-vendor-vendor-Add-sw64-port-not-upstream.patch | ||
| 184 | +Patch1011: 1011-cmd-go-go-Add-sw64-port-not-upstream.patch | ||
| 185 | +Patch1012: 1012-src-internal-Add-sw64-port-not-upstream.patch | ||
| 186 | +Patch1013: 1013-crypto-hash-math-Add-sw64-port-not-upstream.patch | ||
| 187 | +Patch1014: 1014-api-Add-sw64-port-not-upstream.patch | ||
| 188 | +Patch1015: 1015-debug-Add-sw64-port-not-upstream.patch | ||
| 189 | +Patch1016: 1016-encoding-os-sw64-add-var-NativeEndian-not-upstream.patch | ||
| 190 | +%endif | ||
| 191 | + | ||
| 168 | # Part 8001 ~ 8999 | 192 | # Part 8001 ~ 8999 |
| 169 | # Developed optimization features | 193 | # Developed optimization features |
| 170 | Patch8001: 8001-runtime-add-kunpeng-malloc-optimize.patch | 194 | Patch8001: 8001-runtime-add-kunpeng-malloc-optimize.patch |
| @@ -409,6 +433,12 @@ fi | |||
| 409 | %files devel -f go-tests.list -f go-misc.list -f go-src.list | 433 | %files devel -f go-tests.list -f go-misc.list -f go-src.list |
| 410 | 434 | ||
| 411 | %changelog | 435 | %changelog |
| 436 | +* Fri Dec 5 2025 swcompiler <lc@wxiat.com> - 1.21.4-40 | ||
| 437 | +- Type: Sw64 | ||
| 438 | +- CVE:NA | ||
| 439 | +- SUG:NA | ||
| 440 | +- DESC: Add sw64 architecture support. | ||
| 441 | + | ||
| 412 | * Fri Nov 14 2025 zhaoyifan <stopire@gmail.com> - 1.21.4-39 | 442 | * Fri Nov 14 2025 zhaoyifan <stopire@gmail.com> - 1.21.4-39 |
| 413 | - Type:CVE | 443 | - Type:CVE |
| 414 | - CVE:CVE-2025-58187,CVE-2025-61723 | 444 | - CVE:CVE-2025-58187,CVE-2025-61723 |