mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
syscall: clean up mkasm related changes
The mkasm_darwin.go file was renamed to mkasm.go in CL 270380, with OpenBSD support being added. The mkasm_openbsd.go file should not have been merged, so remove it. Fix up references to mkasm_$GOOS.go and provide $GOOS as an argument on invocation. Updates #36435 Change-Id: I868d3f2146973d026e6a663d437749dbb6b312ec Reviewed-on: https://go-review.googlesource.com/c/go/+/286812 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
210f70e298
commit
5cdf0da1bf
3 changed files with 5 additions and 63 deletions
|
|
@ -125,13 +125,13 @@ darwin_amd64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
mksyscall="./mksyscall.pl -darwin"
|
mksyscall="./mksyscall.pl -darwin"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
mkasm="go run mkasm_darwin.go"
|
mkasm="go run mkasm.go"
|
||||||
;;
|
;;
|
||||||
darwin_arm64)
|
darwin_arm64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
mksyscall="./mksyscall.pl -darwin"
|
mksyscall="./mksyscall.pl -darwin"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
mkasm="go run mkasm_darwin.go"
|
mkasm="go run mkasm.go"
|
||||||
;;
|
;;
|
||||||
dragonfly_amd64)
|
dragonfly_amd64)
|
||||||
mkerrors="$mkerrors -m64"
|
mkerrors="$mkerrors -m64"
|
||||||
|
|
@ -299,7 +299,7 @@ openbsd_amd64)
|
||||||
zsysctl="zsysctl_openbsd.go"
|
zsysctl="zsysctl_openbsd.go"
|
||||||
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
|
mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
|
||||||
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
mktypes="GOARCH=$GOARCH go tool cgo -godefs"
|
||||||
mkasm="go run mkasm_openbsd.go"
|
mkasm="go run mkasm.go"
|
||||||
;;
|
;;
|
||||||
openbsd_arm)
|
openbsd_arm)
|
||||||
GOOSARCH_in="syscall_openbsd1.go syscall_openbsd_$GOARCH.go"
|
GOOSARCH_in="syscall_openbsd1.go syscall_openbsd_$GOARCH.go"
|
||||||
|
|
@ -372,5 +372,5 @@ esac
|
||||||
# Therefore, "go run" tries to recompile syscall package but ztypes is empty and it fails.
|
# Therefore, "go run" tries to recompile syscall package but ztypes is empty and it fails.
|
||||||
echo "$mktypes types_$GOOS.go |go run mkpost.go >ztypes_$GOOSARCH.go.NEW && mv ztypes_$GOOSARCH.go.NEW ztypes_$GOOSARCH.go";
|
echo "$mktypes types_$GOOS.go |go run mkpost.go >ztypes_$GOOSARCH.go.NEW && mv ztypes_$GOOSARCH.go.NEW ztypes_$GOOSARCH.go";
|
||||||
fi
|
fi
|
||||||
if [ -n "$mkasm" ]; then echo "$mkasm $GOARCH"; fi
|
if [ -n "$mkasm" ]; then echo "$mkasm $GOOS $GOARCH"; fi
|
||||||
) | $run
|
) | $run
|
||||||
|
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
||||||
// Copyright 2020 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.
|
|
||||||
|
|
||||||
// +build ignore
|
|
||||||
|
|
||||||
// mkasm_openbsd.go generates assembly trampolines to call libc routines from Go.
|
|
||||||
// This program must be run after mksyscall.pl.
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
in1, err := ioutil.ReadFile("syscall_openbsd.go")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("can't open syscall_openbsd.go: %s", err)
|
|
||||||
}
|
|
||||||
arch := os.Args[1]
|
|
||||||
in2, err := ioutil.ReadFile(fmt.Sprintf("syscall_openbsd_%s.go", arch))
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("can't open syscall_openbsd_%s.go: %s", arch, err)
|
|
||||||
}
|
|
||||||
in3, err := ioutil.ReadFile(fmt.Sprintf("zsyscall_openbsd_%s.go", arch))
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("can't open zsyscall_openbsd_%s.go: %s", arch, err)
|
|
||||||
}
|
|
||||||
in := string(in1) + string(in2) + string(in3)
|
|
||||||
|
|
||||||
trampolines := map[string]bool{}
|
|
||||||
|
|
||||||
var out bytes.Buffer
|
|
||||||
|
|
||||||
fmt.Fprintf(&out, "// go run mkasm_openbsd.go %s\n", strings.Join(os.Args[1:], " "))
|
|
||||||
fmt.Fprintf(&out, "// Code generated by the command above; DO NOT EDIT.\n")
|
|
||||||
fmt.Fprintf(&out, "#include \"textflag.h\"\n")
|
|
||||||
for _, line := range strings.Split(in, "\n") {
|
|
||||||
if !strings.HasPrefix(line, "func ") || !strings.HasSuffix(line, "_trampoline()") {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
fn := line[5 : len(line)-13]
|
|
||||||
if !trampolines[fn] {
|
|
||||||
trampolines[fn] = true
|
|
||||||
fmt.Fprintf(&out, "TEXT ·%s_trampoline(SB),NOSPLIT,$0-0\n", fn)
|
|
||||||
fmt.Fprintf(&out, "\tJMP\t%s(SB)\n", fn)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
err = ioutil.WriteFile(fmt.Sprintf("zsyscall_openbsd_%s.s", arch), out.Bytes(), 0644)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("can't write zsyscall_openbsd_%s.s: %s", arch, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -352,7 +352,7 @@ while(<>) {
|
||||||
# The assembly trampoline that jumps to the libc routine.
|
# The assembly trampoline that jumps to the libc routine.
|
||||||
$text .= "func ${funcname}_trampoline()\n";
|
$text .= "func ${funcname}_trampoline()\n";
|
||||||
# Map syscall.funcname to just plain funcname.
|
# Map syscall.funcname to just plain funcname.
|
||||||
# (The jump to this function is in the assembly trampoline, generated by mkasm_$GOOS.go.)
|
# (The jump to this function is in the assembly trampoline, generated by mkasm.go.)
|
||||||
$text .= "//go:linkname $funcname $funcname\n";
|
$text .= "//go:linkname $funcname $funcname\n";
|
||||||
# Tell the linker that funcname can be found in libSystem using varname without the libc_ prefix.
|
# Tell the linker that funcname can be found in libSystem using varname without the libc_ prefix.
|
||||||
my $basename = substr $funcname, 5;
|
my $basename = substr $funcname, 5;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue