]> Cypherpunks.ru repositories - gostls13.git/commitdiff
[dev.regabi] all: merge master (fca94ab) into dev.regabi
authorRobert Griesemer <gri@golang.org>
Tue, 2 Feb 2021 18:27:02 +0000 (10:27 -0800)
committerRobert Griesemer <gri@golang.org>
Tue, 2 Feb 2021 18:27:02 +0000 (10:27 -0800)
Conflicts:

- src/syscall/mksyscall.pl

Merge List:

+ 2021-02-02 fca94ab3ab spec: improve the example in Type assertions section
+ 2021-02-02 98f8454a73 cmd/link: don't decode type symbol in shared library in deadcode
+ 2021-02-02 1426a571b7 cmd/link: fix off-by-1 error in findShlibSection
+ 2021-02-01 32e789f4fb test: fix incorrectly laid out instructions in issue11656.go
+ 2021-02-01 0b6cfea634 doc/go1.16: document that on OpenBSD syscalls are now made through libc
+ 2021-02-01 26e29aa15a cmd/link: disable TestPIESize if CGO isn't enabled
+ 2021-02-01 6ac91e460c doc/go1.16: minor markup fixes
+ 2021-01-29 44361140c0 embed: update docs for proposal tweaks
+ 2021-01-29 68058edc39 runtime: document pointer write atomicity for memclrNoHeapPointers
+ 2021-01-28 c8bd8010ff syscall: generate readlen/writelen for openbsd libc
+ 2021-01-28 41bb49b878 cmd/go: revert TestScript/build_trimpath to use ioutil.ReadFile
+ 2021-01-28 725a642c2d runtime: correct syscall10/syscall10X on openbsd/amd64
+ 2021-01-28 4b068cafb5 doc/go1.16: document go/build/constraint package
+ 2021-01-28 376518d77f runtime,syscall: convert syscall on openbsd/arm64 to libc
+ 2021-01-27 00f2ff5c94 api/go1.16: add go/build/constraint APIs
+ 2021-01-27 35334caf18 crypto/x509: remove leftover CertificateRequest field
+ 2021-01-27 a5a5e2c968 runtime: make sure to remove open-coded defer entries in all cases after a recover
+ 2021-01-27 8cfa01943a runtime: block console ctrlhandler when the signal is handled
+ 2021-01-27 ff9e8364c6 cmd/go: skip issue33139 when the 'cc' script command is unavailable
+ 2021-01-27 cd176b3615 runtime: switch runtime to libc for openbsd/arm64
+ 2021-01-27 6c8fbfbdcf runtime: convert openbsd/arm64 locking to libc
+ 2021-01-27 5cdf0da1bf syscall: clean up mkasm related changes
+ 2021-01-27 210f70e298 doc/go1.16: fix closing brace in .Export format
+ 2021-01-27 0f797f168d math: fix typo in sqrt.go code comment
+ 2021-01-26 8634a234df runtime,syscall: convert syscall on openbsd/amd64 to libc
+ 2021-01-26 1d5e14632e os: further document limitations around naked file descriptors
+ 2021-01-26 cf263e9f77 os: correct names in CreateTemp and MkdirTemp doc comments
+ 2021-01-26 ce8b318624 net/http/fcgi: remove locking added to prevent a test-only race

Change-Id: I9e89df040dfbbeb50f4ce653a8da437cb72b3ef9

69 files changed:
api/go1.16.txt
doc/go1.16.html
doc/go_spec.html
misc/cgo/testshared/shared_test.go
misc/cgo/testshared/testdata/issue44031/a/a.go [new file with mode: 0644]
misc/cgo/testshared/testdata/issue44031/b/b.go [new file with mode: 0644]
misc/cgo/testshared/testdata/issue44031/main/main.go [new file with mode: 0644]
src/cmd/go/testdata/script/build_trimpath.txt
src/cmd/go/testdata/script/link_syso_issue33139.txt
src/cmd/link/elf_test.go
src/cmd/link/internal/ld/deadcode.go
src/cmd/link/internal/ld/decodesym.go
src/crypto/x509/x509.go
src/crypto/x509/x509_test.go
src/embed/embed.go
src/math/sqrt.go
src/net/http/fcgi/child.go
src/net/http/fcgi/fcgi_test.go
src/os/file_unix.go
src/os/tempfile.go
src/runtime/crash_test.go
src/runtime/defer_test.go
src/runtime/defs_openbsd_arm64.go
src/runtime/memclr_386.s
src/runtime/memclr_amd64.s
src/runtime/memclr_arm.s
src/runtime/memclr_arm64.s
src/runtime/memclr_mips64x.s
src/runtime/memclr_mipsx.s
src/runtime/memclr_plan9_386.s
src/runtime/memclr_plan9_amd64.s
src/runtime/memclr_ppc64x.s
src/runtime/memclr_riscv64.s
src/runtime/memclr_s390x.s
src/runtime/memclr_wasm.s
src/runtime/os_openbsd_syscall1.go
src/runtime/os_openbsd_syscall2.go
src/runtime/os_windows.go
src/runtime/panic.go
src/runtime/proc.go
src/runtime/signal_windows_test.go
src/runtime/stubs.go
src/runtime/sys_openbsd1.go
src/runtime/sys_openbsd2.go
src/runtime/sys_openbsd3.go [new file with mode: 0644]
src/runtime/sys_openbsd_amd64.s
src/runtime/sys_openbsd_arm64.s
src/runtime/testdata/testprog/deadlock.go
src/runtime/testdata/testwinsignal/main.go [new file with mode: 0644]
src/syscall/asm9_unix1_amd64.s
src/syscall/asm_openbsd_amd64.s [new file with mode: 0644]
src/syscall/asm_openbsd_arm64.s
src/syscall/asm_unix_amd64.s
src/syscall/exec_bsd.go
src/syscall/exec_libc2.go [moved from src/syscall/exec_darwin.go with 99% similarity]
src/syscall/exec_unix.go
src/syscall/mkall.sh
src/syscall/mkasm.go [moved from src/syscall/mkasm_darwin.go with 51% similarity]
src/syscall/mksyscall.pl
src/syscall/syscall_openbsd.go
src/syscall/syscall_openbsd1.go [new file with mode: 0644]
src/syscall/syscall_openbsd_libc.go [new file with mode: 0644]
src/syscall/zsyscall_darwin_amd64.s
src/syscall/zsyscall_darwin_arm64.s
src/syscall/zsyscall_openbsd_amd64.go
src/syscall/zsyscall_openbsd_amd64.s [new file with mode: 0644]
src/syscall/zsyscall_openbsd_arm64.go
src/syscall/zsyscall_openbsd_arm64.s [new file with mode: 0644]
test/fixedbugs/issue11656.go

index 6e1f8ca91d73df1b86100976a052196a2858f3ef..ce015fd6fb7ebdc8f7dfac932737d5ff18228fa9 100644 (file)
@@ -232,6 +232,35 @@ pkg go/build, type Package struct, TestEmbedPatterns []string
 pkg go/build, type Package struct, TestEmbedPatternPos map[string][]token.Position
 pkg go/build, type Package struct, XTestEmbedPatterns []string
 pkg go/build, type Package struct, XTestEmbedPatternPos map[string][]token.Position
+pkg go/build/constraint, func IsGoBuild(string) bool
+pkg go/build/constraint, func IsPlusBuild(string) bool
+pkg go/build/constraint, func Parse(string) (Expr, error)
+pkg go/build/constraint, func PlusBuildLines(Expr) ([]string, error)
+pkg go/build/constraint, method (*AndExpr) Eval(func(string) bool) bool
+pkg go/build/constraint, method (*AndExpr) String() string
+pkg go/build/constraint, method (*NotExpr) Eval(func(string) bool) bool
+pkg go/build/constraint, method (*NotExpr) String() string
+pkg go/build/constraint, method (*OrExpr) Eval(func(string) bool) bool
+pkg go/build/constraint, method (*OrExpr) String() string
+pkg go/build/constraint, method (*SyntaxError) Error() string
+pkg go/build/constraint, method (*TagExpr) Eval(func(string) bool) bool
+pkg go/build/constraint, method (*TagExpr) String() string
+pkg go/build/constraint, type AndExpr struct
+pkg go/build/constraint, type AndExpr struct, X Expr
+pkg go/build/constraint, type AndExpr struct, Y Expr
+pkg go/build/constraint, type Expr interface, Eval(func(string) bool) bool
+pkg go/build/constraint, type Expr interface, String() string
+pkg go/build/constraint, type Expr interface, unexported methods
+pkg go/build/constraint, type NotExpr struct
+pkg go/build/constraint, type NotExpr struct, X Expr
+pkg go/build/constraint, type OrExpr struct
+pkg go/build/constraint, type OrExpr struct, X Expr
+pkg go/build/constraint, type OrExpr struct, Y Expr
+pkg go/build/constraint, type SyntaxError struct
+pkg go/build/constraint, type SyntaxError struct, Err string
+pkg go/build/constraint, type SyntaxError struct, Offset int
+pkg go/build/constraint, type TagExpr struct
+pkg go/build/constraint, type TagExpr struct, Tag string
 pkg html/template, func ParseFS(fs.FS, ...string) (*Template, error)
 pkg html/template, method (*Template) ParseFS(fs.FS, ...string) (*Template, error)
 pkg io, func NopCloser(Reader) ReadCloser
index 7ddb4a935ec1c860615e2b716c09b7dd65840102..8d31f63fa2a12eecd2f63b1e6e8694e1776925c9 100644 (file)
@@ -80,6 +80,16 @@ Do not send CLs removing the interior tags from such phrases.
   support cgo.
 </p>
 
+<p><!-- golang.org/issue/36435, many CLs -->
+  On the 64-bit x86 and 64-bit ARM architectures on OpenBSD (the
+  <code>openbsd/amd64</code> and <code>openbsd/arm64</code> ports), system
+  calls are now made through <code>libc</code>, instead of directly using
+  the <code>SYSCALL</code>/<code>SVC</code> instruction. This ensures
+  forward-compatibility with future versions of OpenBSD. In particular,
+  OpenBSD 6.9 onwards will require system calls to be made through
+  <code>libc</code> for non-static Go binaries.
+</p>
+
 <h3 id="386">386</h3>
 
 <p><!-- golang.org/issue/40255, golang.org/issue/41848, CL 258957, and CL 260017 -->
@@ -146,7 +156,7 @@ Do not send CLs removing the interior tags from such phrases.
   <code>retract</code> directives may now be used in a <code>go.mod</code> file
   to indicate that certain published versions of the module should not be used
   by other modules. A module author may retract a version after a severe problem
-  is discovered or if the version was published unintentionally.<br>
+  is discovered or if the version was published unintentionally.
 </p>
 
 <p><!-- golang.org/issue/26603 -->
@@ -275,7 +285,7 @@ Do not send CLs removing the interior tags from such phrases.
   When the <code>-export</code> flag is specified, the <code>BuildID</code>
   field is now set to the build ID of the compiled package. This is equivalent
   to running <code>go</code> <code>tool</code> <code>buildid</code> on
-  <code>go</code> <code>list</code> <code>-exported</code> <code>-f</code> <code>{{.Export}</code>,
+  <code>go</code> <code>list</code> <code>-exported</code> <code>-f</code> <code>{{.Export}}</code>,
   but without the extra step.
 </p>
 
@@ -762,6 +772,25 @@ func TestFoo(t *testing.T) {
   </dd>
 </dl><!-- go/build -->
 
+<dl id="go/build/constraint"><dt><a href="/pkg/go/build/constraint/">go/build/constraint</a></dt>
+  <dd>
+    <p><!-- CL 240604 -->
+      The new
+      <a href="/pkg/go/build/constraint/"><code>go/build/constraint</code></a>
+      package parses build constraint lines, both the original
+      <code>// +build</code> syntax and the <code>//go:build</code>
+      syntax that will be introduced in Go 1.17.
+      This package exists so that tools built with Go 1.16 will be able
+      to process Go 1.17 source code.
+      See <a href="https://golang.org/design/draft-gobuild">https://golang.org/design/draft-gobuild</a>
+      for details about the build constraint syntaxes and the planned
+      transition to the <code>//go:build</code> syntax.
+      Note that <code>//go:build</code> lines are <b>not</b> supported
+      in Go 1.16 and should not be introduced into Go programs yet.
+    </p>
+  </dd>
+</dl><!-- go/build/constraint -->
+
 <dl id="html/template"><dt><a href="/pkg/html/template/">html/template</a></dt>
   <dd>
     <p><!-- CL 243938 -->
@@ -880,7 +909,7 @@ func TestFoo(t *testing.T) {
     </p>
 
     <p><!-- CL 250039 -->
-      The <a href="/pkg/net/http/#Client">Client</a> now sends
+      The <a href="/pkg/net/http/#Client"><code>Client</code></a> now sends
       an explicit <code>Content-Length:</code> <code>0</code>
       header in <code>PATCH</code> requests with empty bodies,
       matching the existing behavior of <code>POST</code> and <code>PUT</code>.
@@ -927,7 +956,7 @@ func TestFoo(t *testing.T) {
 <dl id="net/smtp"><dt><a href="/pkg/net/smtp/">net/smtp</a></dt>
   <dd>
     <p><!-- CL 247257 -->
-      The <a href="/pkg/net/smtp/#Client">Client</a>'s
+      The <a href="/pkg/net/smtp/#Client"><code>Client</code></a>'s
       <a href="/pkg/net/smtp/#Client.Mail"><code>Mail</code></a>
       method now sends the <code>SMTPUTF8</code> directive to
       servers that support it, signaling that addresses are encoded in UTF-8.
index 676407f6f2bfd0799393da0ad40bbcfd4fc56eb6..c9e14a3fec70b8762de6c1a9e6d0d80ad6c45fdc 100644 (file)
@@ -1,6 +1,6 @@
 <!--{
        "Title": "The Go Programming Language Specification",
-       "Subtitle": "Version of Oct 7, 2020",
+       "Subtitle": "Version of Feb 2, 2021",
        "Path": "/ref/spec"
 }-->
 
@@ -3400,7 +3400,7 @@ A type assertion used in an <a href="#Assignments">assignment</a> or initializat
 v, ok = x.(T)
 v, ok := x.(T)
 var v, ok = x.(T)
-var v, ok T1 = x.(T)
+var v, ok interface{} = x.(T) // dynamic types of v and ok are T and bool
 </pre>
 
 <p>
index 5e0893784b69d74cca9350719c313748121c2230..f52391c6f6c6ab1750fce523ad87606f25a5c708 100644 (file)
@@ -1063,3 +1063,11 @@ func TestGCData(t *testing.T) {
        goCmd(t, "build", "-linkshared", "./gcdata/main")
        runWithEnv(t, "running gcdata/main", []string{"GODEBUG=clobberfree=1"}, "./main")
 }
+
+// Test that we don't decode type symbols from shared libraries (which has no data,
+// causing panic). See issue 44031.
+func TestIssue44031(t *testing.T) {
+       goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue44031/a")
+       goCmd(t, "install", "-buildmode=shared", "-linkshared", "./issue44031/b")
+       goCmd(t, "run", "-linkshared", "./issue44031/main")
+}
diff --git a/misc/cgo/testshared/testdata/issue44031/a/a.go b/misc/cgo/testshared/testdata/issue44031/a/a.go
new file mode 100644 (file)
index 0000000..48827e6
--- /dev/null
@@ -0,0 +1,9 @@
+// Copyright 2021 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.
+
+package a
+
+type ATypeWithALoooooongName interface { // a long name, so the type descriptor symbol name is mangled
+       M()
+}
diff --git a/misc/cgo/testshared/testdata/issue44031/b/b.go b/misc/cgo/testshared/testdata/issue44031/b/b.go
new file mode 100644 (file)
index 0000000..ad3ebec
--- /dev/null
@@ -0,0 +1,17 @@
+// Copyright 2021 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.
+
+package b
+
+import "testshared/issue44031/a"
+
+type T int
+
+func (T) M() {}
+
+var i = a.ATypeWithALoooooongName(T(0))
+
+func F() {
+       i.M()
+}
diff --git a/misc/cgo/testshared/testdata/issue44031/main/main.go b/misc/cgo/testshared/testdata/issue44031/main/main.go
new file mode 100644 (file)
index 0000000..47f2e3a
--- /dev/null
@@ -0,0 +1,20 @@
+// Copyright 2021 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.
+
+package main
+
+import "testshared/issue44031/b"
+
+type t int
+
+func (t) m() {}
+
+type i interface{ m() } // test that unexported method is correctly marked
+
+var v interface{} = t(0)
+
+func main() {
+       b.F()
+       v.(i).m()
+}
index e1ea0a48b2acfec72a585b6d31cb05718dc9c42b..2c3bee8fdc7a925bb9bd9bdcee078a36b0ed9581 100644 (file)
@@ -121,6 +121,7 @@ package main
 import (
        "bytes"
        "fmt"
+       "io/ioutil"
        "log"
        "os"
        "os/exec"
@@ -130,7 +131,7 @@ import (
 
 func main() {
        exe := os.Args[1]
-       data, err := os.ReadFile(exe)
+       data, err := ioutil.ReadFile(exe)
        if err != nil {
                log.Fatal(err)
        }
index 26034c9626661d6fa2ee3a27d0ae48390951b2c0..8a8cb4aa8c20f045a0c1e7c077bc950c35f95136 100644 (file)
@@ -2,7 +2,7 @@
 # embedded in a package, that is referenced by a Go assembly function.
 # See issue 33139.
 [!gc] skip
-[!exec:cc] skip
+[!cgo] skip
 
 # External linking is not supported on linux/ppc64.
 # See: https://github.com/golang/go/issues/8912
index 334f050e8819f5a526062951f169d85a993efdbd..20754d09f5ac9d0c085d251463d0e172a59bfedd 100644 (file)
@@ -226,6 +226,12 @@ func main() {
 
 func TestPIESize(t *testing.T) {
        testenv.MustHaveGoBuild(t)
+
+       // We don't want to test -linkmode=external if cgo is not supported.
+       // On some systems -buildmode=pie implies -linkmode=external, so just
+       // always skip the test if cgo is not supported.
+       testenv.MustHaveCGO(t)
+
        if !sys.BuildModeSupported(runtime.Compiler, "pie", runtime.GOOS, runtime.GOARCH) {
                t.Skip("-buildmode=pie not supported")
        }
index d8813fa9361c67a3ec8668f1509a56ffe3c76480..245076a83a5c32c204c0a28d03e7059dfa2f9300 100644 (file)
@@ -165,13 +165,17 @@ func (d *deadcodePass) flood() {
                                // R_USEIFACEMETHOD is a marker relocation that marks an interface
                                // method as used.
                                rs := r.Sym()
-                               if d.ldr.SymType(rs) != sym.SDYNIMPORT { // don't decode DYNIMPORT symbol (we'll mark all exported methods anyway)
-                                       m := d.decodeIfaceMethod(d.ldr, d.ctxt.Arch, rs, r.Add())
-                                       if d.ctxt.Debugvlog > 1 {
-                                               d.ctxt.Logf("reached iface method: %v\n", m)
-                                       }
-                                       d.ifaceMethod[m] = true
+                               if d.ctxt.linkShared && (d.ldr.SymType(rs) == sym.SDYNIMPORT || d.ldr.SymType(rs) == sym.Sxxx) {
+                                       // Don't decode symbol from shared library (we'll mark all exported methods anyway).
+                                       // We check for both SDYNIMPORT and Sxxx because name-mangled symbols haven't
+                                       // been resolved at this point.
+                                       continue
+                               }
+                               m := d.decodeIfaceMethod(d.ldr, d.ctxt.Arch, rs, r.Add())
+                               if d.ctxt.Debugvlog > 1 {
+                                       d.ctxt.Logf("reached iface method: %v\n", m)
                                }
+                               d.ifaceMethod[m] = true
                                continue
                        }
                        rs := r.Sym()
index c6e2d8ca7fc9ceda261b854e447ed9181fdd0c98..fc179fc6e44109e28134070ae122d3f93fa0de01 100644 (file)
@@ -279,7 +279,7 @@ func findShlibSection(ctxt *Link, path string, addr uint64) *elf.Section {
        for _, shlib := range ctxt.Shlibs {
                if shlib.Path == path {
                        for _, sect := range shlib.File.Sections[1:] { // skip the NULL section
-                               if sect.Addr <= addr && addr <= sect.Addr+sect.Size {
+                               if sect.Addr <= addr && addr < sect.Addr+sect.Size {
                                        return sect
                                }
                        }
index 42d8158d63ce75052e0b74eea7f62d33143434f6..8c0299b11e9b5ad606591c38304cc8f2c3684437 100644 (file)
@@ -1997,15 +1997,6 @@ func buildCSRExtensions(template *CertificateRequest) ([]pkix.Extension, error)
                })
        }
 
-       if template.KeyUsage != 0 &&
-               !oidInExtensions(oidExtensionKeyUsage, template.ExtraExtensions) {
-               ext, err := marshalKeyUsage(template.KeyUsage)
-               if err != nil {
-                       return nil, err
-               }
-               ret = append(ret, ext)
-       }
-
        return append(ret, template.ExtraExtensions...), nil
 }
 
@@ -2371,7 +2362,6 @@ type CertificateRequest struct {
        Version            int
        Signature          []byte
        SignatureAlgorithm SignatureAlgorithm
-       KeyUsage           KeyUsage
 
        PublicKeyAlgorithm PublicKeyAlgorithm
        PublicKey          interface{}
@@ -2501,15 +2491,6 @@ func parseCSRExtensions(rawAttributes []asn1.RawValue) ([]pkix.Extension, error)
 //  - EmailAddresses
 //  - IPAddresses
 //  - URIs
-//  - KeyUsage
-//  - ExtKeyUsage
-//  - UnknownExtKeyUsage
-//  - BasicConstraintsValid
-//  - IsCA
-//  - MaxPathLen
-//  - MaxPathLenZero
-//  - SubjectKeyId
-//  - PolicyIdentifiers
 //  - ExtraExtensions
 //  - Attributes (deprecated)
 //
@@ -2734,11 +2715,6 @@ func parseCertificateRequest(in *certificateRequest) (*CertificateRequest, error
                        if err != nil {
                                return nil, err
                        }
-               case extension.Id.Equal(oidExtensionKeyUsage):
-                       out.KeyUsage, err = parseKeyUsageExtension(extension.Value)
-                       if err != nil {
-                               return nil, err
-                       }
                }
        }
 
index d5c7ec466b852d3baef3ecfb6503e262eecf5ada..51dda16815b0bb13d7bb6eb9c817ef203edd1c75 100644 (file)
@@ -2977,7 +2977,6 @@ func TestCertificateRequestRoundtripFields(t *testing.T) {
                EmailAddresses: []string{"a@example.com", "b@example.com"},
                IPAddresses:    []net.IP{net.IPv4(192, 0, 2, 0), net.IPv6loopback},
                URIs:           []*url.URL{urlA, urlB},
-               KeyUsage:       KeyUsageCertSign,
        }
        out := marshalAndParseCSR(t, in)
 
@@ -2995,7 +2994,4 @@ func TestCertificateRequestRoundtripFields(t *testing.T) {
        if !reflect.DeepEqual(in.URIs, out.URIs) {
                t.Fatalf("Unexpected URIs: got %v, want %v", out.URIs, in.URIs)
        }
-       if in.KeyUsage != out.KeyUsage {
-               t.Fatalf("Unexpected KeyUsage: got %v, want %v", out.KeyUsage, in.KeyUsage)
-       }
 }
index 26c3f2d60429ae0348c8d8e0ff3da265d6239c6a..5f984aaf71d285cecceb00ccd928b85a62a3dad1 100644 (file)
@@ -9,18 +9,28 @@
 // files read from the package directory or subdirectories at compile time.
 //
 // For example, here are three ways to embed a file named hello.txt
-// and then print its contents at run time:
+// and then print its contents at run time.
 //
-//     import "embed"
+// Embedding one file into a string:
+//
+//     import _ "embed"
 //
 //     //go:embed hello.txt
 //     var s string
 //     print(s)
 //
+// Embedding one file into a slice of bytes:
+//
+//     import _ "embed"
+//
 //     //go:embed hello.txt
 //     var b []byte
 //     print(string(b))
 //
+// Embedded one or more files into a file system:
+//
+//     import "embed"
+//
 //     //go:embed hello.txt
 //     var f embed.FS
 //     data, _ := f.ReadFile("hello.txt")
@@ -34,8 +44,8 @@
 // The directive must immediately precede a line containing the declaration of a single variable.
 // Only blank lines and ‘//’ line comments are permitted between the directive and the declaration.
 //
-// The variable must be of type string, []byte, or FS exactly. Named types or type aliases
-// derived from those types are not allowed.
+// The type of the variable must be a string type, or a slice of a byte type,
+// or FS (or an alias of FS).
 //
 // For example:
 //
@@ -70,8 +80,8 @@
 //
 // The //go:embed directive can be used with both exported and unexported variables,
 // depending on whether the package wants to make the data available to other packages.
-// Similarly, it can be used with both global and function-local variables,
-// depending on what is more convenient in context.
+// It can only be used with global variables at package scope,
+// not with local variables.
 //
 // Patterns must not match files outside the package's module, such as ‘.git/*’ or symbolic links.
 // Matches for empty directories are ignored. After that, each pattern in a //go:embed line
index 7e95f2365b8d387ac60ac3d31df6b050e352060f..1077a62897d94ce7a69d4dcd573b82962e54a469 100644 (file)
@@ -67,7 +67,7 @@ package math
 //
 //      One may easily use induction to prove (4) and (5).
 //      Note. Since the left hand side of (3) contain only i+2 bits,
-//            it does not necessary to do a full (53-bit) comparison
+//            it is not necessary to do a full (53-bit) comparison
 //            in (3).
 //   3. Final rounding
 //      After generating the 53 bits result, we compute one more bit.
index e97b8440e1d372a71782eb8ada4261a7b83f0cfc..756722ba1412a2dcc4e55a2f6e1e6ea4772d3ef6 100644 (file)
@@ -171,12 +171,9 @@ func (c *child) serve() {
        defer c.cleanUp()
        var rec record
        for {
-               c.conn.mutex.Lock()
                if err := rec.read(c.conn.rwc); err != nil {
-                       c.conn.mutex.Unlock()
                        return
                }
-               c.conn.mutex.Unlock()
                if err := c.handleRecord(&rec); err != nil {
                        return
                }
index d3b704f8219b907057742f99dbf92cd98c9a09da..b58111de208dee2e05f8f46096bddba1f1a7ec74 100644 (file)
@@ -221,7 +221,11 @@ var cleanUpTests = []struct {
 }
 
 type nopWriteCloser struct {
-       io.ReadWriter
+       io.Reader
+}
+
+func (nopWriteCloser) Write(buf []byte) (int, error) {
+       return len(buf), nil
 }
 
 func (nopWriteCloser) Close() error {
@@ -235,7 +239,7 @@ func TestChildServeCleansUp(t *testing.T) {
        for _, tt := range cleanUpTests {
                input := make([]byte, len(tt.input))
                copy(input, tt.input)
-               rc := nopWriteCloser{bytes.NewBuffer(input)}
+               rc := nopWriteCloser{bytes.NewReader(input)}
                done := make(chan bool)
                c := newChild(rc, http.HandlerFunc(func(
                        w http.ResponseWriter,
@@ -325,7 +329,7 @@ func TestChildServeReadsEnvVars(t *testing.T) {
        for _, tt := range envVarTests {
                input := make([]byte, len(tt.input))
                copy(input, tt.input)
-               rc := nopWriteCloser{bytes.NewBuffer(input)}
+               rc := nopWriteCloser{bytes.NewReader(input)}
                done := make(chan bool)
                c := newChild(rc, http.HandlerFunc(func(
                        w http.ResponseWriter,
@@ -375,7 +379,7 @@ func TestResponseWriterSniffsContentType(t *testing.T) {
                t.Run(tt.name, func(t *testing.T) {
                        input := make([]byte, len(streamFullRequestStdin))
                        copy(input, streamFullRequestStdin)
-                       rc := nopWriteCloser{bytes.NewBuffer(input)}
+                       rc := nopWriteCloser{bytes.NewReader(input)}
                        done := make(chan bool)
                        var resp *response
                        c := newChild(rc, http.HandlerFunc(func(
index 0dc7a5a0a295c6e0fcbac619054f3647b05d5cd4..f88450018ee3c0e76d9534093357f8a09e651823 100644 (file)
@@ -66,6 +66,10 @@ type file struct {
 // making it invalid; see runtime.SetFinalizer for more information on when
 // a finalizer might be run. On Unix systems this will cause the SetDeadline
 // methods to stop working.
+// Because file descriptors can be reused, the returned file descriptor may
+// only be closed through the Close method of f, or by its finalizer during
+// garbage collection. Otherwise, during garbage collection the finalizer
+// may close an unrelated file descriptor with the same (reused) number.
 //
 // As an alternative, see the f.SyscallConn method.
 func (f *File) Fd() uintptr {
@@ -90,6 +94,10 @@ func (f *File) Fd() uintptr {
 // descriptor. On Unix systems, if the file descriptor is in
 // non-blocking mode, NewFile will attempt to return a pollable File
 // (one for which the SetDeadline methods work).
+//
+// After passing it to NewFile, fd may become invalid under the same
+// conditions described in the comments of the Fd method, and the same
+// constraints apply.
 func NewFile(fd uintptr, name string) *File {
        kind := kindNewFile
        if nb, err := unix.IsNonblock(int(fd)); err == nil && nb {
index 4f90fcf8e8512517852516350e927c436e87ca30..1ad44f1163fa58b90eca41cf9b49d55270cd60da 100644 (file)
@@ -20,7 +20,7 @@ func nextRandom() string {
 // opens the file for reading and writing, and returns the resulting file.
 // The filename is generated by taking pattern and adding a random string to the end.
 // If pattern includes a "*", the random string replaces the last "*".
-// If dir is the empty string, TempFile uses the default directory for temporary files, as returned by TempDir.
+// If dir is the empty string, CreateTemp uses the default directory for temporary files, as returned by TempDir.
 // Multiple programs or goroutines calling CreateTemp simultaneously will not choose the same file.
 // The caller can use the file's Name method to find the pathname of the file.
 // It is the caller's responsibility to remove the file when it is no longer needed.
@@ -71,7 +71,7 @@ func prefixAndSuffix(pattern string) (prefix, suffix string, err error) {
 // and returns the pathname of the new directory.
 // The new directory's name is generated by adding a random string to the end of pattern.
 // If pattern includes a "*", the random string replaces the last "*" instead.
-// If dir is the empty string, TempFile uses the default directory for temporary files, as returned by TempDir.
+// If dir is the empty string, MkdirTemp uses the default directory for temporary files, as returned by TempDir.
 // Multiple programs or goroutines calling MkdirTemp simultaneously will not choose the same directory.
 // It is the caller's responsibility to remove the directory when it is no longer needed.
 func MkdirTemp(dir, pattern string) (string, error) {
index 58ad4f3ebac399f37780281850f80e48ff873a8a..e5bd7973b70b781771b40eb734a49e0de7a0d4d6 100644 (file)
@@ -294,6 +294,18 @@ func TestRecursivePanic4(t *testing.T) {
 
 }
 
+func TestRecursivePanic5(t *testing.T) {
+       output := runTestProg(t, "testprog", "RecursivePanic5")
+       want := `first panic
+second panic
+panic: third panic
+`
+       if !strings.HasPrefix(output, want) {
+               t.Fatalf("output does not start with %q:\n%s", want, output)
+       }
+
+}
+
 func TestGoexitCrash(t *testing.T) {
        // External linking brings in cgo, causing deadlock detection not working.
        testenv.MustInternalLink(t)
index 5ac08145646063bee6e87c47cf1c48691d8149ad..9a40ea19842faf029d6a2502c38c15fedddb1f52 100644 (file)
@@ -410,3 +410,31 @@ func rec1(max int) {
                rec1(max - 1)
        }
 }
+
+func TestIssue43921(t *testing.T) {
+       defer func() {
+               expect(t, 1, recover())
+       }()
+       func() {
+               // Prevent open-coded defers
+               for {
+                       defer func() {}()
+                       break
+               }
+
+               defer func() {
+                       defer func() {
+                               expect(t, 4, recover())
+                       }()
+                       panic(4)
+               }()
+               panic(1)
+
+       }()
+}
+
+func expect(t *testing.T, n int, err interface{}) {
+       if n != err {
+               t.Fatalf("have %v, want %v", err, n)
+       }
+}
index 63ea8dfecc041af66ddcf4c5a6727aedd60b95fd..d2b947feb2741c00f8b9da264a444367bdfb8147 100644 (file)
@@ -33,6 +33,11 @@ const (
 
        _PTHREAD_CREATE_DETACHED = 0x1
 
+       _F_SETFD    = 0x2
+       _F_GETFL    = 0x3
+       _F_SETFL    = 0x4
+       _FD_CLOEXEC = 0x1
+
        _SIGHUP    = 0x1
        _SIGINT    = 0x2
        _SIGQUIT   = 0x3
index 65f7196312cec0fa6d3aa758f2b61b573013b2a0..5e090ef09ebf2b8f6a6fba8efe1045943e96bb49 100644 (file)
@@ -9,6 +9,8 @@
 
 // NOTE: Windows externalthreadhandler expects memclr to preserve DX.
 
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
 TEXT runtime·memclrNoHeapPointers(SB), NOSPLIT, $0-8
        MOVL    ptr+0(FP), DI
index d79078fd00bf5f389837603ad1c40fda72b20c18..37fe9745b1be082d4c0380899ed2bc1cc0009cb9 100644 (file)
@@ -9,6 +9,8 @@
 
 // NOTE: Windows externalthreadhandler expects memclr to preserve DX.
 
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
 TEXT runtime·memclrNoHeapPointers(SB), NOSPLIT, $0-16
        MOVQ    ptr+0(FP), DI
index 7326b8be34066ad7bce04d8973e724c366b909a0..f113a1aa2dd9ffd559dcfde1185e6e645e8e13e7 100644 (file)
@@ -30,6 +30,8 @@
 #define N      R12
 #define TMP    R12                             /* N and TMP don't overlap */
 
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
 TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-8
        MOVW    ptr+0(FP), TO
index a56a6dfb85df8099e3c80bbb457cfce239f330a6..bef77651e48c445b4d88ab7eb31c330b872e54fd 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "textflag.h"
 
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
 TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-16
        MOVD    ptr+0(FP), R0
index 4c2292eae8520e4ae782121a586f488f1e92b93d..d7a3251e2046abf15ac9e487dfa6884ef4e714ac 100644 (file)
@@ -7,6 +7,8 @@
 #include "go_asm.h"
 #include "textflag.h"
 
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
 TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-16
        MOVV    ptr+0(FP), R1
index 1561a23dbe297171a8c4aded6eceb71e4e5636e9..eb2a8a7219c6bbf0bc39064e5beef20cc0306573 100644 (file)
@@ -14,6 +14,8 @@
 #define MOVWLO  MOVWL
 #endif
 
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
 TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-8
        MOVW    n+4(FP), R2
index 5b880ae86f81b43206c55c51ed06a7399be316ae..54701a94536e5493cb9005dcfb82a2823a627b95 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "textflag.h"
 
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
 TEXT runtime·memclrNoHeapPointers(SB), NOSPLIT, $0-8
        MOVL    ptr+0(FP), DI
index ad383cd6b3d69c230362b9881eaf4d1cfacbf9de..8c6a1cc7809ac6a94a81c753009382e53d8842e6 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "textflag.h"
 
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
 TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-16
        MOVQ    ptr+0(FP), DI
index 072963f75687dcdae62c7dd88ec8c24a966d0094..751262089425430eeec3a7208972d4c01507236f 100644 (file)
@@ -6,6 +6,8 @@
 
 #include "textflag.h"
 
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
 TEXT runtime·memclrNoHeapPointers(SB), NOSPLIT|NOFRAME, $0-16
        MOVD ptr+0(FP), R3
index ba7704e805d2b536823f9a03b7c6018a6b0136a3..54ddaa4560c77635e357b9b0a14b8f7da5c211dd 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "textflag.h"
 
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
 // void runtime·memclrNoHeapPointers(void*, uintptr)
 TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-16
        MOV     ptr+0(FP), T1
index dd14a441cc2bb77bba15bb4227d7b431ecc7ee99..fa657ef66e6b9545417223164a4d163329fc6e1a 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "textflag.h"
 
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
 TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT|NOFRAME,$0-16
        MOVD    ptr+0(FP), R4
index 68ffe2f67b513079ad66c6ecf21dc70fd058e224..5a053049f8154eaabe70d92280e7ec6c1edf48d1 100644 (file)
@@ -4,6 +4,8 @@
 
 #include "textflag.h"
 
+// See memclrNoHeapPointers Go doc for important implementation constraints.
+
 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
 TEXT runtime·memclrNoHeapPointers(SB), NOSPLIT, $0-16
        MOVD ptr+0(FP), R0
index 08928cfef44b990b444917d0573a8101b9ebf6e7..b0bef4c5043bd100303728af085dc9e5bc63cee2 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build openbsd,!amd64
+// +build openbsd,!amd64,!arm64
 
 package runtime
 
index 74eb271c2c79bdd8c75d781898ba94d3b034875c..ab940510af152cfa19448d4dcb71718bf696fb49 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build openbsd,!amd64
+// +build openbsd,!amd64,!arm64
 
 package runtime
 
index 83d0d63e5d7c5bccda0d088b8a9fb1ae8787859a..e6b22e316716982101fe0c92b3208e41e0fa7ed2 100644 (file)
@@ -46,6 +46,7 @@ const (
 //go:cgo_import_dynamic runtime._SetThreadPriority SetThreadPriority%2 "kernel32.dll"
 //go:cgo_import_dynamic runtime._SetUnhandledExceptionFilter SetUnhandledExceptionFilter%1 "kernel32.dll"
 //go:cgo_import_dynamic runtime._SetWaitableTimer SetWaitableTimer%6 "kernel32.dll"
+//go:cgo_import_dynamic runtime._Sleep Sleep%1 "kernel32.dll"
 //go:cgo_import_dynamic runtime._SuspendThread SuspendThread%1 "kernel32.dll"
 //go:cgo_import_dynamic runtime._SwitchToThread SwitchToThread%0 "kernel32.dll"
 //go:cgo_import_dynamic runtime._TlsAlloc TlsAlloc%0 "kernel32.dll"
@@ -97,6 +98,7 @@ var (
        _SetThreadPriority,
        _SetUnhandledExceptionFilter,
        _SetWaitableTimer,
+       _Sleep,
        _SuspendThread,
        _SwitchToThread,
        _TlsAlloc,
@@ -1094,6 +1096,11 @@ func ctrlhandler1(_type uint32) uint32 {
        }
 
        if sigsend(s) {
+               if s == _SIGTERM {
+                       // Windows terminates the process after this handler returns.
+                       // Block indefinitely to give signal handlers a chance to clean up.
+                       stdcall1(_Sleep, uintptr(_INFINITE))
+               }
                return 1
        }
        return 0
index aed17d6fc62bd5704559477e192ba22468a055e3..5b2ccdd8740f802468227506afc9854459d23e4f 100644 (file)
@@ -1000,37 +1000,42 @@ func gopanic(e interface{}) {
                        }
                        atomic.Xadd(&runningPanicDefers, -1)
 
-                       if done {
-                               // Remove any remaining non-started, open-coded
-                               // defer entries after a recover, since the
-                               // corresponding defers will be executed normally
-                               // (inline). Any such entry will become stale once
-                               // we run the corresponding defers inline and exit
-                               // the associated stack frame.
-                               d := gp._defer
-                               var prev *_defer
-                               for d != nil {
-                                       if d.openDefer {
-                                               if d.started {
-                                                       // This defer is started but we
-                                                       // are in the middle of a
-                                                       // defer-panic-recover inside of
-                                                       // it, so don't remove it or any
-                                                       // further defer entries
-                                                       break
-                                               }
-                                               if prev == nil {
-                                                       gp._defer = d.link
-                                               } else {
-                                                       prev.link = d.link
-                                               }
-                                               newd := d.link
-                                               freedefer(d)
-                                               d = newd
+                       // Remove any remaining non-started, open-coded
+                       // defer entries after a recover, since the
+                       // corresponding defers will be executed normally
+                       // (inline). Any such entry will become stale once
+                       // we run the corresponding defers inline and exit
+                       // the associated stack frame.
+                       d := gp._defer
+                       var prev *_defer
+                       if !done {
+                               // Skip our current frame, if not done. It is
+                               // needed to complete any remaining defers in
+                               // deferreturn()
+                               prev = d
+                               d = d.link
+                       }
+                       for d != nil {
+                               if d.started {
+                                       // This defer is started but we
+                                       // are in the middle of a
+                                       // defer-panic-recover inside of
+                                       // it, so don't remove it or any
+                                       // further defer entries
+                                       break
+                               }
+                               if d.openDefer {
+                                       if prev == nil {
+                                               gp._defer = d.link
                                        } else {
-                                               prev = d
-                                               d = d.link
+                                               prev.link = d.link
                                        }
+                                       newd := d.link
+                                       freedefer(d)
+                                       d = newd
+                               } else {
+                                       prev = d
+                                       d = d.link
                                }
                        }
 
index d51dcb0d224c4586f985c082eb5ef17375dca33f..73a789c18973e793bda325d3769bfc0ecbb0e98c 100644 (file)
@@ -1213,7 +1213,7 @@ func usesLibcall() bool {
        case "aix", "darwin", "illumos", "ios", "solaris", "windows":
                return true
        case "openbsd":
-               return GOARCH == "amd64"
+               return GOARCH == "amd64" || GOARCH == "arm64"
        }
        return false
 }
index a5a885c2f79d296f485dab34c30e53d2bebc4c17..33a9b92ee73f1f51b9ca265ed3be6c1587e67331 100644 (file)
@@ -11,6 +11,7 @@ import (
        "os/exec"
        "path/filepath"
        "runtime"
+       "strconv"
        "strings"
        "syscall"
        "testing"
@@ -79,6 +80,69 @@ func sendCtrlBreak(pid int) error {
        return nil
 }
 
+// TestCtrlHandler tests that Go can gracefully handle closing the console window.
+// See https://golang.org/issues/41884.
+func TestCtrlHandler(t *testing.T) {
+       testenv.MustHaveGoBuild(t)
+       t.Parallel()
+
+       // build go program
+       exe := filepath.Join(t.TempDir(), "test.exe")
+       cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", exe, "testdata/testwinsignal/main.go")
+       out, err := testenv.CleanCmdEnv(cmd).CombinedOutput()
+       if err != nil {
+               t.Fatalf("failed to build go exe: %v\n%s", err, out)
+       }
+
+       // run test program
+       cmd = exec.Command(exe)
+       var stderr bytes.Buffer
+       cmd.Stderr = &stderr
+       outPipe, err := cmd.StdoutPipe()
+       if err != nil {
+               t.Fatalf("Failed to create stdout pipe: %v", err)
+       }
+       outReader := bufio.NewReader(outPipe)
+
+       // in a new command window
+       const _CREATE_NEW_CONSOLE = 0x00000010
+       cmd.SysProcAttr = &syscall.SysProcAttr{
+               CreationFlags: _CREATE_NEW_CONSOLE,
+               HideWindow:    true,
+       }
+       if err := cmd.Start(); err != nil {
+               t.Fatalf("Start failed: %v", err)
+       }
+       defer func() {
+               cmd.Process.Kill()
+               cmd.Wait()
+       }()
+
+       // wait for child to be ready to receive signals
+       if line, err := outReader.ReadString('\n'); err != nil {
+               t.Fatalf("could not read stdout: %v", err)
+       } else if strings.TrimSpace(line) != "ready" {
+               t.Fatalf("unexpected message: %s", line)
+       }
+
+       // gracefully kill pid, this closes the command window
+       if err := exec.Command("taskkill.exe", "/pid", strconv.Itoa(cmd.Process.Pid)).Run(); err != nil {
+               t.Fatalf("failed to kill: %v", err)
+       }
+
+       // check child received, handled SIGTERM
+       if line, err := outReader.ReadString('\n'); err != nil {
+               t.Fatalf("could not read stdout: %v", err)
+       } else if expected, got := syscall.SIGTERM.String(), strings.TrimSpace(line); expected != got {
+               t.Fatalf("Expected '%s' got: %s", expected, got)
+       }
+
+       // check child exited gracefully, did not timeout
+       if err := cmd.Wait(); err != nil {
+               t.Fatalf("Program exited with error: %v\n%s", err, &stderr)
+       }
+}
+
 // TestLibraryCtrlHandler tests that Go DLL allows calling program to handle console control events.
 // See https://golang.org/issues/35965.
 func TestLibraryCtrlHandler(t *testing.T) {
index b55c3c0590072ed67f7ee64ce2a6af302969d5f9..2ee2c74dfe07e5f1ef4e881352f296697644aab4 100644 (file)
@@ -73,7 +73,15 @@ func badsystemstack() {
 // *ptr is uninitialized memory (e.g., memory that's being reused
 // for a new allocation) and hence contains only "junk".
 //
+// memclrNoHeapPointers ensures that if ptr is pointer-aligned, and n
+// is a multiple of the pointer size, then any pointer-aligned,
+// pointer-sized portion is cleared atomically. Despite the function
+// name, this is necessary because this function is the underlying
+// implementation of typedmemclr and memclrHasPointers. See the doc of
+// memmove for more details.
+//
 // The (CPU-specific) implementations of this function are in memclr_*.s.
+//
 //go:noescape
 func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
 
index a201a16c5332d70f2fdc16b42f23fee237ccb3a6..e2886218db5da06b1893e73d1b5c08db8c61f461 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build openbsd,amd64
+// +build openbsd,amd64 openbsd,arm64
 
 package runtime
 
index 73592df2265d31c8f859805e17f4b55cc1b06a74..474e7145e796220187bba2817a7eb0e513d27ea2 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build openbsd,amd64
+// +build openbsd,amd64 openbsd,arm64
 
 package runtime
 
diff --git a/src/runtime/sys_openbsd3.go b/src/runtime/sys_openbsd3.go
new file mode 100644 (file)
index 0000000..4d4c88e
--- /dev/null
@@ -0,0 +1,113 @@
+// 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 openbsd,amd64 openbsd,arm64
+
+package runtime
+
+import "unsafe"
+
+// The X versions of syscall expect the libc call to return a 64-bit result.
+// Otherwise (the non-X version) expects a 32-bit result.
+// This distinction is required because an error is indicated by returning -1,
+// and we need to know whether to check 32 or 64 bits of the result.
+// (Some libc functions that return 32 bits put junk in the upper 32 bits of AX.)
+
+//go:linkname syscall_syscall syscall.syscall
+//go:nosplit
+//go:cgo_unsafe_args
+func syscall_syscall(fn, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
+       entersyscall()
+       libcCall(unsafe.Pointer(funcPC(syscall)), unsafe.Pointer(&fn))
+       exitsyscall()
+       return
+}
+func syscall()
+
+//go:linkname syscall_syscallX syscall.syscallX
+//go:nosplit
+//go:cgo_unsafe_args
+func syscall_syscallX(fn, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
+       entersyscall()
+       libcCall(unsafe.Pointer(funcPC(syscallX)), unsafe.Pointer(&fn))
+       exitsyscall()
+       return
+}
+func syscallX()
+
+//go:linkname syscall_syscall6 syscall.syscall6
+//go:nosplit
+//go:cgo_unsafe_args
+func syscall_syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) {
+       entersyscall()
+       libcCall(unsafe.Pointer(funcPC(syscall6)), unsafe.Pointer(&fn))
+       exitsyscall()
+       return
+}
+func syscall6()
+
+//go:linkname syscall_syscall6X syscall.syscall6X
+//go:nosplit
+//go:cgo_unsafe_args
+func syscall_syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) {
+       entersyscall()
+       libcCall(unsafe.Pointer(funcPC(syscall6X)), unsafe.Pointer(&fn))
+       exitsyscall()
+       return
+}
+func syscall6X()
+
+//go:linkname syscall_syscall10 syscall.syscall10
+//go:nosplit
+//go:cgo_unsafe_args
+func syscall_syscall10(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 uintptr) (r1, r2, err uintptr) {
+       entersyscall()
+       libcCall(unsafe.Pointer(funcPC(syscall10)), unsafe.Pointer(&fn))
+       exitsyscall()
+       return
+}
+func syscall10()
+
+//go:linkname syscall_syscall10X syscall.syscall10X
+//go:nosplit
+//go:cgo_unsafe_args
+func syscall_syscall10X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 uintptr) (r1, r2, err uintptr) {
+       entersyscall()
+       libcCall(unsafe.Pointer(funcPC(syscall10X)), unsafe.Pointer(&fn))
+       exitsyscall()
+       return
+}
+func syscall10X()
+
+//go:linkname syscall_rawSyscall syscall.rawSyscall
+//go:nosplit
+//go:cgo_unsafe_args
+func syscall_rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
+       libcCall(unsafe.Pointer(funcPC(syscall)), unsafe.Pointer(&fn))
+       return
+}
+
+//go:linkname syscall_rawSyscall6 syscall.rawSyscall6
+//go:nosplit
+//go:cgo_unsafe_args
+func syscall_rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) {
+       libcCall(unsafe.Pointer(funcPC(syscall6)), unsafe.Pointer(&fn))
+       return
+}
+
+//go:linkname syscall_rawSyscall6X syscall.rawSyscall6X
+//go:nosplit
+//go:cgo_unsafe_args
+func syscall_rawSyscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) {
+       libcCall(unsafe.Pointer(funcPC(syscall6X)), unsafe.Pointer(&fn))
+       return
+}
+
+//go:linkname syscall_rawSyscall10X syscall.rawSyscall10X
+//go:nosplit
+//go:cgo_unsafe_args
+func syscall_rawSyscall10X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 uintptr) (r1, r2, err uintptr) {
+       libcCall(unsafe.Pointer(funcPC(syscall10X)), unsafe.Pointer(&fn))
+       return
+}
index 4680a7f7aae181ee3995e5e8482b7f6a0f900757..b3a76b57a3afd4a5a33cbdca7f684f3dabbd1408 100644 (file)
@@ -445,3 +445,344 @@ TEXT runtime·sigaltstack_trampoline(SB),NOSPLIT,$0
        MOVL    $0xf1, 0xf1  // crash
        POPQ    BP
        RET
+
+// syscall calls a function in libc on behalf of the syscall package.
+// syscall takes a pointer to a struct like:
+// struct {
+//     fn    uintptr
+//     a1    uintptr
+//     a2    uintptr
+//     a3    uintptr
+//     r1    uintptr
+//     r2    uintptr
+//     err   uintptr
+// }
+// syscall must be called on the g0 stack with the
+// C calling convention (use libcCall).
+//
+// syscall expects a 32-bit result and tests for 32-bit -1
+// to decide there was an error.
+TEXT runtime·syscall(SB),NOSPLIT,$0
+       PUSHQ   BP
+       MOVQ    SP, BP
+       SUBQ    $16, SP
+       MOVQ    (0*8)(DI), CX // fn
+       MOVQ    (2*8)(DI), SI // a2
+       MOVQ    (3*8)(DI), DX // a3
+       MOVQ    DI, (SP)
+       MOVQ    (1*8)(DI), DI // a1
+       XORL    AX, AX        // vararg: say "no float args"
+
+       CALL    CX
+
+       MOVQ    (SP), DI
+       MOVQ    AX, (4*8)(DI) // r1
+       MOVQ    DX, (5*8)(DI) // r2
+
+       // Standard libc functions return -1 on error
+       // and set errno.
+       CMPL    AX, $-1       // Note: high 32 bits are junk
+       JNE     ok
+
+       // Get error code from libc.
+       CALL    libc_errno(SB)
+       MOVLQSX (AX), AX
+       MOVQ    (SP), DI
+       MOVQ    AX, (6*8)(DI) // err
+
+ok:
+       XORL    AX, AX        // no error (it's ignored anyway)
+       MOVQ    BP, SP
+       POPQ    BP
+       RET
+
+// syscallX calls a function in libc on behalf of the syscall package.
+// syscallX takes a pointer to a struct like:
+// struct {
+//     fn    uintptr
+//     a1    uintptr
+//     a2    uintptr
+//     a3    uintptr
+//     r1    uintptr
+//     r2    uintptr
+//     err   uintptr
+// }
+// syscallX must be called on the g0 stack with the
+// C calling convention (use libcCall).
+//
+// syscallX is like syscall but expects a 64-bit result
+// and tests for 64-bit -1 to decide there was an error.
+TEXT runtime·syscallX(SB),NOSPLIT,$0
+       PUSHQ   BP
+       MOVQ    SP, BP
+       SUBQ    $16, SP
+       MOVQ    (0*8)(DI), CX // fn
+       MOVQ    (2*8)(DI), SI // a2
+       MOVQ    (3*8)(DI), DX // a3
+       MOVQ    DI, (SP)
+       MOVQ    (1*8)(DI), DI // a1
+       XORL    AX, AX        // vararg: say "no float args"
+
+       CALL    CX
+
+       MOVQ    (SP), DI
+       MOVQ    AX, (4*8)(DI) // r1
+       MOVQ    DX, (5*8)(DI) // r2
+
+       // Standard libc functions return -1 on error
+       // and set errno.
+       CMPQ    AX, $-1
+       JNE     ok
+
+       // Get error code from libc.
+       CALL    libc_errno(SB)
+       MOVLQSX (AX), AX
+       MOVQ    (SP), DI
+       MOVQ    AX, (6*8)(DI) // err
+
+ok:
+       XORL    AX, AX        // no error (it's ignored anyway)
+       MOVQ    BP, SP
+       POPQ    BP
+       RET
+
+// syscall6 calls a function in libc on behalf of the syscall package.
+// syscall6 takes a pointer to a struct like:
+// struct {
+//     fn    uintptr
+//     a1    uintptr
+//     a2    uintptr
+//     a3    uintptr
+//     a4    uintptr
+//     a5    uintptr
+//     a6    uintptr
+//     r1    uintptr
+//     r2    uintptr
+//     err   uintptr
+// }
+// syscall6 must be called on the g0 stack with the
+// C calling convention (use libcCall).
+//
+// syscall6 expects a 32-bit result and tests for 32-bit -1
+// to decide there was an error.
+TEXT runtime·syscall6(SB),NOSPLIT,$0
+       PUSHQ   BP
+       MOVQ    SP, BP
+       SUBQ    $16, SP
+       MOVQ    (0*8)(DI), R11// fn
+       MOVQ    (2*8)(DI), SI // a2
+       MOVQ    (3*8)(DI), DX // a3
+       MOVQ    (4*8)(DI), CX // a4
+       MOVQ    (5*8)(DI), R8 // a5
+       MOVQ    (6*8)(DI), R9 // a6
+       MOVQ    DI, (SP)
+       MOVQ    (1*8)(DI), DI // a1
+       XORL    AX, AX        // vararg: say "no float args"
+
+       CALL    R11
+
+       MOVQ    (SP), DI
+       MOVQ    AX, (7*8)(DI) // r1
+       MOVQ    DX, (8*8)(DI) // r2
+
+       CMPL    AX, $-1
+       JNE     ok
+
+       CALL    libc_errno(SB)
+       MOVLQSX (AX), AX
+       MOVQ    (SP), DI
+       MOVQ    AX, (9*8)(DI) // err
+
+ok:
+       XORL    AX, AX        // no error (it's ignored anyway)
+       MOVQ    BP, SP
+       POPQ    BP
+       RET
+
+// syscall6X calls a function in libc on behalf of the syscall package.
+// syscall6X takes a pointer to a struct like:
+// struct {
+//     fn    uintptr
+//     a1    uintptr
+//     a2    uintptr
+//     a3    uintptr
+//     a4    uintptr
+//     a5    uintptr
+//     a6    uintptr
+//     r1    uintptr
+//     r2    uintptr
+//     err   uintptr
+// }
+// syscall6X must be called on the g0 stack with the
+// C calling convention (use libcCall).
+//
+// syscall6X is like syscall6 but expects a 64-bit result
+// and tests for 64-bit -1 to decide there was an error.
+TEXT runtime·syscall6X(SB),NOSPLIT,$0
+       PUSHQ   BP
+       MOVQ    SP, BP
+       SUBQ    $16, SP
+       MOVQ    (0*8)(DI), R11// fn
+       MOVQ    (2*8)(DI), SI // a2
+       MOVQ    (3*8)(DI), DX // a3
+       MOVQ    (4*8)(DI), CX // a4
+       MOVQ    (5*8)(DI), R8 // a5
+       MOVQ    (6*8)(DI), R9 // a6
+       MOVQ    DI, (SP)
+       MOVQ    (1*8)(DI), DI // a1
+       XORL    AX, AX        // vararg: say "no float args"
+
+       CALL    R11
+
+       MOVQ    (SP), DI
+       MOVQ    AX, (7*8)(DI) // r1
+       MOVQ    DX, (8*8)(DI) // r2
+
+       CMPQ    AX, $-1
+       JNE     ok
+
+       CALL    libc_errno(SB)
+       MOVLQSX (AX), AX
+       MOVQ    (SP), DI
+       MOVQ    AX, (9*8)(DI) // err
+
+ok:
+       XORL    AX, AX        // no error (it's ignored anyway)
+       MOVQ    BP, SP
+       POPQ    BP
+       RET
+
+// syscall10 calls a function in libc on behalf of the syscall package.
+// syscall10 takes a pointer to a struct like:
+// struct {
+//     fn    uintptr
+//     a1    uintptr
+//     a2    uintptr
+//     a3    uintptr
+//     a4    uintptr
+//     a5    uintptr
+//     a6    uintptr
+//     a7    uintptr
+//     a8    uintptr
+//     a9    uintptr
+//     a10   uintptr
+//     r1    uintptr
+//     r2    uintptr
+//     err   uintptr
+// }
+// syscall10 must be called on the g0 stack with the
+// C calling convention (use libcCall).
+TEXT runtime·syscall10(SB),NOSPLIT,$0
+       PUSHQ   BP
+       MOVQ    SP, BP
+       SUBQ    $48, SP
+
+       // Arguments a1 to a6 get passed in registers, with a7 onwards being
+       // passed via the stack per the x86-64 System V ABI
+       // (https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf).
+       MOVQ    (7*8)(DI), R10  // a7
+       MOVQ    (8*8)(DI), R11  // a8
+       MOVQ    (9*8)(DI), R12  // a9
+       MOVQ    (10*8)(DI), R13 // a10
+       MOVQ    R10, (0*8)(SP)  // a7
+       MOVQ    R11, (1*8)(SP)  // a8
+       MOVQ    R12, (2*8)(SP)  // a9
+       MOVQ    R13, (3*8)(SP)  // a10
+       MOVQ    (0*8)(DI), R11  // fn
+       MOVQ    (2*8)(DI), SI   // a2
+       MOVQ    (3*8)(DI), DX   // a3
+       MOVQ    (4*8)(DI), CX   // a4
+       MOVQ    (5*8)(DI), R8   // a5
+       MOVQ    (6*8)(DI), R9   // a6
+       MOVQ    DI, (4*8)(SP)
+       MOVQ    (1*8)(DI), DI   // a1
+       XORL    AX, AX          // vararg: say "no float args"
+
+       CALL    R11
+
+       MOVQ    (4*8)(SP), DI
+       MOVQ    AX, (11*8)(DI) // r1
+       MOVQ    DX, (12*8)(DI) // r2
+
+       CMPL    AX, $-1
+       JNE     ok
+
+       CALL    libc_errno(SB)
+       MOVLQSX (AX), AX
+       MOVQ    (4*8)(SP), DI
+       MOVQ    AX, (13*8)(DI) // err
+
+ok:
+       XORL    AX, AX        // no error (it's ignored anyway)
+       MOVQ    BP, SP
+       POPQ    BP
+       RET
+
+// syscall10X calls a function in libc on behalf of the syscall package.
+// syscall10X takes a pointer to a struct like:
+// struct {
+//     fn    uintptr
+//     a1    uintptr
+//     a2    uintptr
+//     a3    uintptr
+//     a4    uintptr
+//     a5    uintptr
+//     a6    uintptr
+//     a7    uintptr
+//     a8    uintptr
+//     a9    uintptr
+//     a10   uintptr
+//     r1    uintptr
+//     r2    uintptr
+//     err   uintptr
+// }
+// syscall10X must be called on the g0 stack with the
+// C calling convention (use libcCall).
+//
+// syscall10X is like syscall10 but expects a 64-bit result
+// and tests for 64-bit -1 to decide there was an error.
+TEXT runtime·syscall10X(SB),NOSPLIT,$0
+       PUSHQ   BP
+       MOVQ    SP, BP
+       SUBQ    $48, SP
+
+       // Arguments a1 to a6 get passed in registers, with a7 onwards being
+       // passed via the stack per the x86-64 System V ABI
+       // (https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf).
+       MOVQ    (7*8)(DI), R10  // a7
+       MOVQ    (8*8)(DI), R11  // a8
+       MOVQ    (9*8)(DI), R12  // a9
+       MOVQ    (10*8)(DI), R13 // a10
+       MOVQ    R10, (0*8)(SP)  // a7
+       MOVQ    R11, (1*8)(SP)  // a8
+       MOVQ    R12, (2*8)(SP)  // a9
+       MOVQ    R13, (3*8)(SP)  // a10
+       MOVQ    (0*8)(DI), R11  // fn
+       MOVQ    (2*8)(DI), SI   // a2
+       MOVQ    (3*8)(DI), DX   // a3
+       MOVQ    (4*8)(DI), CX   // a4
+       MOVQ    (5*8)(DI), R8   // a5
+       MOVQ    (6*8)(DI), R9   // a6
+       MOVQ    DI, (4*8)(SP)
+       MOVQ    (1*8)(DI), DI   // a1
+       XORL    AX, AX          // vararg: say "no float args"
+
+       CALL    R11
+
+       MOVQ    (4*8)(SP), DI
+       MOVQ    AX, (11*8)(DI) // r1
+       MOVQ    DX, (12*8)(DI) // r2
+
+       CMPQ    AX, $-1
+       JNE     ok
+
+       CALL    libc_errno(SB)
+       MOVLQSX (AX), AX
+       MOVQ    (4*8)(SP), DI
+       MOVQ    AX, (13*8)(DI) // err
+
+ok:
+       XORL    AX, AX        // no error (it's ignored anyway)
+       MOVQ    BP, SP
+       POPQ    BP
+       RET
index 2ec9d038ba2439767a8ba21f3950f669b59b754a..9b4acc90a58c88e3abc08d18b7d476a267c67692 100644 (file)
 #define CLOCK_REALTIME $0
 #define        CLOCK_MONOTONIC $3
 
-// With OpenBSD 6.7 onwards, an arm64 syscall returns two instructions
-// after the SVC instruction, to allow for a speculative execution
-// barrier to be placed after the SVC without impacting performance.
-// For now use hardware no-ops as this works with both older and newer
-// kernels. After OpenBSD 6.8 is released this should be changed to
-// speculation barriers.
-#define        INVOKE_SYSCALL  \
-       SVC;            \
-       NOOP;           \
-       NOOP
-
 // mstart_stub is the first function executed on a new thread started by pthread_create.
 // It just does some low-level setup and then calls mstart.
 // Note: called with the C calling convention.
@@ -188,322 +177,524 @@ TEXT runtime·pthread_create_trampoline(SB),NOSPLIT,$0
        ADD     $16, RSP
        RET
 
-// Exit the entire program (like C exit)
-TEXT runtime·exit(SB),NOSPLIT|NOFRAME,$0
-       MOVW    code+0(FP), R0          // arg 1 - status
-       MOVD    $1, R8                  // sys_exit
-       INVOKE_SYSCALL
-       BCC     3(PC)
-       MOVD    $0, R0                  // crash on syscall failure
-       MOVD    R0, (R0)
+TEXT runtime·thrkill_trampoline(SB),NOSPLIT,$0
+       MOVW    8(R0), R1               // arg 2 - signal
+       MOVD    $0, R2                  // arg 3 - tcb
+       MOVW    0(R0), R0               // arg 1 - tid
+       CALL    libc_thrkill(SB)
        RET
 
-// func exitThread(wait *uint32)
-TEXT runtime·exitThread(SB),NOSPLIT,$0
-       MOVD    wait+0(FP), R0          // arg 1 - notdead
-       MOVD    $302, R8                // sys___threxit
-       INVOKE_SYSCALL
-       MOVD    $0, R0                  // crash on syscall failure
+TEXT runtime·thrsleep_trampoline(SB),NOSPLIT,$0
+       MOVW    8(R0), R1               // arg 2 - clock_id
+       MOVD    16(R0), R2              // arg 3 - abstime
+       MOVD    24(R0), R3              // arg 4 - lock
+       MOVD    32(R0), R4              // arg 5 - abort
+       MOVD    0(R0), R0               // arg 1 - id
+       CALL    libc_thrsleep(SB)
+       RET
+
+TEXT runtime·thrwakeup_trampoline(SB),NOSPLIT,$0
+       MOVW    8(R0), R1               // arg 2 - count
+       MOVD    0(R0), R0               // arg 1 - id
+       CALL    libc_thrwakeup(SB)
+       RET
+
+TEXT runtime·exit_trampoline(SB),NOSPLIT,$0
+       MOVW    0(R0), R0               // arg 1 - status
+       CALL    libc_exit(SB)
+       MOVD    $0, R0                  // crash on failure
        MOVD    R0, (R0)
-       JMP     0(PC)
-
-TEXT runtime·open(SB),NOSPLIT|NOFRAME,$0
-       MOVD    name+0(FP), R0          // arg 1 - path
-       MOVW    mode+8(FP), R1          // arg 2 - mode
-       MOVW    perm+12(FP), R2         // arg 3 - perm
-       MOVD    $5, R8                  // sys_open
-       INVOKE_SYSCALL
-       BCC     2(PC)
-       MOVW    $-1, R0
-       MOVW    R0, ret+16(FP)
-       RET
-
-TEXT runtime·closefd(SB),NOSPLIT|NOFRAME,$0
-       MOVW    fd+0(FP), R0            // arg 1 - fd
-       MOVD    $6, R8                  // sys_close
-       INVOKE_SYSCALL
-       BCC     2(PC)
-       MOVW    $-1, R0
-       MOVW    R0, ret+8(FP)
-       RET
-
-TEXT runtime·read(SB),NOSPLIT|NOFRAME,$0
-       MOVW    fd+0(FP), R0            // arg 1 - fd
-       MOVD    p+8(FP), R1             // arg 2 - buf
-       MOVW    n+16(FP), R2            // arg 3 - nbyte
-       MOVD    $3, R8                  // sys_read
-       INVOKE_SYSCALL
-       BCC     2(PC)
-       NEG     R0, R0
-       MOVW    R0, ret+24(FP)
-       RET
-
-// func pipe() (r, w int32, errno int32)
-TEXT runtime·pipe(SB),NOSPLIT|NOFRAME,$0-12
-       MOVD    $r+0(FP), R0
-       MOVW    $0, R1
-       MOVD    $101, R8                // sys_pipe2
-       INVOKE_SYSCALL
-       BCC     2(PC)
-       NEG     R0, R0
-       MOVW    R0, errno+8(FP)
-       RET
-
-// func pipe2(flags int32) (r, w int32, errno int32)
-TEXT runtime·pipe2(SB),NOSPLIT|NOFRAME,$0-20
-       MOVD    $r+8(FP), R0
-       MOVW    flags+0(FP), R1
-       MOVD    $101, R8                // sys_pipe2
-       INVOKE_SYSCALL
-       BCC     2(PC)
-       NEG     R0, R0
-       MOVW    R0, errno+16(FP)
-       RET
-
-TEXT runtime·write1(SB),NOSPLIT|NOFRAME,$0
-       MOVD    fd+0(FP), R0            // arg 1 - fd
-       MOVD    p+8(FP), R1             // arg 2 - buf
-       MOVW    n+16(FP), R2            // arg 3 - nbyte
-       MOVD    $4, R8                  // sys_write
-       INVOKE_SYSCALL
-       BCC     2(PC)
-       NEG     R0, R0
-       MOVW    R0, ret+24(FP)
-       RET
-
-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)              // tv_sec
-       MUL     R3, R4
-       SUB     R4, R5
-       MOVW    $1000, R4
-       MUL     R4, R5
-       MOVD    R5, 16(RSP)             // tv_nsec
-
-       ADD     $8, RSP, R0             // arg 1 - rqtp
-       MOVD    $0, R1                  // arg 2 - rmtp
-       MOVD    $91, R8                 // sys_nanosleep
-       INVOKE_SYSCALL
-       RET
-
-TEXT runtime·getthrid(SB),NOSPLIT,$0-4
-       MOVD    $299, R8                // sys_getthrid
-       INVOKE_SYSCALL
-       MOVW    R0, ret+0(FP)
-       RET
-
-TEXT runtime·thrkill(SB),NOSPLIT,$0-16
-       MOVW    tid+0(FP), R0           // arg 1 - tid
-       MOVD    sig+8(FP), R1           // arg 2 - signum
-       MOVW    $0, R2                  // arg 3 - tcb
-       MOVD    $119, R8                // sys_thrkill
-       INVOKE_SYSCALL
-       RET
-
-TEXT runtime·raiseproc(SB),NOSPLIT,$0
-       MOVD    $20, R8                 // sys_getpid
-       INVOKE_SYSCALL
-                                       // arg 1 - pid, already in R0
-       MOVW    sig+0(FP), R1           // arg 2 - signum
-       MOVD    $122, R8                // sys_kill
-       INVOKE_SYSCALL
-       RET
-
-TEXT runtime·mmap(SB),NOSPLIT,$0
-       MOVD    addr+0(FP), R0          // arg 1 - addr
-       MOVD    n+8(FP), R1             // arg 2 - len
-       MOVW    prot+16(FP), R2         // arg 3 - prot
-       MOVW    flags+20(FP), R3        // arg 4 - flags
-       MOVW    fd+24(FP), R4           // arg 5 - fd
-       MOVW    $0, R5                  // arg 6 - pad
-       MOVW    off+28(FP), R6          // arg 7 - offset
-       MOVD    $197, R8                // sys_mmap
-       INVOKE_SYSCALL
+       RET
+
+TEXT runtime·getthrid_trampoline(SB),NOSPLIT,$0
+       MOVD    R0, R19                 // pointer to args
+       CALL    libc_getthrid(SB)
+       MOVW    R0, 0(R19)              // return value
+       RET
+
+TEXT runtime·raiseproc_trampoline(SB),NOSPLIT,$0
+       MOVD    R0, R19                 // pointer to args
+       CALL    libc_getpid(SB)         // arg 1 - pid
+       MOVW    0(R19), R1              // arg 2 - signal
+       CALL    libc_kill(SB)
+       RET
+
+TEXT runtime·sched_yield_trampoline(SB),NOSPLIT,$0
+       CALL    libc_sched_yield(SB)
+       RET
+
+TEXT runtime·mmap_trampoline(SB),NOSPLIT,$0
+       MOVD    R0, R19                 // pointer to args
+       MOVD    0(R19), R0              // arg 1 - addr
+       MOVD    8(R19), R1              // arg 2 - len
+       MOVW    16(R19), R2             // arg 3 - prot
+       MOVW    20(R19), R3             // arg 4 - flags
+       MOVW    24(R19), R4             // arg 5 - fid
+       MOVW    28(R19), R5             // arg 6 - offset
+       CALL    libc_mmap(SB)
        MOVD    $0, R1
-       BCC     3(PC)
-       MOVD    R0, R1                  // if error, move to R1
+       CMP     $-1, R0
+       BNE     noerr
+       CALL    libc_errno(SB)
+       MOVW    (R0), R1                // errno
        MOVD    $0, R0
-       MOVD    R0, p+32(FP)
-       MOVD    R1, err+40(FP)
+noerr:
+       MOVD    R0, 32(R19)
+       MOVD    R1, 40(R19)
+       RET
+
+TEXT runtime·munmap_trampoline(SB),NOSPLIT,$0
+       MOVD    8(R0), R1               // arg 2 - len
+       MOVD    0(R0), R0               // arg 1 - addr
+       CALL    libc_munmap(SB)
+       CMP     $-1, R0
+       BNE     3(PC)
+       MOVD    $0, R0                  // crash on failure
+       MOVD    R0, (R0)
+       RET
+
+TEXT runtime·madvise_trampoline(SB), NOSPLIT, $0
+       MOVD    8(R0), R1               // arg 2 - len
+       MOVW    16(R0), R2              // arg 3 - advice
+       MOVD    0(R0), R0               // arg 1 - addr
+       CALL    libc_madvise(SB)
+       // ignore failure - maybe pages are locked
+       RET
+
+TEXT runtime·open_trampoline(SB),NOSPLIT,$0
+       MOVW    8(R0), R1               // arg 2 - flags
+       MOVW    12(R0), R2              // arg 3 - mode
+       MOVD    0(R0), R0               // arg 1 - path
+       MOVD    $0, R3                  // varargs
+       CALL    libc_open(SB)
+       RET
+
+TEXT runtime·close_trampoline(SB),NOSPLIT,$0
+       MOVD    0(R0), R0               // arg 1 - fd
+       CALL    libc_close(SB)
+       RET
+
+TEXT runtime·read_trampoline(SB),NOSPLIT,$0
+       MOVD    8(R0), R1               // arg 2 - buf
+       MOVW    16(R0), R2              // arg 3 - count
+       MOVW    0(R0), R0               // arg 1 - fd
+       CALL    libc_read(SB)
+       CMP     $-1, R0
+       BNE     noerr
+       CALL    libc_errno(SB)
+       MOVW    (R0), R0                // errno
+       NEG     R0, R0                  // caller expects negative errno value
+noerr:
+       RET
+
+TEXT runtime·write_trampoline(SB),NOSPLIT,$0
+       MOVD    8(R0), R1               // arg 2 - buf
+       MOVW    16(R0), R2              // arg 3 - count
+       MOVW    0(R0), R0               // arg 1 - fd
+       CALL    libc_write(SB)
+       CMP     $-1, R0
+       BNE     noerr
+       CALL    libc_errno(SB)
+       MOVW    (R0), R0                // errno
+       NEG     R0, R0                  // caller expects negative errno value
+noerr:
+       RET
+
+TEXT runtime·pipe2_trampoline(SB),NOSPLIT,$0
+       MOVW    8(R0), R1               // arg 2 - flags
+       MOVD    0(R0), R0               // arg 1 - filedes
+       CALL    libc_pipe2(SB)
+       CMP     $-1, R0
+       BNE     noerr
+       CALL    libc_errno(SB)
+       MOVW    (R0), R0                // errno
+       NEG     R0, R0                  // caller expects negative errno value
+noerr:
+       RET
+
+TEXT runtime·setitimer_trampoline(SB),NOSPLIT,$0
+       MOVD    8(R0), R1               // arg 2 - new
+       MOVD    16(R0), R2              // arg 3 - old
+       MOVW    0(R0), R0               // arg 1 - which
+       CALL    libc_setitimer(SB)
+       RET
+
+TEXT runtime·usleep_trampoline(SB),NOSPLIT,$0
+       MOVD    0(R0), R0               // arg 1 - usec
+       CALL    libc_usleep(SB)
+       RET
+
+TEXT runtime·sysctl_trampoline(SB),NOSPLIT,$0
+       MOVW    8(R0), R1               // arg 2 - miblen
+       MOVD    16(R0), R2              // arg 3 - out
+       MOVD    24(R0), R3              // arg 4 - size
+       MOVD    32(R0), R4              // arg 5 - dst
+       MOVD    40(R0), R5              // arg 6 - ndst
+       MOVD    0(R0), R0               // arg 1 - mib
+       CALL    libc_sysctl(SB)
+       RET
+
+TEXT runtime·kqueue_trampoline(SB),NOSPLIT,$0
+       CALL    libc_kqueue(SB)
+       RET
+
+TEXT runtime·kevent_trampoline(SB),NOSPLIT,$0
+       MOVD    8(R0), R1               // arg 2 - keventt
+       MOVW    16(R0), R2              // arg 3 - nch
+       MOVD    24(R0), R3              // arg 4 - ev
+       MOVW    32(R0), R4              // arg 5 - nev
+       MOVD    40(R0), R5              // arg 6 - ts
+       MOVW    0(R0), R0               // arg 1 - kq
+       CALL    libc_kevent(SB)
+       CMP     $-1, R0
+       BNE     noerr
+       CALL    libc_errno(SB)
+       MOVW    (R0), R0                // errno
+       NEG     R0, R0                  // caller expects negative errno value
+noerr:
+       RET
+
+TEXT runtime·clock_gettime_trampoline(SB),NOSPLIT,$0
+       MOVD    8(R0), R1               // arg 2 - tp
+       MOVD    0(R0), R0               // arg 1 - clock_id
+       CALL    libc_clock_gettime(SB)
+       CMP     $-1, R0
+       BNE     3(PC)
+       MOVD    $0, R0                  // crash on failure
+       MOVD    R0, (R0)
+       RET
+
+TEXT runtime·fcntl_trampoline(SB),NOSPLIT,$0
+       MOVW    4(R0), R1               // arg 2 - cmd
+       MOVW    8(R0), R2               // arg 3 - arg
+       MOVW    0(R0), R0               // arg 1 - fd
+       MOVD    $0, R3                  // vararg
+       CALL    libc_fcntl(SB)
+       RET
+
+TEXT runtime·sigaction_trampoline(SB),NOSPLIT,$0
+       MOVD    8(R0), R1               // arg 2 - new
+       MOVD    16(R0), R2              // arg 3 - old
+       MOVW    0(R0), R0               // arg 1 - sig
+       CALL    libc_sigaction(SB)
+       CMP     $-1, R0
+       BNE     3(PC)
+       MOVD    $0, R0                  // crash on syscall failure
+       MOVD    R0, (R0)
        RET
 
-TEXT runtime·munmap(SB),NOSPLIT,$0
-       MOVD    addr+0(FP), R0          // arg 1 - addr
-       MOVD    n+8(FP), R1             // arg 2 - len
-       MOVD    $73, R8                 // sys_munmap
-       INVOKE_SYSCALL
-       BCC     3(PC)
+TEXT runtime·sigprocmask_trampoline(SB),NOSPLIT,$0
+       MOVD    8(R0), R1               // arg 2 - new
+       MOVD    16(R0), R2              // arg 3 - old
+       MOVW    0(R0), R0               // arg 1 - how
+       CALL    libc_pthread_sigmask(SB)
+       CMP     $-1, R0
+       BNE     3(PC)
        MOVD    $0, R0                  // crash on syscall failure
        MOVD    R0, (R0)
        RET
 
-TEXT runtime·madvise(SB),NOSPLIT,$0
-       MOVD    addr+0(FP), R0          // arg 1 - addr
-       MOVD    n+8(FP), R1             // arg 2 - len
-       MOVW    flags+16(FP), R2        // arg 2 - flags
-       MOVD    $75, R8                 // sys_madvise
-       INVOKE_SYSCALL
-       BCC     2(PC)
-       MOVW    $-1, R0
-       MOVW    R0, ret+24(FP)
-       RET
-
-TEXT runtime·setitimer(SB),NOSPLIT,$0
-       MOVW    mode+0(FP), R0          // arg 1 - mode
-       MOVD    new+8(FP), R1           // arg 2 - new value
-       MOVD    old+16(FP), R2          // arg 3 - old value
-       MOVD    $69, R8                 // sys_setitimer
-       INVOKE_SYSCALL
-       RET
-
-// func walltime1() (sec int64, nsec int32)
-TEXT runtime·walltime1(SB), NOSPLIT, $32
-       MOVW    CLOCK_REALTIME, R0      // arg 1 - clock_id
-       MOVD    $8(RSP), R1             // arg 2 - tp
-       MOVD    $87, R8                 // sys_clock_gettime
-       INVOKE_SYSCALL
-
-       MOVD    8(RSP), R0              // sec
-       MOVD    16(RSP), R1             // nsec
-       MOVD    R0, sec+0(FP)
-       MOVW    R1, nsec+8(FP)
-
-       RET
-
-// int64 nanotime1(void) so really
-// void nanotime1(int64 *nsec)
-TEXT runtime·nanotime1(SB),NOSPLIT,$32
-       MOVW    CLOCK_MONOTONIC, R0     // arg 1 - clock_id
-       MOVD    $8(RSP), R1             // arg 2 - tp
-       MOVD    $87, R8                 // sys_clock_gettime
-       INVOKE_SYSCALL
-
-       MOVW    8(RSP), R3              // sec
-       MOVW    16(RSP), R5             // nsec
-
-       MOVD    $1000000000, R4
-       MUL     R4, R3
-       ADD     R5, R3
-       MOVD    R3, ret+0(FP)
-       RET
-
-TEXT runtime·sigaction(SB),NOSPLIT,$0
-       MOVW    sig+0(FP), R0           // arg 1 - signum
-       MOVD    new+8(FP), R1           // arg 2 - new sigaction
-       MOVD    old+16(FP), R2          // arg 3 - old sigaction
-       MOVD    $46, R8                 // sys_sigaction
-       INVOKE_SYSCALL
-       BCC     3(PC)
-       MOVD    $3, R0                  // crash on syscall failure
+TEXT runtime·sigaltstack_trampoline(SB),NOSPLIT,$0
+       MOVD    8(R0), R1               // arg 2 - old
+       MOVD    0(R0), R0               // arg 1 - new
+       CALL    libc_sigaltstack(SB)
+       CMP     $-1, R0
+       BNE     3(PC)
+       MOVD    $0, R0                  // crash on syscall failure
        MOVD    R0, (R0)
        RET
 
-TEXT runtime·obsdsigprocmask(SB),NOSPLIT,$0
-       MOVW    how+0(FP), R0           // arg 1 - mode
-       MOVW    new+4(FP), R1           // arg 2 - new
-       MOVD    $48, R8                 // sys_sigprocmask
-       INVOKE_SYSCALL
-       BCC     3(PC)
-       MOVD    $3, R8                  // crash on syscall failure
-       MOVD    R8, (R8)
-       MOVW    R0, ret+8(FP)
-       RET
-
-TEXT runtime·sigaltstack(SB),NOSPLIT,$0
-       MOVD    new+0(FP), R0           // arg 1 - new sigaltstack
-       MOVD    old+8(FP), R1           // arg 2 - old sigaltstack
-       MOVD    $288, R8                // sys_sigaltstack
-       INVOKE_SYSCALL
-       BCC     3(PC)
-       MOVD    $0, R8                  // crash on syscall failure
-       MOVD    R8, (R8)
-       RET
-
-TEXT runtime·osyield(SB),NOSPLIT,$0
-       MOVD    $298, R8                // sys_sched_yield
-       INVOKE_SYSCALL
-       RET
-
-TEXT runtime·thrsleep(SB),NOSPLIT,$0
-       MOVD    ident+0(FP), R0         // arg 1 - ident
-       MOVW    clock_id+8(FP), R1      // arg 2 - clock_id
-       MOVD    tsp+16(FP), R2          // arg 3 - tsp
-       MOVD    lock+24(FP), R3         // arg 4 - lock
-       MOVD    abort+32(FP), R4        // arg 5 - abort
-       MOVD    $94, R8                 // sys___thrsleep
-       INVOKE_SYSCALL
-       MOVW    R0, ret+40(FP)
-       RET
-
-TEXT runtime·thrwakeup(SB),NOSPLIT,$0
-       MOVD    ident+0(FP), R0         // arg 1 - ident
-       MOVW    n+8(FP), R1             // arg 2 - n
-       MOVD    $301, R8                // sys___thrwakeup
-       INVOKE_SYSCALL
-       MOVW    R0, ret+16(FP)
-       RET
-
-TEXT runtime·sysctl(SB),NOSPLIT,$0
-       MOVD    mib+0(FP), R0           // arg 1 - mib
-       MOVW    miblen+8(FP), R1        // arg 2 - miblen
-       MOVD    out+16(FP), R2          // arg 3 - out
-       MOVD    size+24(FP), R3         // arg 4 - size
-       MOVD    dst+32(FP), R4          // arg 5 - dest
-       MOVD    ndst+40(FP), R5         // arg 6 - newlen
-       MOVD    $202, R8                // sys___sysctl
-       INVOKE_SYSCALL
-       BCC     2(PC)
-       NEG     R0, R0
-       MOVW    R0, ret+48(FP)
-       RET
-
-// int32 runtime·kqueue(void);
-TEXT runtime·kqueue(SB),NOSPLIT,$0
-       MOVD    $269, R8                // sys_kqueue
-       INVOKE_SYSCALL
-       BCC     2(PC)
-       NEG     R0, R0
-       MOVW    R0, ret+0(FP)
-       RET
-
-// int32 runtime·kevent(int kq, Kevent *changelist, int nchanges, Kevent *eventlist, int nevents, Timespec *timeout);
-TEXT runtime·kevent(SB),NOSPLIT,$0
-       MOVW    kq+0(FP), R0            // arg 1 - kq
-       MOVD    ch+8(FP), R1            // arg 2 - changelist
-       MOVW    nch+16(FP), R2          // arg 3 - nchanges
-       MOVD    ev+24(FP), R3           // arg 4 - eventlist
-       MOVW    nev+32(FP), R4          // arg 5 - nevents
-       MOVD    ts+40(FP), R5           // arg 6 - timeout
-       MOVD    $72, R8                 // sys_kevent
-       INVOKE_SYSCALL
-       BCC     2(PC)
-       NEG     R0, R0
-       MOVW    R0, ret+48(FP)
-       RET
-
-// func closeonexec(fd int32)
-TEXT runtime·closeonexec(SB),NOSPLIT,$0
-       MOVW    fd+0(FP), R0            // arg 1 - fd
-       MOVD    $2, R1                  // arg 2 - cmd (F_SETFD)
-       MOVD    $1, R2                  // arg 3 - arg (FD_CLOEXEC)
-       MOVD    $92, R8                 // sys_fcntl
-       INVOKE_SYSCALL
-       RET
-
-// func runtime·setNonblock(int32 fd)
-TEXT runtime·setNonblock(SB),NOSPLIT|NOFRAME,$0-4
-       MOVW    fd+0(FP), R0            // arg 1 - fd
-       MOVD    $3, R1                  // arg 2 - cmd (F_GETFL)
-       MOVD    $0, R2                  // arg 3
-       MOVD    $92, R8                 // sys_fcntl
-       INVOKE_SYSCALL
-       MOVD    $4, R2                  // O_NONBLOCK
-       ORR     R0, R2                  // arg 3 - flags
-       MOVW    fd+0(FP), R0            // arg 1 - fd
-       MOVD    $4, R1                  // arg 2 - cmd (F_SETFL)
-       MOVD    $92, R8                 // sys_fcntl
-       INVOKE_SYSCALL
+// syscall calls a function in libc on behalf of the syscall package.
+// syscall takes a pointer to a struct like:
+// struct {
+//     fn    uintptr
+//     a1    uintptr
+//     a2    uintptr
+//     a3    uintptr
+//     r1    uintptr
+//     r2    uintptr
+//     err   uintptr
+// }
+// syscall must be called on the g0 stack with the
+// C calling convention (use libcCall).
+//
+// syscall expects a 32-bit result and tests for 32-bit -1
+// to decide there was an error.
+TEXT runtime·syscall(SB),NOSPLIT,$0
+       MOVD    R0, R19                 // pointer to args
+
+       MOVD    (0*8)(R19), R11         // fn
+       MOVD    (1*8)(R19), R0          // a1
+       MOVD    (2*8)(R19), R1          // a2
+       MOVD    (3*8)(R19), R2          // a3
+       MOVD    $0, R3                  // vararg
+
+       CALL    R11
+
+       MOVD    R0, (4*8)(R19)          // r1
+       MOVD    R1, (5*8)(R19)          // r2
+
+       // Standard libc functions return -1 on error
+       // and set errno.
+       CMPW    $-1, R0
+       BNE     ok
+
+       // Get error code from libc.
+       CALL    libc_errno(SB)
+       MOVW    (R0), R0
+       MOVD    R0, (6*8)(R19)          // err
+
+ok:
+       RET
+
+// syscallX calls a function in libc on behalf of the syscall package.
+// syscallX takes a pointer to a struct like:
+// struct {
+//     fn    uintptr
+//     a1    uintptr
+//     a2    uintptr
+//     a3    uintptr
+//     r1    uintptr
+//     r2    uintptr
+//     err   uintptr
+// }
+// syscallX must be called on the g0 stack with the
+// C calling convention (use libcCall).
+//
+// syscallX is like syscall but expects a 64-bit result
+// and tests for 64-bit -1 to decide there was an error.
+TEXT runtime·syscallX(SB),NOSPLIT,$0
+       MOVD    R0, R19                 // pointer to args
+
+       MOVD    (0*8)(R19), R11         // fn
+       MOVD    (1*8)(R19), R0          // a1
+       MOVD    (2*8)(R19), R1          // a2
+       MOVD    (3*8)(R19), R2          // a3
+       MOVD    $0, R3                  // vararg
+
+       CALL    R11
+
+       MOVD    R0, (4*8)(R19)          // r1
+       MOVD    R1, (5*8)(R19)          // r2
+
+       // Standard libc functions return -1 on error
+       // and set errno.
+       CMP     $-1, R0
+       BNE     ok
+
+       // Get error code from libc.
+       CALL    libc_errno(SB)
+       MOVW    (R0), R0
+       MOVD    R0, (6*8)(R19)          // err
+
+ok:
+       RET
+
+// syscall6 calls a function in libc on behalf of the syscall package.
+// syscall6 takes a pointer to a struct like:
+// struct {
+//     fn    uintptr
+//     a1    uintptr
+//     a2    uintptr
+//     a3    uintptr
+//     a4    uintptr
+//     a5    uintptr
+//     a6    uintptr
+//     r1    uintptr
+//     r2    uintptr
+//     err   uintptr
+// }
+// syscall6 must be called on the g0 stack with the
+// C calling convention (use libcCall).
+//
+// syscall6 expects a 32-bit result and tests for 32-bit -1
+// to decide there was an error.
+TEXT runtime·syscall6(SB),NOSPLIT,$0
+       MOVD    R0, R19                 // pointer to args
+
+       MOVD    (0*8)(R19), R11         // fn
+       MOVD    (1*8)(R19), R0          // a1
+       MOVD    (2*8)(R19), R1          // a2
+       MOVD    (3*8)(R19), R2          // a3
+       MOVD    (4*8)(R19), R3          // a4
+       MOVD    (5*8)(R19), R4          // a5
+       MOVD    (6*8)(R19), R5          // a6
+       MOVD    $0, R6                  // vararg
+
+       CALL    R11
+
+       MOVD    R0, (7*8)(R19)          // r1
+       MOVD    R1, (8*8)(R19)          // r2
+
+       // Standard libc functions return -1 on error
+       // and set errno.
+       CMPW    $-1, R0
+       BNE     ok
+
+       // Get error code from libc.
+       CALL    libc_errno(SB)
+       MOVW    (R0), R0
+       MOVD    R0, (9*8)(R19)          // err
+
+ok:
+       RET
+
+// syscall6X calls a function in libc on behalf of the syscall package.
+// syscall6X takes a pointer to a struct like:
+// struct {
+//     fn    uintptr
+//     a1    uintptr
+//     a2    uintptr
+//     a3    uintptr
+//     a4    uintptr
+//     a5    uintptr
+//     a6    uintptr
+//     r1    uintptr
+//     r2    uintptr
+//     err   uintptr
+// }
+// syscall6X must be called on the g0 stack with the
+// C calling convention (use libcCall).
+//
+// syscall6X is like syscall6 but expects a 64-bit result
+// and tests for 64-bit -1 to decide there was an error.
+TEXT runtime·syscall6X(SB),NOSPLIT,$0
+       MOVD    R0, R19                 // pointer to args
+
+       MOVD    (0*8)(R19), R11         // fn
+       MOVD    (1*8)(R19), R0          // a1
+       MOVD    (2*8)(R19), R1          // a2
+       MOVD    (3*8)(R19), R2          // a3
+       MOVD    (4*8)(R19), R3          // a4
+       MOVD    (5*8)(R19), R4          // a5
+       MOVD    (6*8)(R19), R5          // a6
+       MOVD    $0, R6                  // vararg
+
+       CALL    R11
+
+       MOVD    R0, (7*8)(R19)          // r1
+       MOVD    R1, (8*8)(R19)          // r2
+
+       // Standard libc functions return -1 on error
+       // and set errno.
+       CMP     $-1, R0
+       BNE     ok
+
+       // Get error code from libc.
+       CALL    libc_errno(SB)
+       MOVW    (R0), R0
+       MOVD    R0, (9*8)(R19)          // err
+
+ok:
+       RET
+
+// syscall10 calls a function in libc on behalf of the syscall package.
+// syscall10 takes a pointer to a struct like:
+// struct {
+//     fn    uintptr
+//     a1    uintptr
+//     a2    uintptr
+//     a3    uintptr
+//     a4    uintptr
+//     a5    uintptr
+//     a6    uintptr
+//     a7    uintptr
+//     a8    uintptr
+//     a9    uintptr
+//     a10   uintptr
+//     r1    uintptr
+//     r2    uintptr
+//     err   uintptr
+// }
+// syscall10 must be called on the g0 stack with the
+// C calling convention (use libcCall).
+TEXT runtime·syscall10(SB),NOSPLIT,$0
+       MOVD    R0, R19                 // pointer to args
+
+       MOVD    (0*8)(R19), R11         // fn
+       MOVD    (1*8)(R19), R0          // a1
+       MOVD    (2*8)(R19), R1          // a2
+       MOVD    (3*8)(R19), R2          // a3
+       MOVD    (4*8)(R19), R3          // a4
+       MOVD    (5*8)(R19), R4          // a5
+       MOVD    (6*8)(R19), R5          // a6
+       MOVD    (7*8)(R19), R6          // a7
+       MOVD    (8*8)(R19), R7          // a8
+       MOVD    (9*8)(R19), R8          // a9
+       MOVD    (10*8)(R19), R9         // a10
+       MOVD    $0, R10                 // vararg
+
+       CALL    R11
+
+       MOVD    R0, (11*8)(R19)         // r1
+       MOVD    R1, (12*8)(R19)         // r2
+
+       // Standard libc functions return -1 on error
+       // and set errno.
+       CMPW    $-1, R0
+       BNE     ok
+
+       // Get error code from libc.
+       CALL    libc_errno(SB)
+       MOVW    (R0), R0
+       MOVD    R0, (13*8)(R19)         // err
+
+ok:
+       RET
+
+// syscall10X calls a function in libc on behalf of the syscall package.
+// syscall10X takes a pointer to a struct like:
+// struct {
+//     fn    uintptr
+//     a1    uintptr
+//     a2    uintptr
+//     a3    uintptr
+//     a4    uintptr
+//     a5    uintptr
+//     a6    uintptr
+//     a7    uintptr
+//     a8    uintptr
+//     a9    uintptr
+//     a10   uintptr
+//     r1    uintptr
+//     r2    uintptr
+//     err   uintptr
+// }
+// syscall10X must be called on the g0 stack with the
+// C calling convention (use libcCall).
+//
+// syscall10X is like syscall10 but expects a 64-bit result
+// and tests for 64-bit -1 to decide there was an error.
+TEXT runtime·syscall10X(SB),NOSPLIT,$0
+       MOVD    R0, R19                 // pointer to args
+
+       MOVD    (0*8)(R19), R11         // fn
+       MOVD    (1*8)(R19), R0          // a1
+       MOVD    (2*8)(R19), R1          // a2
+       MOVD    (3*8)(R19), R2          // a3
+       MOVD    (4*8)(R19), R3          // a4
+       MOVD    (5*8)(R19), R4          // a5
+       MOVD    (6*8)(R19), R5          // a6
+       MOVD    (7*8)(R19), R6          // a7
+       MOVD    (8*8)(R19), R7          // a8
+       MOVD    (9*8)(R19), R8          // a9
+       MOVD    (10*8)(R19), R9         // a10
+       MOVD    $0, R10                 // vararg
+
+       CALL    R11
+
+       MOVD    R0, (11*8)(R19)         // r1
+       MOVD    R1, (12*8)(R19)         // r2
+
+       // Standard libc functions return -1 on error
+       // and set errno.
+       CMP     $-1, R0
+       BNE     ok
+
+       // Get error code from libc.
+       CALL    libc_errno(SB)
+       MOVW    (R0), R0
+       MOVD    R0, (13*8)(R19)         // err
+
+ok:
        RET
index 105d6a5faae0cf78d4badfa926e903f7ab20d110..781acbd7706ac68627f3962bfd9d11f6c8953f41 100644 (file)
@@ -25,6 +25,7 @@ func init() {
        register("RecursivePanic2", RecursivePanic2)
        register("RecursivePanic3", RecursivePanic3)
        register("RecursivePanic4", RecursivePanic4)
+       register("RecursivePanic5", RecursivePanic5)
        register("GoexitExit", GoexitExit)
        register("GoNil", GoNil)
        register("MainGoroutineID", MainGoroutineID)
@@ -160,6 +161,44 @@ func RecursivePanic4() {
        panic("first panic")
 }
 
+// Test case where we have an open-coded defer higher up the stack (in two), and
+// in the current function (three) we recover in a defer while we still have
+// another defer to be processed.
+func RecursivePanic5() {
+       one()
+       panic("third panic")
+}
+
+//go:noinline
+func one() {
+       two()
+}
+
+//go:noinline
+func two() {
+       defer func() {
+       }()
+
+       three()
+}
+
+//go:noinline
+func three() {
+       defer func() {
+       }()
+
+       defer func() {
+               fmt.Println(recover())
+       }()
+
+       defer func() {
+               fmt.Println(recover())
+               panic("second panic")
+       }()
+
+       panic("first panic")
+}
+
 func GoexitExit() {
        println("t1")
        go func() {
diff --git a/src/runtime/testdata/testwinsignal/main.go b/src/runtime/testdata/testwinsignal/main.go
new file mode 100644 (file)
index 0000000..d8cd884
--- /dev/null
@@ -0,0 +1,19 @@
+package main\r
+\r
+import (\r
+       "fmt"\r
+       "os"\r
+       "os/signal"\r
+       "time"\r
+)\r
+\r
+func main() {\r
+       c := make(chan os.Signal, 1)\r
+       signal.Notify(c)\r
+\r
+       fmt.Println("ready")\r
+       sig := <-c\r
+\r
+       time.Sleep(time.Second)\r
+       fmt.Println(sig)\r
+}\r
index 29af78c801cbdd46e31b1fb371b53155994f444f..f2ae87d623e765737b4e232cdf4e82f499d3b591 100644 (file)
@@ -1,4 +1,4 @@
-// +build netbsd openbsd
+// +build netbsd
 
 // Copyright 2016 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
@@ -8,7 +8,7 @@
 #include "funcdata.h"
 
 //
-// Syscall9 support for AMD64, NetBSD and OpenBSD
+// Syscall9 support for AMD64, NetBSD
 //
 
 // func Syscall9(trap int64, a1, a2, a3, a4, a5, a6, a7, a8, a9 int64) (r1, r2, err int64);
diff --git a/src/syscall/asm_openbsd_amd64.s b/src/syscall/asm_openbsd_amd64.s
new file mode 100644 (file)
index 0000000..8d2ffd1
--- /dev/null
@@ -0,0 +1,32 @@
+// 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.
+
+#include "textflag.h"
+
+//
+// System call support for AMD64, OpenBSD
+//
+
+// Provide these function names via assembly so they are provided as ABI0,
+// rather than ABIInternal.
+
+// func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
+TEXT   ·Syscall(SB),NOSPLIT,$0-56
+       JMP     ·syscallInternal(SB)
+
+// func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
+TEXT   ·Syscall6(SB),NOSPLIT,$0-80
+       JMP     ·syscall6Internal(SB)
+
+// func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
+TEXT   ·RawSyscall(SB),NOSPLIT,$0-56
+       JMP     ·rawSyscallInternal(SB)
+
+// func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
+TEXT   ·RawSyscall6(SB),NOSPLIT,$0-80
+       JMP     ·rawSyscall6Internal(SB)
+
+// func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno)
+TEXT   ·Syscall9(SB),NOSPLIT,$0-104
+       JMP     ·syscall9Internal(SB)
index dcbed10cbea39d20a13f2ab270654720af8a3046..61595a11a37303466db4f0440485037f51f609f1 100644 (file)
 
 #include "textflag.h"
 
-// See comment in runtime/sys_openbsd_arm64.s re this construction.
-#define        INVOKE_SYSCALL  \
-       SVC;            \
-       NOOP;           \
-       NOOP
+//
+// System call support for ARM64, OpenBSD
+//
 
-// func Syscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64);
-TEXT ·Syscall(SB),NOSPLIT,$0-56
-       BL      runtime·entersyscall(SB)
-       MOVD    a1+8(FP), R0
-       MOVD    a2+16(FP), R1
-       MOVD    a3+24(FP), R2
-       MOVD    $0, R3
-       MOVD    $0, R4
-       MOVD    $0, R5
-       MOVD    trap+0(FP), R8  // syscall number
-       INVOKE_SYSCALL
-       BCC     ok
-       MOVD    $-1, R4
-       MOVD    R4, r1+32(FP)   // r1
-       MOVD    ZR, r2+40(FP)   // r2
-       MOVD    R0, err+48(FP)  // errno
-       BL      runtime·exitsyscall(SB)
-       RET
-ok:
-       MOVD    R0, r1+32(FP)   // r1
-       MOVD    R1, r2+40(FP)   // r2
-       MOVD    ZR, err+48(FP)  // errno
-       BL      runtime·exitsyscall(SB)
-       RET
+// Provide these function names via assembly so they are provided as ABI0,
+// rather than ABIInternal.
 
-TEXT ·Syscall6(SB),NOSPLIT,$0-80
-       BL      runtime·entersyscall(SB)
-       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
-       MOVD    trap+0(FP), R8  // syscall number
-       INVOKE_SYSCALL
-       BCC     ok
-       MOVD    $-1, R4
-       MOVD    R4, r1+56(FP)   // r1
-       MOVD    ZR, r2+64(FP)   // r2
-       MOVD    R0, err+72(FP)  // errno
-       BL      runtime·exitsyscall(SB)
-       RET
-ok:
-       MOVD    R0, r1+56(FP)   // r1
-       MOVD    R1, r2+64(FP)   // r2
-       MOVD    ZR, err+72(FP)  // errno
-       BL      runtime·exitsyscall(SB)
-       RET
+// func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
+TEXT   ·Syscall(SB),NOSPLIT,$0-56
+       JMP     ·syscallInternal(SB)
 
-TEXT ·Syscall9(SB),NOSPLIT,$0-104
-       BL      runtime·entersyscall(SB)
-       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
-       MOVD    a7+56(FP), R6
-       MOVD    a8+64(FP), R7
-       MOVD    a9+72(FP), R8   // on stack
-       MOVD    R8, 8(RSP)
-       MOVD    num+0(FP), R8   // syscall number
-       INVOKE_SYSCALL
-       BCC     ok
-       MOVD    $-1, R4
-       MOVD    R4, r1+80(FP)   // r1
-       MOVD    ZR, r2+88(FP)   // r2
-       MOVD    R0, err+96(FP)  // errno
-       BL      runtime·exitsyscall(SB)
-       RET
-ok:
-       MOVD    R0, r1+80(FP)   // r1
-       MOVD    R1, r2+88(FP)   // r2
-       MOVD    ZR, err+96(FP)  // errno
-       BL      runtime·exitsyscall(SB)
-       RET
+// func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
+TEXT   ·Syscall6(SB),NOSPLIT,$0-80
+       JMP     ·syscall6Internal(SB)
 
-TEXT ·RawSyscall(SB),NOSPLIT,$0-56
-       MOVD    a1+8(FP), R0
-       MOVD    a2+16(FP), R1
-       MOVD    a3+24(FP), R2
-       MOVD    $0, R3
-       MOVD    $0, R4
-       MOVD    $0, R5
-       MOVD    trap+0(FP), R8  // syscall number
-       INVOKE_SYSCALL
-       BCC     ok
-       MOVD    $-1, R4
-       MOVD    R4, r1+32(FP)   // r1
-       MOVD    ZR, r2+40(FP)   // r2
-       MOVD    R0, err+48(FP)  // errno
-       RET
-ok:
-       MOVD    R0, r1+32(FP)   // r1
-       MOVD    R1, r2+40(FP)   // r2
-       MOVD    ZR, err+48(FP)  // errno
-       RET
+// func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
+TEXT   ·RawSyscall(SB),NOSPLIT,$0-56
+       JMP     ·rawSyscallInternal(SB)
 
-TEXT ·RawSyscall6(SB),NOSPLIT,$0-80
-       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
-       MOVD    trap+0(FP), R8  // syscall number
-       INVOKE_SYSCALL
-       BCC     ok
-       MOVD    $-1, R4
-       MOVD    R4, r1+56(FP)   // r1
-       MOVD    ZR, r2+64(FP)   // r2
-       MOVD    R0, err+72(FP)  // errno
-       RET
-ok:
-       MOVD    R0, r1+56(FP)   // r1
-       MOVD    R1, r2+64(FP)   // r2
-       MOVD    ZR, err+72(FP)  // errno
-       RET
+// func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
+TEXT   ·RawSyscall6(SB),NOSPLIT,$0-80
+       JMP     ·rawSyscall6Internal(SB)
+
+// func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno)
+TEXT   ·Syscall9(SB),NOSPLIT,$0-104
+       JMP     ·syscall9Internal(SB)
index 9cf3fe0d358fb4f72b4b65ce6ed6dbd7589ec8f8..aa03eb96a0ad900b0b0e7e28ba07f9c1c70bd835 100644 (file)
@@ -1,4 +1,4 @@
-// +build netbsd freebsd openbsd dragonfly
+// +build netbsd freebsd dragonfly
 
 // Copyright 2009 The Go Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style
index b297db96cc4fa899cdc747e3931f508167ffa5a6..940a81b58ee90fbad19aa9b5c475004d60183364 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build dragonfly freebsd netbsd openbsd
+// +build dragonfly freebsd netbsd openbsd,!amd64,!arm64
 
 package syscall
 
similarity index 99%
rename from src/syscall/exec_darwin.go
rename to src/syscall/exec_libc2.go
index f035d555535609a98b1e8ca9f60ca12212666620..45d3f85baff9ac3c74adec26cc5df145eee89708 100644 (file)
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build darwin openbsd,amd64 openbsd,arm64
+
 package syscall
 
 import (
index 725c2bc1f92195252f056c47c98c55da7eb144fa..1f49c78ef9d7e276621e59f3cf596f62565a5a8d 100644 (file)
@@ -272,6 +272,7 @@ func runtime_AfterExec()
 // avoids a build dependency for other platforms.
 var execveLibc func(path uintptr, argv uintptr, envp uintptr) Errno
 var execveDarwin func(path *byte, argv **byte, envp **byte) error
+var execveOpenBSD func(path *byte, argv **byte, envp **byte) error
 
 // Exec invokes the execve(2) system call.
 func Exec(argv0 string, argv []string, envv []string) (err error) {
@@ -299,6 +300,9 @@ func Exec(argv0 string, argv []string, envv []string) (err error) {
        } else if runtime.GOOS == "darwin" || runtime.GOOS == "ios" {
                // Similarly on Darwin.
                err1 = execveDarwin(argv0p, &argvp[0], &envvp[0])
+       } else if runtime.GOOS == "openbsd" && runtime.GOARCH == "amd64" {
+               // Similarly on OpenBSD.
+               err1 = execveOpenBSD(argv0p, &argvp[0], &envvp[0])
        } else {
                _, _, err1 = RawSyscall(SYS_EXECVE,
                        uintptr(unsafe.Pointer(argv0p)),
index 8f1111dafbf49787f0f52e07c9f2c4b7b666e5ae..d1e28efa8c0cd0b5742e6a64562497680ef913a3 100755 (executable)
@@ -125,13 +125,13 @@ darwin_amd64)
        mkerrors="$mkerrors -m64"
        mksyscall="./mksyscall.pl -darwin"
        mktypes="GOARCH=$GOARCH go tool cgo -godefs"
-       mkasm="go run mkasm_darwin.go"
+       mkasm="go run mkasm.go"
        ;;
 darwin_arm64)
        mkerrors="$mkerrors -m64"
        mksyscall="./mksyscall.pl -darwin"
        mktypes="GOARCH=$GOARCH go tool cgo -godefs"
-       mkasm="go run mkasm_darwin.go"
+       mkasm="go run mkasm.go"
        ;;
 dragonfly_amd64)
        mkerrors="$mkerrors -m64"
@@ -283,6 +283,7 @@ netbsd_arm64)
        mktypes="GOARCH=$GOARCH go tool cgo -godefs"
        ;;
 openbsd_386)
+       GOOSARCH_in="syscall_openbsd1.go syscall_openbsd_$GOARCH.go"
        mkerrors="$mkerrors -m32"
        mksyscall="./mksyscall.pl -l32 -openbsd"
        mksysctl="./mksysctl_openbsd.pl"
@@ -291,14 +292,17 @@ openbsd_386)
        mktypes="GOARCH=$GOARCH go tool cgo -godefs"
        ;;
 openbsd_amd64)
+       GOOSARCH_in="syscall_openbsd_libc.go syscall_openbsd_$GOARCH.go"
        mkerrors="$mkerrors -m64"
-       mksyscall="./mksyscall.pl -openbsd"
+       mksyscall="./mksyscall.pl -openbsd -libc"
        mksysctl="./mksysctl_openbsd.pl"
        zsysctl="zsysctl_openbsd.go"
        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"
+       mkasm="go run mkasm.go"
        ;;
 openbsd_arm)
+       GOOSARCH_in="syscall_openbsd1.go syscall_openbsd_$GOARCH.go"
        mkerrors="$mkerrors"
        mksyscall="./mksyscall.pl -l32 -openbsd -arm"
        mksysctl="./mksysctl_openbsd.pl"
@@ -309,16 +313,19 @@ openbsd_arm)
        mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
        ;;
 openbsd_arm64)
+       GOOSARCH_in="syscall_openbsd_libc.go syscall_openbsd_$GOARCH.go"
        mkerrors="$mkerrors -m64"
-       mksyscall="./mksyscall.pl -openbsd"
+       mksyscall="./mksyscall.pl -openbsd -libc"
        mksysctl="./mksysctl_openbsd.pl"
        zsysctl="zsysctl_openbsd.go"
        mksysnum="curl -s 'http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/src/sys/kern/syscalls.master' | ./mksysnum_openbsd.pl"
        # Let the type of C char be signed to make the bare syscall
        # API consistent between platforms.
        mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
+       mkasm="go run mkasm.go"
        ;;
 openbsd_mips64)
+       GOOSARCH_in="syscall_openbsd1.go syscall_openbsd_$GOARCH.go"
        mkerrors="$mkerrors -m64"
        mksyscall="./mksyscall.pl -openbsd"
        mksysctl="./mksysctl_openbsd.pl"
@@ -327,7 +334,6 @@ openbsd_mips64)
        # Let the type of C char be signed to make the bare syscall
        # API consistent between platforms.
        mktypes="GOARCH=$GOARCH go tool cgo -godefs -- -fsigned-char"
-       GOOSARCH_in=syscall_openbsd_mips64.go
        ;;
 plan9_386)
        mkerrors=
@@ -367,5 +373,5 @@ esac
                # 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";
        fi
-       if [ -n "$mkasm" ]; then echo "$mkasm $GOARCH"; fi
+       if [ -n "$mkasm" ]; then echo "$mkasm $GOOS $GOARCH"; fi
 ) | $run
similarity index 51%
rename from src/syscall/mkasm_darwin.go
rename to src/syscall/mkasm.go
index 1783387a53120970d64691fb3f35e7cad1e46153..2ebaf8d3513e53b2cedb20f85fdcb07cff2c1f17 100644 (file)
@@ -4,8 +4,8 @@
 
 // +build ignore
 
-// mkasm_darwin.go generates assembly trampolines to call libSystem routines from Go.
-//This program must be run after mksyscall.pl.
+// mkasm.go generates assembly trampolines to call library routines from Go.
+// This program must be run after mksyscall.pl.
 package main
 
 import (
@@ -17,18 +17,25 @@ import (
 )
 
 func main() {
-       in1, err := os.ReadFile("syscall_darwin.go")
+       if len(os.Args) != 3 {
+               log.Fatalf("Usage: %s <goos> <arch>", os.Args[0])
+       }
+       goos, arch := os.Args[1], os.Args[2]
+
+       syscallFilename := fmt.Sprintf("syscall_%s.go", goos)
+       syscallArchFilename := fmt.Sprintf("syscall_%s_%s.go", goos, arch)
+
+       in1, err := os.ReadFile(syscallFilename)
        if err != nil {
-               log.Fatalf("can't open syscall_darwin.go: %s", err)
+               log.Fatalf("can't open syscall file: %s", err)
        }
-       arch := os.Args[1]
-       in2, err := os.ReadFile(fmt.Sprintf("syscall_darwin_%s.go", arch))
+       in2, err := os.ReadFile(syscallArchFilename)
        if err != nil {
-               log.Fatalf("can't open syscall_darwin_%s.go: %s", arch, err)
+               log.Fatalf("can't open syscall file: %s", err)
        }
-       in3, err := os.ReadFile(fmt.Sprintf("zsyscall_darwin_%s.go", arch))
+       in3, err := os.ReadFile("z" + syscallArchFilename)
        if err != nil {
-               log.Fatalf("can't open zsyscall_darwin_%s.go: %s", arch, err)
+               log.Fatalf("can't open syscall file: %s", err)
        }
        in := string(in1) + string(in2) + string(in3)
 
@@ -36,7 +43,7 @@ func main() {
 
        var out bytes.Buffer
 
-       fmt.Fprintf(&out, "// go run mkasm_darwin.go %s\n", strings.Join(os.Args[1:], " "))
+       fmt.Fprintf(&out, "// go run mkasm.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") {
@@ -50,8 +57,8 @@ func main() {
                        fmt.Fprintf(&out, "\tJMP\t%s(SB)\n", fn)
                }
        }
-       err = os.WriteFile(fmt.Sprintf("zsyscall_darwin_%s.s", arch), out.Bytes(), 0644)
+       err = os.WriteFile(fmt.Sprintf("zsyscall_%s_%s.s", goos, arch), out.Bytes(), 0644)
        if err != nil {
-               log.Fatalf("can't write zsyscall_darwin_%s.s: %s", arch, err)
+               log.Fatalf("can't write syscall file: %s", err)
        }
 }
index 26c93ffe5b5ab290995651539f39e3dd69fb457e..c1ed3a35d97705be137057129000cc13aaadf3ae 100755 (executable)
@@ -30,6 +30,7 @@ my $openbsd = 0;
 my $netbsd = 0;
 my $dragonfly = 0;
 my $arm = 0; # 64-bit value should use (even, odd)-pair
+my $libc = 0;
 my $tags = "";  # build tags
 
 if($ARGV[0] eq "-b32") {
@@ -45,6 +46,7 @@ if($ARGV[0] eq "-plan9") {
 }
 if($ARGV[0] eq "-darwin") {
        $darwin = 1;
+       $libc = 1;
        shift;
 }
 if($ARGV[0] eq "-openbsd") {
@@ -63,6 +65,10 @@ if($ARGV[0] eq "-arm") {
        $arm = 1;
        shift;
 }
+if($ARGV[0] eq "-libc") {
+       $libc = 1;
+       shift;
+}
 if($ARGV[0] eq "-tags") {
        shift;
        $tags = $ARGV[0];
@@ -125,7 +131,7 @@ while(<>) {
        # without reading the header.
        $text .= "// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT\n\n";
 
-       if ($darwin && $func eq "ptrace1") {
+       if (($darwin || ($openbsd && $libc)) && $func eq "ptrace") {
                # The ptrace function is called from forkAndExecInChild where stack
                # growth is forbidden.
                $text .= "//go:nosplit\n"
@@ -176,7 +182,9 @@ while(<>) {
                        push @args, "uintptr(_p$n)", "uintptr(len($name))";
                        $n++;
                } elsif($type eq "int64" && ($openbsd || $netbsd)) {
-                       push @args, "0";
+                       if (!$libc) {
+                               push @args, "0";
+                       }
                        if($_32bit eq "big-endian") {
                                push @args, "uintptr($name>>32)", "uintptr($name)";
                        } elsif($_32bit eq "little-endian") {
@@ -220,7 +228,7 @@ while(<>) {
                        $asm = "RawSyscall";
                }
        }
-       if ($darwin) {
+       if ($libc) {
                # Call unexported syscall functions (which take
                # libc functions instead of syscall numbers).
                $asm = lcfirst($asm);
@@ -243,7 +251,7 @@ while(<>) {
                print STDERR "$ARGV:$.: too many arguments to system call\n";
        }
 
-       if ($darwin) {
+       if ($darwin || ($openbsd && $libc)) {
                # Use extended versions for calls that generate a 64-bit result.
                my ($name, $type) = parseparam($out[0]);
                if ($type eq "int64" || ($type eq "uintptr" && $_32bit eq "")) {
@@ -257,13 +265,13 @@ while(<>) {
                $sysname = "SYS_$func";
                $sysname =~ s/([a-z])([A-Z])/${1}_$2/g; # turn FooBar into Foo_Bar
                $sysname =~ y/a-z/A-Z/;
-               if($darwin) {
+               if($libc) {
                        $sysname =~ y/A-Z/a-z/;
                        $sysname = substr $sysname, 4;
                        $funcname = "libc_$sysname";
                }
        }
-       if($darwin) {
+       if($libc) {
                if($funcname eq "") {
                        $sysname = substr $sysname, 4;
                        $funcname = "libc_$sysname";
@@ -338,14 +346,18 @@ while(<>) {
        }
        $text .= "\treturn\n";
        $text .= "}\n\n";
-       if($darwin) {
+       if($libc) {
                if (not exists $trampolines{$funcname}) {
                        $trampolines{$funcname} = 1;
                        # The assembly trampoline that jumps to the libc routine.
                        $text .= "func ${funcname}_trampoline()\n";
                        # Tell the linker that funcname can be found in libSystem using varname without the libc_ prefix.
                        my $basename = substr $funcname, 5;
-                       $text .= "//go:cgo_import_dynamic $funcname $basename \"/usr/lib/libSystem.B.dylib\"\n\n";
+                       my $libc = "libc.so";
+                       if ($darwin) {
+                               $libc = "/usr/lib/libSystem.B.dylib";
+                       }
+                       $text .= "//go:cgo_import_dynamic $funcname $basename \"$libc\"\n\n";
                }
        }
 }
index eebb5ceb1a8609d1792e4e80593effd200b9448e..5a5ba5a51b07b7d7f908b74a2831c2ab57c338c7 100644 (file)
@@ -182,7 +182,6 @@ func setattrlistTimes(path string, times []Timespec) error {
 //sys  Rename(from string, to string) (err error)
 //sys  Revoke(path string) (err error)
 //sys  Rmdir(path string) (err error)
-//sys  Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
 //sys  Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
 //sysnb        Setegid(egid int) (err error)
 //sysnb        Seteuid(euid int) (err error)
@@ -207,8 +206,4 @@ func setattrlistTimes(path string, times []Timespec) error {
 //sys  write(fd int, p []byte) (n int, err error)
 //sys  mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
 //sys  munmap(addr uintptr, length uintptr) (err error)
-//sys  readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
-//sys  writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
 //sys  utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error)
-//sys  getcwd(buf []byte) (n int, err error) = SYS___GETCWD
-//sys  sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
diff --git a/src/syscall/syscall_openbsd1.go b/src/syscall/syscall_openbsd1.go
new file mode 100644 (file)
index 0000000..2c7d0f8
--- /dev/null
@@ -0,0 +1,13 @@
+// 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 openbsd,!amd64,!arm64
+
+package syscall
+
+//sys  readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
+//sys  writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
+//sys  Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
+//sys  getcwd(buf []byte) (n int, err error) = SYS___GETCWD
+//sys  sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
diff --git a/src/syscall/syscall_openbsd_libc.go b/src/syscall/syscall_openbsd_libc.go
new file mode 100644 (file)
index 0000000..042615b
--- /dev/null
@@ -0,0 +1,77 @@
+// 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 openbsd,amd64 openbsd,arm64
+
+package syscall
+
+import "unsafe"
+
+func init() {
+       execveOpenBSD = execve
+}
+
+//sys directSyscall(trap uintptr, a1 uintptr, a2 uintptr, a3 uintptr, a4 uintptr, a5 uintptr) (ret uintptr, err error) = SYS_syscall
+
+func syscallInternal(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
+       return syscall6X(funcPC(libc_syscall_trampoline), trap, a1, a2, a3, 0, 0)
+}
+
+func syscall6Internal(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
+       return syscall10X(funcPC(libc_syscall_trampoline), trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
+}
+
+func rawSyscallInternal(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
+       return rawSyscall6X(funcPC(libc_syscall_trampoline), trap, a1, a2, a3, 0, 0)
+}
+
+func rawSyscall6Internal(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
+       return rawSyscall10X(funcPC(libc_syscall_trampoline), trap, a1, a2, a3, a4, a5, a6, 0, 0, 0)
+}
+
+func syscall9Internal(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) {
+       return rawSyscall10X(funcPC(libc_syscall_trampoline), trap, a1, a2, a3, a4, a5, a6, a7, a8, a9)
+}
+
+// Implemented in the runtime package (runtime/sys_openbsd3.go)
+func syscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
+func syscallX(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
+func syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
+func syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
+func syscall10(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 uintptr) (r1, r2 uintptr, err Errno)
+func syscall10X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 uintptr) (r1, r2 uintptr, err Errno)
+func rawSyscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)
+func rawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
+func rawSyscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno)
+func rawSyscall10X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 uintptr) (r1, r2 uintptr, err Errno)
+
+func syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) {
+       return syscall10(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, 0)
+}
+func syscall9X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err Errno) {
+       return syscall10X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, 0)
+}
+
+// Find the entry point for f. See comments in runtime/proc.go for the
+// function of the same name.
+//go:nosplit
+func funcPC(f func()) uintptr {
+       return **(**uintptr)(unsafe.Pointer(&f))
+}
+
+//sys  readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_read
+//sys  writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_write
+//sys  Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_lseek
+//sys  getcwd(buf []byte) (n int, err error)
+//sys  sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error)
+//sysnb fork() (pid int, err error)
+//sysnb ioctl(fd int, req int, arg int) (err error)
+//sysnb execve(path *byte, argv **byte, envp **byte) (err error)
+//sysnb exit(res int) (err error)
+//sys   ptrace(request int, pid int, addr uintptr, data uintptr) (err error)
+//sysnb getentropy(p []byte) (err error)
+//sys   fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
+//sys  fcntlPtr(fd int, cmd int, arg unsafe.Pointer) (val int, err error) = SYS_fcntl
+//sys   unlinkat(fd int, path string, flags int) (err error)
+//sys   openat(fd int, path string, flags int, perm uint32) (fdret int, err error)
index d99656d0282da2584b7fa3b1dd1f5bd2f9b121a0..492f94785548754bc70c6db0c60ba87217f5a959 100644 (file)
@@ -1,4 +1,4 @@
-// go run mkasm_darwin.go amd64
+// go run mkasm.go darwin amd64
 // Code generated by the command above; DO NOT EDIT.
 #include "textflag.h"
 TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
index 0a8879d1c36990f1c603ab87032089cc3ca8e803..b606c6e49e35bba658ee8f19eb432debeb6fd820 100644 (file)
@@ -1,4 +1,4 @@
-// go run mkasm_darwin.go arm64
+// go run mkasm.go darwin arm64
 // Code generated by the command above; DO NOT EDIT.
 #include "textflag.h"
 TEXT ·libc_getfsstat_trampoline(SB),NOSPLIT,$0-0
index f7390390e094778f64b26e09a8a0f34d42d6a3a0..733050ad1d8279d11dc18d7e397ad15339f83ced 100644 (file)
@@ -1,4 +1,4 @@
-// mksyscall.pl -openbsd -tags openbsd,amd64 syscall_bsd.go syscall_openbsd.go syscall_openbsd_amd64.go
+// mksyscall.pl -openbsd -libc -tags openbsd,amd64 syscall_bsd.go syscall_openbsd.go syscall_openbsd_libc.go syscall_openbsd_amd64.go
 // Code generated by the command above; DO NOT EDIT.
 
 // +build openbsd,amd64
@@ -10,7 +10,7 @@ import "unsafe"
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
-       r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+       r0, _, e1 := rawSyscall(funcPC(libc_getgroups_trampoline), uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -18,20 +18,30 @@ func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
        return
 }
 
+func libc_getgroups_trampoline()
+
+//go:linkname libc_getgroups libc_getgroups
+//go:cgo_import_dynamic libc_getgroups getgroups "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func setgroups(ngid int, gid *_Gid_t) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setgroups_trampoline), uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setgroups_trampoline()
+
+//go:linkname libc_setgroups libc_setgroups
+//go:cgo_import_dynamic libc_setgroups setgroups "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
-       r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
+       r0, _, e1 := syscall6(funcPC(libc_wait4_trampoline), uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
        wpid = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -39,10 +49,15 @@ func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err
        return
 }
 
+func libc_wait4_trampoline()
+
+//go:linkname libc_wait4 libc_wait4
+//go:cgo_import_dynamic libc_wait4 wait4 "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
-       r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+       r0, _, e1 := syscall(funcPC(libc_accept_trampoline), uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
        fd = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -50,30 +65,45 @@ func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
        return
 }
 
+func libc_accept_trampoline()
+
+//go:linkname libc_accept libc_accept
+//go:cgo_import_dynamic libc_accept accept "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
-       _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
+       _, _, e1 := syscall(funcPC(libc_bind_trampoline), uintptr(s), uintptr(addr), uintptr(addrlen))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_bind_trampoline()
+
+//go:linkname libc_bind libc_bind
+//go:cgo_import_dynamic libc_bind bind "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
-       _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
+       _, _, e1 := syscall(funcPC(libc_connect_trampoline), uintptr(s), uintptr(addr), uintptr(addrlen))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_connect_trampoline()
+
+//go:linkname libc_connect libc_connect
+//go:cgo_import_dynamic libc_connect connect "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func socket(domain int, typ int, proto int) (fd int, err error) {
-       r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
+       r0, _, e1 := rawSyscall(funcPC(libc_socket_trampoline), uintptr(domain), uintptr(typ), uintptr(proto))
        fd = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -81,66 +111,101 @@ func socket(domain int, typ int, proto int) (fd int, err error) {
        return
 }
 
+func libc_socket_trampoline()
+
+//go:linkname libc_socket libc_socket
+//go:cgo_import_dynamic libc_socket socket "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
-       _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
+       _, _, e1 := syscall6(funcPC(libc_getsockopt_trampoline), uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_getsockopt_trampoline()
+
+//go:linkname libc_getsockopt libc_getsockopt
+//go:cgo_import_dynamic libc_getsockopt getsockopt "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
-       _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
+       _, _, e1 := syscall6(funcPC(libc_setsockopt_trampoline), uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setsockopt_trampoline()
+
+//go:linkname libc_setsockopt libc_setsockopt
+//go:cgo_import_dynamic libc_setsockopt setsockopt "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
-       _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+       _, _, e1 := rawSyscall(funcPC(libc_getpeername_trampoline), uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_getpeername_trampoline()
+
+//go:linkname libc_getpeername libc_getpeername
+//go:cgo_import_dynamic libc_getpeername getpeername "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
-       _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+       _, _, e1 := rawSyscall(funcPC(libc_getsockname_trampoline), uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_getsockname_trampoline()
+
+//go:linkname libc_getsockname libc_getsockname
+//go:cgo_import_dynamic libc_getsockname getsockname "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Shutdown(s int, how int) (err error) {
-       _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
+       _, _, e1 := syscall(funcPC(libc_shutdown_trampoline), uintptr(s), uintptr(how), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_shutdown_trampoline()
+
+//go:linkname libc_shutdown libc_shutdown
+//go:cgo_import_dynamic libc_shutdown shutdown "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
-       _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
+       _, _, e1 := rawSyscall6(funcPC(libc_socketpair_trampoline), uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_socketpair_trampoline()
+
+//go:linkname libc_socketpair libc_socketpair
+//go:cgo_import_dynamic libc_socketpair socketpair "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
@@ -150,7 +215,7 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
+       r0, _, e1 := syscall6(funcPC(libc_recvfrom_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -158,6 +223,11 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl
        return
 }
 
+func libc_recvfrom_trampoline()
+
+//go:linkname libc_recvfrom libc_recvfrom
+//go:cgo_import_dynamic libc_recvfrom recvfrom "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
@@ -167,17 +237,22 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
+       _, _, e1 := syscall6(funcPC(libc_sendto_trampoline), uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_sendto_trampoline()
+
+//go:linkname libc_sendto libc_sendto
+//go:cgo_import_dynamic libc_sendto sendto "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
-       r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+       r0, _, e1 := syscall(funcPC(libc_recvmsg_trampoline), uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -185,10 +260,15 @@ func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
        return
 }
 
+func libc_recvmsg_trampoline()
+
+//go:linkname libc_recvmsg libc_recvmsg
+//go:cgo_import_dynamic libc_recvmsg recvmsg "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
-       r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+       r0, _, e1 := syscall(funcPC(libc_sendmsg_trampoline), uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -196,10 +276,15 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
        return
 }
 
+func libc_sendmsg_trampoline()
+
+//go:linkname libc_sendmsg libc_sendmsg
+//go:cgo_import_dynamic libc_sendmsg sendmsg "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
-       r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
+       r0, _, e1 := syscall6(funcPC(libc_kevent_trampoline), uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -207,21 +292,10 @@ func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, ne
        return
 }
 
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_kevent_trampoline()
 
-func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
-       var _p0 unsafe.Pointer
-       if len(mib) > 0 {
-               _p0 = unsafe.Pointer(&mib[0])
-       } else {
-               _p0 = unsafe.Pointer(&_zero)
-       }
-       _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
-       if e1 != 0 {
-               err = errnoErr(e1)
-       }
-       return
-}
+//go:linkname libc_kevent libc_kevent
+//go:cgo_import_dynamic libc_kevent kevent "libc.so"
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
@@ -231,27 +305,37 @@ func utimes(path string, timeval *[2]Timeval) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
+       _, _, e1 := syscall(funcPC(libc_utimes_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_utimes_trampoline()
+
+//go:linkname libc_utimes libc_utimes
+//go:cgo_import_dynamic libc_utimes utimes "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func futimes(fd int, timeval *[2]Timeval) (err error) {
-       _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
+       _, _, e1 := syscall(funcPC(libc_futimes_trampoline), uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_futimes_trampoline()
+
+//go:linkname libc_futimes libc_futimes
+//go:cgo_import_dynamic libc_futimes futimes "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func fcntl(fd int, cmd int, arg int) (val int, err error) {
-       r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
+       r0, _, e1 := syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
        val = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -259,20 +343,30 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) {
        return
 }
 
+func libc_fcntl_trampoline()
+
+//go:linkname libc_fcntl libc_fcntl
+//go:cgo_import_dynamic libc_fcntl fcntl "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func pipe2(p *[2]_C_int, flags int) (err error) {
-       _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_pipe2_trampoline), uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_pipe2_trampoline()
+
+//go:linkname libc_pipe2 libc_pipe2
+//go:cgo_import_dynamic libc_pipe2 pipe2 "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) {
-       r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
+       r0, _, e1 := syscall6(funcPC(libc_accept4_trampoline), uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
        nfd = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -280,6 +374,11 @@ func accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int
        return
 }
 
+func libc_accept4_trampoline()
+
+//go:linkname libc_accept4 libc_accept4
+//go:cgo_import_dynamic libc_accept4 accept4 "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func getdents(fd int, buf []byte) (n int, err error) {
@@ -289,7 +388,7 @@ func getdents(fd int, buf []byte) (n int, err error) {
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
+       r0, _, e1 := syscall(funcPC(libc_getdents_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(buf)))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -297,6 +396,11 @@ func getdents(fd int, buf []byte) (n int, err error) {
        return
 }
 
+func libc_getdents_trampoline()
+
+//go:linkname libc_getdents libc_getdents
+//go:cgo_import_dynamic libc_getdents getdents "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Access(path string, mode uint32) (err error) {
@@ -305,23 +409,33 @@ func Access(path string, mode uint32) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+       _, _, e1 := syscall(funcPC(libc_access_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_access_trampoline()
+
+//go:linkname libc_access libc_access
+//go:cgo_import_dynamic libc_access access "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
-       _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
+       _, _, e1 := syscall(funcPC(libc_adjtime_trampoline), uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_adjtime_trampoline()
+
+//go:linkname libc_adjtime libc_adjtime
+//go:cgo_import_dynamic libc_adjtime adjtime "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Chdir(path string) (err error) {
@@ -330,13 +444,18 @@ func Chdir(path string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_chdir_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_chdir_trampoline()
+
+//go:linkname libc_chdir libc_chdir
+//go:cgo_import_dynamic libc_chdir chdir "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Chflags(path string, flags int) (err error) {
@@ -345,13 +464,18 @@ func Chflags(path string, flags int) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+       _, _, e1 := syscall(funcPC(libc_chflags_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_chflags_trampoline()
+
+//go:linkname libc_chflags libc_chflags
+//go:cgo_import_dynamic libc_chflags chflags "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Chmod(path string, mode uint32) (err error) {
@@ -360,13 +484,18 @@ func Chmod(path string, mode uint32) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+       _, _, e1 := syscall(funcPC(libc_chmod_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_chmod_trampoline()
+
+//go:linkname libc_chmod libc_chmod
+//go:cgo_import_dynamic libc_chmod chmod "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Chown(path string, uid int, gid int) (err error) {
@@ -375,13 +504,18 @@ func Chown(path string, uid int, gid int) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+       _, _, e1 := syscall(funcPC(libc_chown_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_chown_trampoline()
+
+//go:linkname libc_chown libc_chown
+//go:cgo_import_dynamic libc_chown chown "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Chroot(path string) (err error) {
@@ -390,27 +524,37 @@ func Chroot(path string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_chroot_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_chroot_trampoline()
+
+//go:linkname libc_chroot libc_chroot
+//go:cgo_import_dynamic libc_chroot chroot "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Close(fd int) (err error) {
-       _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_close_trampoline), uintptr(fd), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_close_trampoline()
+
+//go:linkname libc_close libc_close
+//go:cgo_import_dynamic libc_close close "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Dup(fd int) (nfd int, err error) {
-       r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
+       r0, _, e1 := syscall(funcPC(libc_dup_trampoline), uintptr(fd), 0, 0)
        nfd = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -418,70 +562,105 @@ func Dup(fd int) (nfd int, err error) {
        return
 }
 
+func libc_dup_trampoline()
+
+//go:linkname libc_dup libc_dup
+//go:cgo_import_dynamic libc_dup dup "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Dup2(from int, to int) (err error) {
-       _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
+       _, _, e1 := syscall(funcPC(libc_dup2_trampoline), uintptr(from), uintptr(to), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_dup2_trampoline()
+
+//go:linkname libc_dup2 libc_dup2
+//go:cgo_import_dynamic libc_dup2 dup2 "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fchdir(fd int) (err error) {
-       _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_fchdir_trampoline), uintptr(fd), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_fchdir_trampoline()
+
+//go:linkname libc_fchdir libc_fchdir
+//go:cgo_import_dynamic libc_fchdir fchdir "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fchflags(fd int, flags int) (err error) {
-       _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
+       _, _, e1 := syscall(funcPC(libc_fchflags_trampoline), uintptr(fd), uintptr(flags), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_fchflags_trampoline()
+
+//go:linkname libc_fchflags libc_fchflags
+//go:cgo_import_dynamic libc_fchflags fchflags "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fchmod(fd int, mode uint32) (err error) {
-       _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
+       _, _, e1 := syscall(funcPC(libc_fchmod_trampoline), uintptr(fd), uintptr(mode), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_fchmod_trampoline()
+
+//go:linkname libc_fchmod libc_fchmod
+//go:cgo_import_dynamic libc_fchmod fchmod "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fchown(fd int, uid int, gid int) (err error) {
-       _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
+       _, _, e1 := syscall(funcPC(libc_fchown_trampoline), uintptr(fd), uintptr(uid), uintptr(gid))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_fchown_trampoline()
+
+//go:linkname libc_fchown libc_fchown
+//go:cgo_import_dynamic libc_fchown fchown "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Flock(fd int, how int) (err error) {
-       _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
+       _, _, e1 := syscall(funcPC(libc_flock_trampoline), uintptr(fd), uintptr(how), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_flock_trampoline()
+
+//go:linkname libc_flock libc_flock
+//go:cgo_import_dynamic libc_flock flock "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fpathconf(fd int, name int) (val int, err error) {
-       r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
+       r0, _, e1 := syscall(funcPC(libc_fpathconf_trampoline), uintptr(fd), uintptr(name), 0)
        val = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -489,74 +668,114 @@ func Fpathconf(fd int, name int) (val int, err error) {
        return
 }
 
+func libc_fpathconf_trampoline()
+
+//go:linkname libc_fpathconf libc_fpathconf
+//go:cgo_import_dynamic libc_fpathconf fpathconf "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fstat(fd int, stat *Stat_t) (err error) {
-       _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+       _, _, e1 := syscall(funcPC(libc_fstat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_fstat_trampoline()
+
+//go:linkname libc_fstat libc_fstat
+//go:cgo_import_dynamic libc_fstat fstat "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fstatfs(fd int, stat *Statfs_t) (err error) {
-       _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+       _, _, e1 := syscall(funcPC(libc_fstatfs_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_fstatfs_trampoline()
+
+//go:linkname libc_fstatfs libc_fstatfs
+//go:cgo_import_dynamic libc_fstatfs fstatfs "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fsync(fd int) (err error) {
-       _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_fsync_trampoline), uintptr(fd), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_fsync_trampoline()
+
+//go:linkname libc_fsync libc_fsync
+//go:cgo_import_dynamic libc_fsync fsync "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Ftruncate(fd int, length int64) (err error) {
-       _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length))
+       _, _, e1 := syscall(funcPC(libc_ftruncate_trampoline), uintptr(fd), uintptr(length), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_ftruncate_trampoline()
+
+//go:linkname libc_ftruncate libc_ftruncate
+//go:cgo_import_dynamic libc_ftruncate ftruncate "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getegid() (egid int) {
-       r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
+       r0, _, _ := rawSyscall(funcPC(libc_getegid_trampoline), 0, 0, 0)
        egid = int(r0)
        return
 }
 
+func libc_getegid_trampoline()
+
+//go:linkname libc_getegid libc_getegid
+//go:cgo_import_dynamic libc_getegid getegid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Geteuid() (uid int) {
-       r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
+       r0, _, _ := rawSyscall(funcPC(libc_geteuid_trampoline), 0, 0, 0)
        uid = int(r0)
        return
 }
 
+func libc_geteuid_trampoline()
+
+//go:linkname libc_geteuid libc_geteuid
+//go:cgo_import_dynamic libc_geteuid geteuid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getgid() (gid int) {
-       r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
+       r0, _, _ := rawSyscall(funcPC(libc_getgid_trampoline), 0, 0, 0)
        gid = int(r0)
        return
 }
 
+func libc_getgid_trampoline()
+
+//go:linkname libc_getgid libc_getgid
+//go:cgo_import_dynamic libc_getgid getgid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getpgid(pid int) (pgid int, err error) {
-       r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
+       r0, _, e1 := rawSyscall(funcPC(libc_getpgid_trampoline), uintptr(pid), 0, 0)
        pgid = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -564,34 +783,54 @@ func Getpgid(pid int) (pgid int, err error) {
        return
 }
 
+func libc_getpgid_trampoline()
+
+//go:linkname libc_getpgid libc_getpgid
+//go:cgo_import_dynamic libc_getpgid getpgid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getpgrp() (pgrp int) {
-       r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
+       r0, _, _ := rawSyscall(funcPC(libc_getpgrp_trampoline), 0, 0, 0)
        pgrp = int(r0)
        return
 }
 
+func libc_getpgrp_trampoline()
+
+//go:linkname libc_getpgrp libc_getpgrp
+//go:cgo_import_dynamic libc_getpgrp getpgrp "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getpid() (pid int) {
-       r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
+       r0, _, _ := rawSyscall(funcPC(libc_getpid_trampoline), 0, 0, 0)
        pid = int(r0)
        return
 }
 
+func libc_getpid_trampoline()
+
+//go:linkname libc_getpid libc_getpid
+//go:cgo_import_dynamic libc_getpid getpid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getppid() (ppid int) {
-       r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
+       r0, _, _ := rawSyscall(funcPC(libc_getppid_trampoline), 0, 0, 0)
        ppid = int(r0)
        return
 }
 
+func libc_getppid_trampoline()
+
+//go:linkname libc_getppid libc_getppid
+//go:cgo_import_dynamic libc_getppid getppid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getpriority(which int, who int) (prio int, err error) {
-       r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
+       r0, _, e1 := syscall(funcPC(libc_getpriority_trampoline), uintptr(which), uintptr(who), 0)
        prio = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -599,30 +838,45 @@ func Getpriority(which int, who int) (prio int, err error) {
        return
 }
 
+func libc_getpriority_trampoline()
+
+//go:linkname libc_getpriority libc_getpriority
+//go:cgo_import_dynamic libc_getpriority getpriority "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getrlimit(which int, lim *Rlimit) (err error) {
-       _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_getrlimit_trampoline), uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_getrlimit_trampoline()
+
+//go:linkname libc_getrlimit libc_getrlimit
+//go:cgo_import_dynamic libc_getrlimit getrlimit "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getrusage(who int, rusage *Rusage) (err error) {
-       _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_getrusage_trampoline), uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_getrusage_trampoline()
+
+//go:linkname libc_getrusage libc_getrusage
+//go:cgo_import_dynamic libc_getrusage getrusage "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getsid(pid int) (sid int, err error) {
-       r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
+       r0, _, e1 := rawSyscall(funcPC(libc_getsid_trampoline), uintptr(pid), 0, 0)
        sid = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -630,46 +884,71 @@ func Getsid(pid int) (sid int, err error) {
        return
 }
 
+func libc_getsid_trampoline()
+
+//go:linkname libc_getsid libc_getsid
+//go:cgo_import_dynamic libc_getsid getsid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Gettimeofday(tv *Timeval) (err error) {
-       _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
+       _, _, e1 := rawSyscall(funcPC(libc_gettimeofday_trampoline), uintptr(unsafe.Pointer(tv)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_gettimeofday_trampoline()
+
+//go:linkname libc_gettimeofday libc_gettimeofday
+//go:cgo_import_dynamic libc_gettimeofday gettimeofday "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getuid() (uid int) {
-       r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
+       r0, _, _ := rawSyscall(funcPC(libc_getuid_trampoline), 0, 0, 0)
        uid = int(r0)
        return
 }
 
+func libc_getuid_trampoline()
+
+//go:linkname libc_getuid libc_getuid
+//go:cgo_import_dynamic libc_getuid getuid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Issetugid() (tainted bool) {
-       r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0)
+       r0, _, _ := syscall(funcPC(libc_issetugid_trampoline), 0, 0, 0)
        tainted = bool(r0 != 0)
        return
 }
 
+func libc_issetugid_trampoline()
+
+//go:linkname libc_issetugid libc_issetugid
+//go:cgo_import_dynamic libc_issetugid issetugid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Kill(pid int, signum Signal) (err error) {
-       _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0)
+       _, _, e1 := syscall(funcPC(libc_kill_trampoline), uintptr(pid), uintptr(signum), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_kill_trampoline()
+
+//go:linkname libc_kill libc_kill
+//go:cgo_import_dynamic libc_kill kill "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Kqueue() (fd int, err error) {
-       r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
+       r0, _, e1 := syscall(funcPC(libc_kqueue_trampoline), 0, 0, 0)
        fd = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -677,6 +956,11 @@ func Kqueue() (fd int, err error) {
        return
 }
 
+func libc_kqueue_trampoline()
+
+//go:linkname libc_kqueue libc_kqueue
+//go:cgo_import_dynamic libc_kqueue kqueue "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Lchown(path string, uid int, gid int) (err error) {
@@ -685,13 +969,18 @@ func Lchown(path string, uid int, gid int) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+       _, _, e1 := syscall(funcPC(libc_lchown_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_lchown_trampoline()
+
+//go:linkname libc_lchown libc_lchown
+//go:cgo_import_dynamic libc_lchown lchown "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Link(path string, link string) (err error) {
@@ -705,23 +994,33 @@ func Link(path string, link string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+       _, _, e1 := syscall(funcPC(libc_link_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_link_trampoline()
+
+//go:linkname libc_link libc_link
+//go:cgo_import_dynamic libc_link link "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Listen(s int, backlog int) (err error) {
-       _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
+       _, _, e1 := syscall(funcPC(libc_listen_trampoline), uintptr(s), uintptr(backlog), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_listen_trampoline()
+
+//go:linkname libc_listen libc_listen
+//go:cgo_import_dynamic libc_listen listen "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Lstat(path string, stat *Stat_t) (err error) {
@@ -730,13 +1029,18 @@ func Lstat(path string, stat *Stat_t) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+       _, _, e1 := syscall(funcPC(libc_lstat_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_lstat_trampoline()
+
+//go:linkname libc_lstat libc_lstat
+//go:cgo_import_dynamic libc_lstat lstat "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Mkdir(path string, mode uint32) (err error) {
@@ -745,13 +1049,18 @@ func Mkdir(path string, mode uint32) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+       _, _, e1 := syscall(funcPC(libc_mkdir_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_mkdir_trampoline()
+
+//go:linkname libc_mkdir libc_mkdir
+//go:cgo_import_dynamic libc_mkdir mkdir "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Mkfifo(path string, mode uint32) (err error) {
@@ -760,13 +1069,18 @@ func Mkfifo(path string, mode uint32) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+       _, _, e1 := syscall(funcPC(libc_mkfifo_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_mkfifo_trampoline()
+
+//go:linkname libc_mkfifo libc_mkfifo
+//go:cgo_import_dynamic libc_mkfifo mkfifo "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Mknod(path string, mode uint32, dev int) (err error) {
@@ -775,23 +1089,33 @@ func Mknod(path string, mode uint32, dev int) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
+       _, _, e1 := syscall(funcPC(libc_mknod_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_mknod_trampoline()
+
+//go:linkname libc_mknod libc_mknod
+//go:cgo_import_dynamic libc_mknod mknod "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
-       _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
+       _, _, e1 := syscall(funcPC(libc_nanosleep_trampoline), uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_nanosleep_trampoline()
+
+//go:linkname libc_nanosleep libc_nanosleep
+//go:cgo_import_dynamic libc_nanosleep nanosleep "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Open(path string, mode int, perm uint32) (fd int, err error) {
@@ -800,7 +1124,7 @@ func Open(path string, mode int, perm uint32) (fd int, err error) {
        if err != nil {
                return
        }
-       r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
+       r0, _, e1 := syscall(funcPC(libc_open_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
        fd = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -808,6 +1132,11 @@ func Open(path string, mode int, perm uint32) (fd int, err error) {
        return
 }
 
+func libc_open_trampoline()
+
+//go:linkname libc_open libc_open
+//go:cgo_import_dynamic libc_open open "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Pathconf(path string, name int) (val int, err error) {
@@ -816,7 +1145,7 @@ func Pathconf(path string, name int) (val int, err error) {
        if err != nil {
                return
        }
-       r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
+       r0, _, e1 := syscall(funcPC(libc_pathconf_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
        val = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -824,6 +1153,11 @@ func Pathconf(path string, name int) (val int, err error) {
        return
 }
 
+func libc_pathconf_trampoline()
+
+//go:linkname libc_pathconf libc_pathconf
+//go:cgo_import_dynamic libc_pathconf pathconf "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Pread(fd int, p []byte, offset int64) (n int, err error) {
@@ -833,7 +1167,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) {
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), 0)
+       r0, _, e1 := syscall6(funcPC(libc_pread_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -841,6 +1175,11 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) {
        return
 }
 
+func libc_pread_trampoline()
+
+//go:linkname libc_pread libc_pread
+//go:cgo_import_dynamic libc_pread pread "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
@@ -850,7 +1189,7 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), 0)
+       r0, _, e1 := syscall6(funcPC(libc_pwrite_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -858,6 +1197,11 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
        return
 }
 
+func libc_pwrite_trampoline()
+
+//go:linkname libc_pwrite libc_pwrite
+//go:cgo_import_dynamic libc_pwrite pwrite "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func read(fd int, p []byte) (n int, err error) {
@@ -867,7 +1211,7 @@ func read(fd int, p []byte) (n int, err error) {
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+       r0, _, e1 := syscall(funcPC(libc_read_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -875,6 +1219,11 @@ func read(fd int, p []byte) (n int, err error) {
        return
 }
 
+func libc_read_trampoline()
+
+//go:linkname libc_read libc_read
+//go:cgo_import_dynamic libc_read read "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Readlink(path string, buf []byte) (n int, err error) {
@@ -889,7 +1238,7 @@ func Readlink(path string, buf []byte) (n int, err error) {
        } else {
                _p1 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
+       r0, _, e1 := syscall(funcPC(libc_readlink_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -897,6 +1246,11 @@ func Readlink(path string, buf []byte) (n int, err error) {
        return
 }
 
+func libc_readlink_trampoline()
+
+//go:linkname libc_readlink libc_readlink
+//go:cgo_import_dynamic libc_readlink readlink "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Rename(from string, to string) (err error) {
@@ -910,13 +1264,18 @@ func Rename(from string, to string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+       _, _, e1 := syscall(funcPC(libc_rename_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_rename_trampoline()
+
+//go:linkname libc_rename libc_rename
+//go:cgo_import_dynamic libc_rename rename "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Revoke(path string) (err error) {
@@ -925,13 +1284,18 @@ func Revoke(path string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_revoke_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_revoke_trampoline()
+
+//go:linkname libc_revoke libc_revoke
+//go:cgo_import_dynamic libc_revoke revoke "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Rmdir(path string) (err error) {
@@ -940,64 +1304,78 @@ func Rmdir(path string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_rmdir_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_rmdir_trampoline()
 
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
-       r0, _, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(whence), 0, 0)
-       newoffset = int64(r0)
-       if e1 != 0 {
-               err = errnoErr(e1)
-       }
-       return
-}
+//go:linkname libc_rmdir libc_rmdir
+//go:cgo_import_dynamic libc_rmdir rmdir "libc.so"
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
-       _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
+       _, _, e1 := syscall6(funcPC(libc_select_trampoline), uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_select_trampoline()
+
+//go:linkname libc_select libc_select
+//go:cgo_import_dynamic libc_select select "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setegid(egid int) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setegid_trampoline), uintptr(egid), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setegid_trampoline()
+
+//go:linkname libc_setegid libc_setegid
+//go:cgo_import_dynamic libc_setegid setegid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Seteuid(euid int) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
+       _, _, e1 := rawSyscall(funcPC(libc_seteuid_trampoline), uintptr(euid), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_seteuid_trampoline()
+
+//go:linkname libc_seteuid libc_seteuid
+//go:cgo_import_dynamic libc_seteuid seteuid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setgid(gid int) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setgid_trampoline), uintptr(gid), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setgid_trampoline()
+
+//go:linkname libc_setgid libc_setgid
+//go:cgo_import_dynamic libc_setgid setgid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setlogin(name string) (err error) {
@@ -1006,67 +1384,97 @@ func Setlogin(name string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_setlogin_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setlogin_trampoline()
+
+//go:linkname libc_setlogin libc_setlogin
+//go:cgo_import_dynamic libc_setlogin setlogin "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setpgid(pid int, pgid int) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setpgid_trampoline), uintptr(pid), uintptr(pgid), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setpgid_trampoline()
+
+//go:linkname libc_setpgid libc_setpgid
+//go:cgo_import_dynamic libc_setpgid setpgid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setpriority(which int, who int, prio int) (err error) {
-       _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
+       _, _, e1 := syscall(funcPC(libc_setpriority_trampoline), uintptr(which), uintptr(who), uintptr(prio))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setpriority_trampoline()
+
+//go:linkname libc_setpriority libc_setpriority
+//go:cgo_import_dynamic libc_setpriority setpriority "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setregid(rgid int, egid int) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setregid_trampoline), uintptr(rgid), uintptr(egid), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setregid_trampoline()
+
+//go:linkname libc_setregid libc_setregid
+//go:cgo_import_dynamic libc_setregid setregid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setreuid(ruid int, euid int) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setreuid_trampoline), uintptr(ruid), uintptr(euid), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setreuid_trampoline()
+
+//go:linkname libc_setreuid libc_setreuid
+//go:cgo_import_dynamic libc_setreuid setreuid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setrlimit(which int, lim *Rlimit) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setrlimit_trampoline), uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setrlimit_trampoline()
+
+//go:linkname libc_setrlimit libc_setrlimit
+//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setsid() (pid int, err error) {
-       r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
+       r0, _, e1 := rawSyscall(funcPC(libc_setsid_trampoline), 0, 0, 0)
        pid = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -1074,26 +1482,41 @@ func Setsid() (pid int, err error) {
        return
 }
 
+func libc_setsid_trampoline()
+
+//go:linkname libc_setsid libc_setsid
+//go:cgo_import_dynamic libc_setsid setsid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Settimeofday(tp *Timeval) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+       _, _, e1 := rawSyscall(funcPC(libc_settimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_settimeofday_trampoline()
+
+//go:linkname libc_settimeofday libc_settimeofday
+//go:cgo_import_dynamic libc_settimeofday settimeofday "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setuid(uid int) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setuid_trampoline), uintptr(uid), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setuid_trampoline()
+
+//go:linkname libc_setuid libc_setuid
+//go:cgo_import_dynamic libc_setuid setuid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Stat(path string, stat *Stat_t) (err error) {
@@ -1102,13 +1525,18 @@ func Stat(path string, stat *Stat_t) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+       _, _, e1 := syscall(funcPC(libc_stat_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_stat_trampoline()
+
+//go:linkname libc_stat libc_stat
+//go:cgo_import_dynamic libc_stat stat "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Statfs(path string, stat *Statfs_t) (err error) {
@@ -1117,13 +1545,18 @@ func Statfs(path string, stat *Statfs_t) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+       _, _, e1 := syscall(funcPC(libc_statfs_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_statfs_trampoline()
+
+//go:linkname libc_statfs libc_statfs
+//go:cgo_import_dynamic libc_statfs statfs "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Symlink(path string, link string) (err error) {
@@ -1137,23 +1570,33 @@ func Symlink(path string, link string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+       _, _, e1 := syscall(funcPC(libc_symlink_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_symlink_trampoline()
+
+//go:linkname libc_symlink libc_symlink
+//go:cgo_import_dynamic libc_symlink symlink "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Sync() (err error) {
-       _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
+       _, _, e1 := syscall(funcPC(libc_sync_trampoline), 0, 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_sync_trampoline()
+
+//go:linkname libc_sync libc_sync
+//go:cgo_import_dynamic libc_sync sync "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Truncate(path string, length int64) (err error) {
@@ -1162,21 +1605,31 @@ func Truncate(path string, length int64) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length))
+       _, _, e1 := syscall(funcPC(libc_truncate_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_truncate_trampoline()
+
+//go:linkname libc_truncate libc_truncate
+//go:cgo_import_dynamic libc_truncate truncate "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Umask(newmask int) (oldmask int) {
-       r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
+       r0, _, _ := syscall(funcPC(libc_umask_trampoline), uintptr(newmask), 0, 0)
        oldmask = int(r0)
        return
 }
 
+func libc_umask_trampoline()
+
+//go:linkname libc_umask libc_umask
+//go:cgo_import_dynamic libc_umask umask "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Unlink(path string) (err error) {
@@ -1185,13 +1638,18 @@ func Unlink(path string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_unlink_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_unlink_trampoline()
+
+//go:linkname libc_unlink libc_unlink
+//go:cgo_import_dynamic libc_unlink unlink "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Unmount(path string, flags int) (err error) {
@@ -1200,13 +1658,18 @@ func Unmount(path string, flags int) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+       _, _, e1 := syscall(funcPC(libc_unmount_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_unmount_trampoline()
+
+//go:linkname libc_unmount libc_unmount
+//go:cgo_import_dynamic libc_unmount unmount "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func write(fd int, p []byte) (n int, err error) {
@@ -1216,7 +1679,7 @@ func write(fd int, p []byte) (n int, err error) {
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+       r0, _, e1 := syscall(funcPC(libc_write_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -1224,10 +1687,15 @@ func write(fd int, p []byte) (n int, err error) {
        return
 }
 
+func libc_write_trampoline()
+
+//go:linkname libc_write libc_write
+//go:cgo_import_dynamic libc_write write "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
-       r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), 0, 0)
+       r0, _, e1 := syscall6X(funcPC(libc_mmap_trampoline), uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos))
        ret = uintptr(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -1235,20 +1703,66 @@ func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (
        return
 }
 
+func libc_mmap_trampoline()
+
+//go:linkname libc_mmap libc_mmap
+//go:cgo_import_dynamic libc_mmap mmap "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func munmap(addr uintptr, length uintptr) (err error) {
-       _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
+       _, _, e1 := syscall(funcPC(libc_munmap_trampoline), uintptr(addr), uintptr(length), 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_munmap_trampoline()
+
+//go:linkname libc_munmap libc_munmap
+//go:cgo_import_dynamic libc_munmap munmap "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error) {
+       var _p0 *byte
+       _p0, err = BytePtrFromString(path)
+       if err != nil {
+               return
+       }
+       _, _, e1 := syscall6(funcPC(libc_utimensat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flag), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_utimensat_trampoline()
+
+//go:linkname libc_utimensat libc_utimensat
+//go:cgo_import_dynamic libc_utimensat utimensat "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func directSyscall(trap uintptr, a1 uintptr, a2 uintptr, a3 uintptr, a4 uintptr, a5 uintptr) (ret uintptr, err error) {
+       r0, _, e1 := syscall6X(funcPC(libc_syscall_trampoline), uintptr(trap), uintptr(a1), uintptr(a2), uintptr(a3), uintptr(a4), uintptr(a5))
+       ret = uintptr(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_syscall_trampoline()
+
+//go:linkname libc_syscall libc_syscall
+//go:cgo_import_dynamic libc_syscall syscall "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
-       r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+       r0, _, e1 := syscall(funcPC(libc_read_trampoline), uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -1259,7 +1773,7 @@ func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
-       r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+       r0, _, e1 := syscall(funcPC(libc_write_trampoline), uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -1269,19 +1783,20 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
-func utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error) {
-       var _p0 *byte
-       _p0, err = BytePtrFromString(path)
-       if err != nil {
-               return
-       }
-       _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flag), 0, 0)
+func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
+       r0, _, e1 := syscallX(funcPC(libc_lseek_trampoline), uintptr(fd), uintptr(offset), uintptr(whence))
+       newoffset = int64(r0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_lseek_trampoline()
+
+//go:linkname libc_lseek libc_lseek
+//go:cgo_import_dynamic libc_lseek lseek "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func getcwd(buf []byte) (n int, err error) {
@@ -1291,10 +1806,206 @@ func getcwd(buf []byte) (n int, err error) {
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall(SYS___GETCWD, uintptr(_p0), uintptr(len(buf)), 0)
+       r0, _, e1 := syscall(funcPC(libc_getcwd_trampoline), uintptr(_p0), uintptr(len(buf)), 0)
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
+
+func libc_getcwd_trampoline()
+
+//go:linkname libc_getcwd libc_getcwd
+//go:cgo_import_dynamic libc_getcwd getcwd "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
+       var _p0 unsafe.Pointer
+       if len(mib) > 0 {
+               _p0 = unsafe.Pointer(&mib[0])
+       } else {
+               _p0 = unsafe.Pointer(&_zero)
+       }
+       _, _, e1 := syscall6(funcPC(libc_sysctl_trampoline), uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_sysctl_trampoline()
+
+//go:linkname libc_sysctl libc_sysctl
+//go:cgo_import_dynamic libc_sysctl sysctl "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fork() (pid int, err error) {
+       r0, _, e1 := rawSyscall(funcPC(libc_fork_trampoline), 0, 0, 0)
+       pid = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_fork_trampoline()
+
+//go:linkname libc_fork libc_fork
+//go:cgo_import_dynamic libc_fork fork "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func ioctl(fd int, req int, arg int) (err error) {
+       _, _, e1 := rawSyscall(funcPC(libc_ioctl_trampoline), uintptr(fd), uintptr(req), uintptr(arg))
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_ioctl_trampoline()
+
+//go:linkname libc_ioctl libc_ioctl
+//go:cgo_import_dynamic libc_ioctl ioctl "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func execve(path *byte, argv **byte, envp **byte) (err error) {
+       _, _, e1 := rawSyscall(funcPC(libc_execve_trampoline), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(argv)), uintptr(unsafe.Pointer(envp)))
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_execve_trampoline()
+
+//go:linkname libc_execve libc_execve
+//go:cgo_import_dynamic libc_execve execve "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func exit(res int) (err error) {
+       _, _, e1 := rawSyscall(funcPC(libc_exit_trampoline), uintptr(res), 0, 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_exit_trampoline()
+
+//go:linkname libc_exit libc_exit
+//go:cgo_import_dynamic libc_exit exit "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+//go:nosplit
+func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
+       _, _, e1 := syscall6(funcPC(libc_ptrace_trampoline), uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_ptrace_trampoline()
+
+//go:linkname libc_ptrace libc_ptrace
+//go:cgo_import_dynamic libc_ptrace ptrace "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getentropy(p []byte) (err error) {
+       var _p0 unsafe.Pointer
+       if len(p) > 0 {
+               _p0 = unsafe.Pointer(&p[0])
+       } else {
+               _p0 = unsafe.Pointer(&_zero)
+       }
+       _, _, e1 := rawSyscall(funcPC(libc_getentropy_trampoline), uintptr(_p0), uintptr(len(p)), 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_getentropy_trampoline()
+
+//go:linkname libc_getentropy libc_getentropy
+//go:cgo_import_dynamic libc_getentropy getentropy "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
+       var _p0 *byte
+       _p0, err = BytePtrFromString(path)
+       if err != nil {
+               return
+       }
+       _, _, e1 := syscall6(funcPC(libc_fstatat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_fstatat_trampoline()
+
+//go:linkname libc_fstatat libc_fstatat
+//go:cgo_import_dynamic libc_fstatat fstatat "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fcntlPtr(fd int, cmd int, arg unsafe.Pointer) (val int, err error) {
+       r0, _, e1 := syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
+       val = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func unlinkat(fd int, path string, flags int) (err error) {
+       var _p0 *byte
+       _p0, err = BytePtrFromString(path)
+       if err != nil {
+               return
+       }
+       _, _, e1 := syscall(funcPC(libc_unlinkat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_unlinkat_trampoline()
+
+//go:linkname libc_unlinkat libc_unlinkat
+//go:cgo_import_dynamic libc_unlinkat unlinkat "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func openat(fd int, path string, flags int, perm uint32) (fdret int, err error) {
+       var _p0 *byte
+       _p0, err = BytePtrFromString(path)
+       if err != nil {
+               return
+       }
+       r0, _, e1 := syscall6(funcPC(libc_openat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(perm), 0, 0)
+       fdret = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_openat_trampoline()
+
+//go:linkname libc_openat libc_openat
+//go:cgo_import_dynamic libc_openat openat "libc.so"
diff --git a/src/syscall/zsyscall_openbsd_amd64.s b/src/syscall/zsyscall_openbsd_amd64.s
new file mode 100644 (file)
index 0000000..e5c5dde
--- /dev/null
@@ -0,0 +1,233 @@
+// go run mkasm.go openbsd amd64
+// Code generated by the command above; DO NOT EDIT.
+#include "textflag.h"
+TEXT ·libc_getgroups_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getgroups(SB)
+TEXT ·libc_setgroups_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setgroups(SB)
+TEXT ·libc_wait4_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_wait4(SB)
+TEXT ·libc_accept_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_accept(SB)
+TEXT ·libc_bind_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_bind(SB)
+TEXT ·libc_connect_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_connect(SB)
+TEXT ·libc_socket_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_socket(SB)
+TEXT ·libc_getsockopt_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getsockopt(SB)
+TEXT ·libc_setsockopt_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setsockopt(SB)
+TEXT ·libc_getpeername_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getpeername(SB)
+TEXT ·libc_getsockname_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getsockname(SB)
+TEXT ·libc_shutdown_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_shutdown(SB)
+TEXT ·libc_socketpair_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_socketpair(SB)
+TEXT ·libc_recvfrom_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_recvfrom(SB)
+TEXT ·libc_sendto_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_sendto(SB)
+TEXT ·libc_recvmsg_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_recvmsg(SB)
+TEXT ·libc_sendmsg_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_sendmsg(SB)
+TEXT ·libc_kevent_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_kevent(SB)
+TEXT ·libc_utimes_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_utimes(SB)
+TEXT ·libc_futimes_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_futimes(SB)
+TEXT ·libc_fcntl_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fcntl(SB)
+TEXT ·libc_pipe2_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_pipe2(SB)
+TEXT ·libc_accept4_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_accept4(SB)
+TEXT ·libc_getdents_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getdents(SB)
+TEXT ·libc_access_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_access(SB)
+TEXT ·libc_adjtime_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_adjtime(SB)
+TEXT ·libc_chdir_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_chdir(SB)
+TEXT ·libc_chflags_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_chflags(SB)
+TEXT ·libc_chmod_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_chmod(SB)
+TEXT ·libc_chown_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_chown(SB)
+TEXT ·libc_chroot_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_chroot(SB)
+TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_close(SB)
+TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_dup(SB)
+TEXT ·libc_dup2_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_dup2(SB)
+TEXT ·libc_fchdir_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fchdir(SB)
+TEXT ·libc_fchflags_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fchflags(SB)
+TEXT ·libc_fchmod_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fchmod(SB)
+TEXT ·libc_fchown_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fchown(SB)
+TEXT ·libc_flock_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_flock(SB)
+TEXT ·libc_fpathconf_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fpathconf(SB)
+TEXT ·libc_fstat_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fstat(SB)
+TEXT ·libc_fstatfs_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fstatfs(SB)
+TEXT ·libc_fsync_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fsync(SB)
+TEXT ·libc_ftruncate_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_ftruncate(SB)
+TEXT ·libc_getegid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getegid(SB)
+TEXT ·libc_geteuid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_geteuid(SB)
+TEXT ·libc_getgid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getgid(SB)
+TEXT ·libc_getpgid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getpgid(SB)
+TEXT ·libc_getpgrp_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getpgrp(SB)
+TEXT ·libc_getpid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getpid(SB)
+TEXT ·libc_getppid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getppid(SB)
+TEXT ·libc_getpriority_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getpriority(SB)
+TEXT ·libc_getrlimit_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getrlimit(SB)
+TEXT ·libc_getrusage_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getrusage(SB)
+TEXT ·libc_getsid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getsid(SB)
+TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_gettimeofday(SB)
+TEXT ·libc_getuid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getuid(SB)
+TEXT ·libc_issetugid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_issetugid(SB)
+TEXT ·libc_kill_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_kill(SB)
+TEXT ·libc_kqueue_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_kqueue(SB)
+TEXT ·libc_lchown_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_lchown(SB)
+TEXT ·libc_link_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_link(SB)
+TEXT ·libc_listen_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_listen(SB)
+TEXT ·libc_lstat_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_lstat(SB)
+TEXT ·libc_mkdir_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_mkdir(SB)
+TEXT ·libc_mkfifo_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_mkfifo(SB)
+TEXT ·libc_mknod_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_mknod(SB)
+TEXT ·libc_nanosleep_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_nanosleep(SB)
+TEXT ·libc_open_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_open(SB)
+TEXT ·libc_pathconf_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_pathconf(SB)
+TEXT ·libc_pread_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_pread(SB)
+TEXT ·libc_pwrite_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_pwrite(SB)
+TEXT ·libc_read_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_read(SB)
+TEXT ·libc_readlink_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_readlink(SB)
+TEXT ·libc_rename_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_rename(SB)
+TEXT ·libc_revoke_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_revoke(SB)
+TEXT ·libc_rmdir_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_rmdir(SB)
+TEXT ·libc_select_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_select(SB)
+TEXT ·libc_setegid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setegid(SB)
+TEXT ·libc_seteuid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_seteuid(SB)
+TEXT ·libc_setgid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setgid(SB)
+TEXT ·libc_setlogin_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setlogin(SB)
+TEXT ·libc_setpgid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setpgid(SB)
+TEXT ·libc_setpriority_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setpriority(SB)
+TEXT ·libc_setregid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setregid(SB)
+TEXT ·libc_setreuid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setreuid(SB)
+TEXT ·libc_setrlimit_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setrlimit(SB)
+TEXT ·libc_setsid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setsid(SB)
+TEXT ·libc_settimeofday_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_settimeofday(SB)
+TEXT ·libc_setuid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setuid(SB)
+TEXT ·libc_stat_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_stat(SB)
+TEXT ·libc_statfs_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_statfs(SB)
+TEXT ·libc_symlink_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_symlink(SB)
+TEXT ·libc_sync_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_sync(SB)
+TEXT ·libc_truncate_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_truncate(SB)
+TEXT ·libc_umask_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_umask(SB)
+TEXT ·libc_unlink_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_unlink(SB)
+TEXT ·libc_unmount_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_unmount(SB)
+TEXT ·libc_write_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_write(SB)
+TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_mmap(SB)
+TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_munmap(SB)
+TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_utimensat(SB)
+TEXT ·libc_syscall_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_syscall(SB)
+TEXT ·libc_lseek_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_lseek(SB)
+TEXT ·libc_getcwd_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getcwd(SB)
+TEXT ·libc_sysctl_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_sysctl(SB)
+TEXT ·libc_fork_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fork(SB)
+TEXT ·libc_ioctl_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_ioctl(SB)
+TEXT ·libc_execve_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_execve(SB)
+TEXT ·libc_exit_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_exit(SB)
+TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_ptrace(SB)
+TEXT ·libc_getentropy_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getentropy(SB)
+TEXT ·libc_fstatat_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fstatat(SB)
+TEXT ·libc_unlinkat_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_unlinkat(SB)
+TEXT ·libc_openat_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_openat(SB)
index 626ce177033ebcf13acdd3ff9bc16863e653ef4f..2093eb74e57f9699595f944181759f04fcb77e11 100644 (file)
@@ -1,4 +1,4 @@
-// mksyscall.pl -openbsd -tags openbsd,arm64 syscall_bsd.go syscall_openbsd.go syscall_openbsd_arm64.go
+// mksyscall.pl -openbsd -libc -tags openbsd,arm64 syscall_bsd.go syscall_openbsd.go syscall_openbsd_libc.go syscall_openbsd_arm64.go
 // Code generated by the command above; DO NOT EDIT.
 
 // +build openbsd,arm64
@@ -10,7 +10,7 @@ import "unsafe"
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
-       r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+       r0, _, e1 := rawSyscall(funcPC(libc_getgroups_trampoline), uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -18,20 +18,30 @@ func getgroups(ngid int, gid *_Gid_t) (n int, err error) {
        return
 }
 
+func libc_getgroups_trampoline()
+
+//go:linkname libc_getgroups libc_getgroups
+//go:cgo_import_dynamic libc_getgroups getgroups "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func setgroups(ngid int, gid *_Gid_t) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setgroups_trampoline), uintptr(ngid), uintptr(unsafe.Pointer(gid)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setgroups_trampoline()
+
+//go:linkname libc_setgroups libc_setgroups
+//go:cgo_import_dynamic libc_setgroups setgroups "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) {
-       r0, _, e1 := Syscall6(SYS_WAIT4, uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
+       r0, _, e1 := syscall6(funcPC(libc_wait4_trampoline), uintptr(pid), uintptr(unsafe.Pointer(wstatus)), uintptr(options), uintptr(unsafe.Pointer(rusage)), 0, 0)
        wpid = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -39,10 +49,15 @@ func wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err
        return
 }
 
+func libc_wait4_trampoline()
+
+//go:linkname libc_wait4 libc_wait4
+//go:cgo_import_dynamic libc_wait4 wait4 "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
-       r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+       r0, _, e1 := syscall(funcPC(libc_accept_trampoline), uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
        fd = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -50,30 +65,45 @@ func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
        return
 }
 
+func libc_accept_trampoline()
+
+//go:linkname libc_accept libc_accept
+//go:cgo_import_dynamic libc_accept accept "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
-       _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
+       _, _, e1 := syscall(funcPC(libc_bind_trampoline), uintptr(s), uintptr(addr), uintptr(addrlen))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_bind_trampoline()
+
+//go:linkname libc_bind libc_bind
+//go:cgo_import_dynamic libc_bind bind "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
-       _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
+       _, _, e1 := syscall(funcPC(libc_connect_trampoline), uintptr(s), uintptr(addr), uintptr(addrlen))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_connect_trampoline()
+
+//go:linkname libc_connect libc_connect
+//go:cgo_import_dynamic libc_connect connect "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func socket(domain int, typ int, proto int) (fd int, err error) {
-       r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
+       r0, _, e1 := rawSyscall(funcPC(libc_socket_trampoline), uintptr(domain), uintptr(typ), uintptr(proto))
        fd = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -81,66 +111,101 @@ func socket(domain int, typ int, proto int) (fd int, err error) {
        return
 }
 
+func libc_socket_trampoline()
+
+//go:linkname libc_socket libc_socket
+//go:cgo_import_dynamic libc_socket socket "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
-       _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
+       _, _, e1 := syscall6(funcPC(libc_getsockopt_trampoline), uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_getsockopt_trampoline()
+
+//go:linkname libc_getsockopt libc_getsockopt
+//go:cgo_import_dynamic libc_getsockopt getsockopt "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
-       _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
+       _, _, e1 := syscall6(funcPC(libc_setsockopt_trampoline), uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setsockopt_trampoline()
+
+//go:linkname libc_setsockopt libc_setsockopt
+//go:cgo_import_dynamic libc_setsockopt setsockopt "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
-       _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+       _, _, e1 := rawSyscall(funcPC(libc_getpeername_trampoline), uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_getpeername_trampoline()
+
+//go:linkname libc_getpeername libc_getpeername
+//go:cgo_import_dynamic libc_getpeername getpeername "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
-       _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
+       _, _, e1 := rawSyscall(funcPC(libc_getsockname_trampoline), uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_getsockname_trampoline()
+
+//go:linkname libc_getsockname libc_getsockname
+//go:cgo_import_dynamic libc_getsockname getsockname "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Shutdown(s int, how int) (err error) {
-       _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(s), uintptr(how), 0)
+       _, _, e1 := syscall(funcPC(libc_shutdown_trampoline), uintptr(s), uintptr(how), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_shutdown_trampoline()
+
+//go:linkname libc_shutdown libc_shutdown
+//go:cgo_import_dynamic libc_shutdown shutdown "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
-       _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
+       _, _, e1 := rawSyscall6(funcPC(libc_socketpair_trampoline), uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_socketpair_trampoline()
+
+//go:linkname libc_socketpair libc_socketpair
+//go:cgo_import_dynamic libc_socketpair socketpair "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
@@ -150,7 +215,7 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
+       r0, _, e1 := syscall6(funcPC(libc_recvfrom_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -158,6 +223,11 @@ func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Sockl
        return
 }
 
+func libc_recvfrom_trampoline()
+
+//go:linkname libc_recvfrom libc_recvfrom
+//go:cgo_import_dynamic libc_recvfrom recvfrom "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
@@ -167,17 +237,22 @@ func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
+       _, _, e1 := syscall6(funcPC(libc_sendto_trampoline), uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_sendto_trampoline()
+
+//go:linkname libc_sendto libc_sendto
+//go:cgo_import_dynamic libc_sendto sendto "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
-       r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+       r0, _, e1 := syscall(funcPC(libc_recvmsg_trampoline), uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -185,10 +260,15 @@ func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
        return
 }
 
+func libc_recvmsg_trampoline()
+
+//go:linkname libc_recvmsg libc_recvmsg
+//go:cgo_import_dynamic libc_recvmsg recvmsg "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
-       r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
+       r0, _, e1 := syscall(funcPC(libc_sendmsg_trampoline), uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -196,10 +276,15 @@ func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
        return
 }
 
+func libc_sendmsg_trampoline()
+
+//go:linkname libc_sendmsg libc_sendmsg
+//go:cgo_import_dynamic libc_sendmsg sendmsg "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) {
-       r0, _, e1 := Syscall6(SYS_KEVENT, uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
+       r0, _, e1 := syscall6(funcPC(libc_kevent_trampoline), uintptr(kq), uintptr(change), uintptr(nchange), uintptr(event), uintptr(nevent), uintptr(unsafe.Pointer(timeout)))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -207,6 +292,11 @@ func kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, ne
        return
 }
 
+func libc_kevent_trampoline()
+
+//go:linkname libc_kevent libc_kevent
+//go:cgo_import_dynamic libc_kevent kevent "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func utimes(path string, timeval *[2]Timeval) (err error) {
@@ -215,27 +305,37 @@ func utimes(path string, timeval *[2]Timeval) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
+       _, _, e1 := syscall(funcPC(libc_utimes_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(timeval)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_utimes_trampoline()
+
+//go:linkname libc_utimes libc_utimes
+//go:cgo_import_dynamic libc_utimes utimes "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func futimes(fd int, timeval *[2]Timeval) (err error) {
-       _, _, e1 := Syscall(SYS_FUTIMES, uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
+       _, _, e1 := syscall(funcPC(libc_futimes_trampoline), uintptr(fd), uintptr(unsafe.Pointer(timeval)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_futimes_trampoline()
+
+//go:linkname libc_futimes libc_futimes
+//go:cgo_import_dynamic libc_futimes futimes "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func fcntl(fd int, cmd int, arg int) (val int, err error) {
-       r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
+       r0, _, e1 := syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
        val = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -243,20 +343,30 @@ func fcntl(fd int, cmd int, arg int) (val int, err error) {
        return
 }
 
+func libc_fcntl_trampoline()
+
+//go:linkname libc_fcntl libc_fcntl
+//go:cgo_import_dynamic libc_fcntl fcntl "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func pipe2(p *[2]_C_int, flags int) (err error) {
-       _, _, e1 := RawSyscall(SYS_PIPE2, uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_pipe2_trampoline), uintptr(unsafe.Pointer(p)), uintptr(flags), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_pipe2_trampoline()
+
+//go:linkname libc_pipe2 libc_pipe2
+//go:cgo_import_dynamic libc_pipe2 pipe2 "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) {
-       r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
+       r0, _, e1 := syscall6(funcPC(libc_accept4_trampoline), uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
        nfd = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -264,6 +374,11 @@ func accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int
        return
 }
 
+func libc_accept4_trampoline()
+
+//go:linkname libc_accept4 libc_accept4
+//go:cgo_import_dynamic libc_accept4 accept4 "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func getdents(fd int, buf []byte) (n int, err error) {
@@ -273,7 +388,7 @@ func getdents(fd int, buf []byte) (n int, err error) {
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall(SYS_GETDENTS, uintptr(fd), uintptr(_p0), uintptr(len(buf)))
+       r0, _, e1 := syscall(funcPC(libc_getdents_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(buf)))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -281,6 +396,11 @@ func getdents(fd int, buf []byte) (n int, err error) {
        return
 }
 
+func libc_getdents_trampoline()
+
+//go:linkname libc_getdents libc_getdents
+//go:cgo_import_dynamic libc_getdents getdents "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Access(path string, mode uint32) (err error) {
@@ -289,23 +409,33 @@ func Access(path string, mode uint32) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_ACCESS, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+       _, _, e1 := syscall(funcPC(libc_access_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_access_trampoline()
+
+//go:linkname libc_access libc_access
+//go:cgo_import_dynamic libc_access access "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Adjtime(delta *Timeval, olddelta *Timeval) (err error) {
-       _, _, e1 := Syscall(SYS_ADJTIME, uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
+       _, _, e1 := syscall(funcPC(libc_adjtime_trampoline), uintptr(unsafe.Pointer(delta)), uintptr(unsafe.Pointer(olddelta)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_adjtime_trampoline()
+
+//go:linkname libc_adjtime libc_adjtime
+//go:cgo_import_dynamic libc_adjtime adjtime "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Chdir(path string) (err error) {
@@ -314,13 +444,18 @@ func Chdir(path string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_CHDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_chdir_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_chdir_trampoline()
+
+//go:linkname libc_chdir libc_chdir
+//go:cgo_import_dynamic libc_chdir chdir "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Chflags(path string, flags int) (err error) {
@@ -329,13 +464,18 @@ func Chflags(path string, flags int) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_CHFLAGS, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+       _, _, e1 := syscall(funcPC(libc_chflags_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_chflags_trampoline()
+
+//go:linkname libc_chflags libc_chflags
+//go:cgo_import_dynamic libc_chflags chflags "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Chmod(path string, mode uint32) (err error) {
@@ -344,13 +484,18 @@ func Chmod(path string, mode uint32) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_CHMOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+       _, _, e1 := syscall(funcPC(libc_chmod_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_chmod_trampoline()
+
+//go:linkname libc_chmod libc_chmod
+//go:cgo_import_dynamic libc_chmod chmod "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Chown(path string, uid int, gid int) (err error) {
@@ -359,13 +504,18 @@ func Chown(path string, uid int, gid int) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_CHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+       _, _, e1 := syscall(funcPC(libc_chown_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_chown_trampoline()
+
+//go:linkname libc_chown libc_chown
+//go:cgo_import_dynamic libc_chown chown "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Chroot(path string) (err error) {
@@ -374,27 +524,37 @@ func Chroot(path string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_CHROOT, uintptr(unsafe.Pointer(_p0)), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_chroot_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_chroot_trampoline()
+
+//go:linkname libc_chroot libc_chroot
+//go:cgo_import_dynamic libc_chroot chroot "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Close(fd int) (err error) {
-       _, _, e1 := Syscall(SYS_CLOSE, uintptr(fd), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_close_trampoline), uintptr(fd), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_close_trampoline()
+
+//go:linkname libc_close libc_close
+//go:cgo_import_dynamic libc_close close "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Dup(fd int) (nfd int, err error) {
-       r0, _, e1 := Syscall(SYS_DUP, uintptr(fd), 0, 0)
+       r0, _, e1 := syscall(funcPC(libc_dup_trampoline), uintptr(fd), 0, 0)
        nfd = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -402,70 +562,105 @@ func Dup(fd int) (nfd int, err error) {
        return
 }
 
+func libc_dup_trampoline()
+
+//go:linkname libc_dup libc_dup
+//go:cgo_import_dynamic libc_dup dup "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Dup2(from int, to int) (err error) {
-       _, _, e1 := Syscall(SYS_DUP2, uintptr(from), uintptr(to), 0)
+       _, _, e1 := syscall(funcPC(libc_dup2_trampoline), uintptr(from), uintptr(to), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_dup2_trampoline()
+
+//go:linkname libc_dup2 libc_dup2
+//go:cgo_import_dynamic libc_dup2 dup2 "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fchdir(fd int) (err error) {
-       _, _, e1 := Syscall(SYS_FCHDIR, uintptr(fd), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_fchdir_trampoline), uintptr(fd), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_fchdir_trampoline()
+
+//go:linkname libc_fchdir libc_fchdir
+//go:cgo_import_dynamic libc_fchdir fchdir "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fchflags(fd int, flags int) (err error) {
-       _, _, e1 := Syscall(SYS_FCHFLAGS, uintptr(fd), uintptr(flags), 0)
+       _, _, e1 := syscall(funcPC(libc_fchflags_trampoline), uintptr(fd), uintptr(flags), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_fchflags_trampoline()
+
+//go:linkname libc_fchflags libc_fchflags
+//go:cgo_import_dynamic libc_fchflags fchflags "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fchmod(fd int, mode uint32) (err error) {
-       _, _, e1 := Syscall(SYS_FCHMOD, uintptr(fd), uintptr(mode), 0)
+       _, _, e1 := syscall(funcPC(libc_fchmod_trampoline), uintptr(fd), uintptr(mode), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_fchmod_trampoline()
+
+//go:linkname libc_fchmod libc_fchmod
+//go:cgo_import_dynamic libc_fchmod fchmod "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fchown(fd int, uid int, gid int) (err error) {
-       _, _, e1 := Syscall(SYS_FCHOWN, uintptr(fd), uintptr(uid), uintptr(gid))
+       _, _, e1 := syscall(funcPC(libc_fchown_trampoline), uintptr(fd), uintptr(uid), uintptr(gid))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_fchown_trampoline()
+
+//go:linkname libc_fchown libc_fchown
+//go:cgo_import_dynamic libc_fchown fchown "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Flock(fd int, how int) (err error) {
-       _, _, e1 := Syscall(SYS_FLOCK, uintptr(fd), uintptr(how), 0)
+       _, _, e1 := syscall(funcPC(libc_flock_trampoline), uintptr(fd), uintptr(how), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_flock_trampoline()
+
+//go:linkname libc_flock libc_flock
+//go:cgo_import_dynamic libc_flock flock "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fpathconf(fd int, name int) (val int, err error) {
-       r0, _, e1 := Syscall(SYS_FPATHCONF, uintptr(fd), uintptr(name), 0)
+       r0, _, e1 := syscall(funcPC(libc_fpathconf_trampoline), uintptr(fd), uintptr(name), 0)
        val = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -473,74 +668,114 @@ func Fpathconf(fd int, name int) (val int, err error) {
        return
 }
 
+func libc_fpathconf_trampoline()
+
+//go:linkname libc_fpathconf libc_fpathconf
+//go:cgo_import_dynamic libc_fpathconf fpathconf "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fstat(fd int, stat *Stat_t) (err error) {
-       _, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+       _, _, e1 := syscall(funcPC(libc_fstat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_fstat_trampoline()
+
+//go:linkname libc_fstat libc_fstat
+//go:cgo_import_dynamic libc_fstat fstat "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fstatfs(fd int, stat *Statfs_t) (err error) {
-       _, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
+       _, _, e1 := syscall(funcPC(libc_fstatfs_trampoline), uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_fstatfs_trampoline()
+
+//go:linkname libc_fstatfs libc_fstatfs
+//go:cgo_import_dynamic libc_fstatfs fstatfs "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Fsync(fd int) (err error) {
-       _, _, e1 := Syscall(SYS_FSYNC, uintptr(fd), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_fsync_trampoline), uintptr(fd), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_fsync_trampoline()
+
+//go:linkname libc_fsync libc_fsync
+//go:cgo_import_dynamic libc_fsync fsync "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Ftruncate(fd int, length int64) (err error) {
-       _, _, e1 := Syscall(SYS_FTRUNCATE, uintptr(fd), 0, uintptr(length))
+       _, _, e1 := syscall(funcPC(libc_ftruncate_trampoline), uintptr(fd), uintptr(length), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_ftruncate_trampoline()
+
+//go:linkname libc_ftruncate libc_ftruncate
+//go:cgo_import_dynamic libc_ftruncate ftruncate "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getegid() (egid int) {
-       r0, _, _ := RawSyscall(SYS_GETEGID, 0, 0, 0)
+       r0, _, _ := rawSyscall(funcPC(libc_getegid_trampoline), 0, 0, 0)
        egid = int(r0)
        return
 }
 
+func libc_getegid_trampoline()
+
+//go:linkname libc_getegid libc_getegid
+//go:cgo_import_dynamic libc_getegid getegid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Geteuid() (uid int) {
-       r0, _, _ := RawSyscall(SYS_GETEUID, 0, 0, 0)
+       r0, _, _ := rawSyscall(funcPC(libc_geteuid_trampoline), 0, 0, 0)
        uid = int(r0)
        return
 }
 
+func libc_geteuid_trampoline()
+
+//go:linkname libc_geteuid libc_geteuid
+//go:cgo_import_dynamic libc_geteuid geteuid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getgid() (gid int) {
-       r0, _, _ := RawSyscall(SYS_GETGID, 0, 0, 0)
+       r0, _, _ := rawSyscall(funcPC(libc_getgid_trampoline), 0, 0, 0)
        gid = int(r0)
        return
 }
 
+func libc_getgid_trampoline()
+
+//go:linkname libc_getgid libc_getgid
+//go:cgo_import_dynamic libc_getgid getgid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getpgid(pid int) (pgid int, err error) {
-       r0, _, e1 := RawSyscall(SYS_GETPGID, uintptr(pid), 0, 0)
+       r0, _, e1 := rawSyscall(funcPC(libc_getpgid_trampoline), uintptr(pid), 0, 0)
        pgid = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -548,34 +783,54 @@ func Getpgid(pid int) (pgid int, err error) {
        return
 }
 
+func libc_getpgid_trampoline()
+
+//go:linkname libc_getpgid libc_getpgid
+//go:cgo_import_dynamic libc_getpgid getpgid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getpgrp() (pgrp int) {
-       r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0)
+       r0, _, _ := rawSyscall(funcPC(libc_getpgrp_trampoline), 0, 0, 0)
        pgrp = int(r0)
        return
 }
 
+func libc_getpgrp_trampoline()
+
+//go:linkname libc_getpgrp libc_getpgrp
+//go:cgo_import_dynamic libc_getpgrp getpgrp "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getpid() (pid int) {
-       r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0)
+       r0, _, _ := rawSyscall(funcPC(libc_getpid_trampoline), 0, 0, 0)
        pid = int(r0)
        return
 }
 
+func libc_getpid_trampoline()
+
+//go:linkname libc_getpid libc_getpid
+//go:cgo_import_dynamic libc_getpid getpid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getppid() (ppid int) {
-       r0, _, _ := RawSyscall(SYS_GETPPID, 0, 0, 0)
+       r0, _, _ := rawSyscall(funcPC(libc_getppid_trampoline), 0, 0, 0)
        ppid = int(r0)
        return
 }
 
+func libc_getppid_trampoline()
+
+//go:linkname libc_getppid libc_getppid
+//go:cgo_import_dynamic libc_getppid getppid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getpriority(which int, who int) (prio int, err error) {
-       r0, _, e1 := Syscall(SYS_GETPRIORITY, uintptr(which), uintptr(who), 0)
+       r0, _, e1 := syscall(funcPC(libc_getpriority_trampoline), uintptr(which), uintptr(who), 0)
        prio = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -583,30 +838,45 @@ func Getpriority(which int, who int) (prio int, err error) {
        return
 }
 
+func libc_getpriority_trampoline()
+
+//go:linkname libc_getpriority libc_getpriority
+//go:cgo_import_dynamic libc_getpriority getpriority "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getrlimit(which int, lim *Rlimit) (err error) {
-       _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_getrlimit_trampoline), uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_getrlimit_trampoline()
+
+//go:linkname libc_getrlimit libc_getrlimit
+//go:cgo_import_dynamic libc_getrlimit getrlimit "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getrusage(who int, rusage *Rusage) (err error) {
-       _, _, e1 := RawSyscall(SYS_GETRUSAGE, uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_getrusage_trampoline), uintptr(who), uintptr(unsafe.Pointer(rusage)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_getrusage_trampoline()
+
+//go:linkname libc_getrusage libc_getrusage
+//go:cgo_import_dynamic libc_getrusage getrusage "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getsid(pid int) (sid int, err error) {
-       r0, _, e1 := RawSyscall(SYS_GETSID, uintptr(pid), 0, 0)
+       r0, _, e1 := rawSyscall(funcPC(libc_getsid_trampoline), uintptr(pid), 0, 0)
        sid = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -614,46 +884,71 @@ func Getsid(pid int) (sid int, err error) {
        return
 }
 
+func libc_getsid_trampoline()
+
+//go:linkname libc_getsid libc_getsid
+//go:cgo_import_dynamic libc_getsid getsid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Gettimeofday(tv *Timeval) (err error) {
-       _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
+       _, _, e1 := rawSyscall(funcPC(libc_gettimeofday_trampoline), uintptr(unsafe.Pointer(tv)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_gettimeofday_trampoline()
+
+//go:linkname libc_gettimeofday libc_gettimeofday
+//go:cgo_import_dynamic libc_gettimeofday gettimeofday "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Getuid() (uid int) {
-       r0, _, _ := RawSyscall(SYS_GETUID, 0, 0, 0)
+       r0, _, _ := rawSyscall(funcPC(libc_getuid_trampoline), 0, 0, 0)
        uid = int(r0)
        return
 }
 
+func libc_getuid_trampoline()
+
+//go:linkname libc_getuid libc_getuid
+//go:cgo_import_dynamic libc_getuid getuid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Issetugid() (tainted bool) {
-       r0, _, _ := Syscall(SYS_ISSETUGID, 0, 0, 0)
+       r0, _, _ := syscall(funcPC(libc_issetugid_trampoline), 0, 0, 0)
        tainted = bool(r0 != 0)
        return
 }
 
+func libc_issetugid_trampoline()
+
+//go:linkname libc_issetugid libc_issetugid
+//go:cgo_import_dynamic libc_issetugid issetugid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Kill(pid int, signum Signal) (err error) {
-       _, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), 0)
+       _, _, e1 := syscall(funcPC(libc_kill_trampoline), uintptr(pid), uintptr(signum), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_kill_trampoline()
+
+//go:linkname libc_kill libc_kill
+//go:cgo_import_dynamic libc_kill kill "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Kqueue() (fd int, err error) {
-       r0, _, e1 := Syscall(SYS_KQUEUE, 0, 0, 0)
+       r0, _, e1 := syscall(funcPC(libc_kqueue_trampoline), 0, 0, 0)
        fd = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -661,6 +956,11 @@ func Kqueue() (fd int, err error) {
        return
 }
 
+func libc_kqueue_trampoline()
+
+//go:linkname libc_kqueue libc_kqueue
+//go:cgo_import_dynamic libc_kqueue kqueue "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Lchown(path string, uid int, gid int) (err error) {
@@ -669,13 +969,18 @@ func Lchown(path string, uid int, gid int) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
+       _, _, e1 := syscall(funcPC(libc_lchown_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_lchown_trampoline()
+
+//go:linkname libc_lchown libc_lchown
+//go:cgo_import_dynamic libc_lchown lchown "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Link(path string, link string) (err error) {
@@ -689,23 +994,33 @@ func Link(path string, link string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_LINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+       _, _, e1 := syscall(funcPC(libc_link_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_link_trampoline()
+
+//go:linkname libc_link libc_link
+//go:cgo_import_dynamic libc_link link "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Listen(s int, backlog int) (err error) {
-       _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(backlog), 0)
+       _, _, e1 := syscall(funcPC(libc_listen_trampoline), uintptr(s), uintptr(backlog), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_listen_trampoline()
+
+//go:linkname libc_listen libc_listen
+//go:cgo_import_dynamic libc_listen listen "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Lstat(path string, stat *Stat_t) (err error) {
@@ -714,13 +1029,18 @@ func Lstat(path string, stat *Stat_t) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+       _, _, e1 := syscall(funcPC(libc_lstat_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_lstat_trampoline()
+
+//go:linkname libc_lstat libc_lstat
+//go:cgo_import_dynamic libc_lstat lstat "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Mkdir(path string, mode uint32) (err error) {
@@ -729,13 +1049,18 @@ func Mkdir(path string, mode uint32) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_MKDIR, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+       _, _, e1 := syscall(funcPC(libc_mkdir_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_mkdir_trampoline()
+
+//go:linkname libc_mkdir libc_mkdir
+//go:cgo_import_dynamic libc_mkdir mkdir "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Mkfifo(path string, mode uint32) (err error) {
@@ -744,13 +1069,18 @@ func Mkfifo(path string, mode uint32) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_MKFIFO, uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
+       _, _, e1 := syscall(funcPC(libc_mkfifo_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_mkfifo_trampoline()
+
+//go:linkname libc_mkfifo libc_mkfifo
+//go:cgo_import_dynamic libc_mkfifo mkfifo "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Mknod(path string, mode uint32, dev int) (err error) {
@@ -759,23 +1089,33 @@ func Mknod(path string, mode uint32, dev int) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_MKNOD, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
+       _, _, e1 := syscall(funcPC(libc_mknod_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(dev))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_mknod_trampoline()
+
+//go:linkname libc_mknod libc_mknod
+//go:cgo_import_dynamic libc_mknod mknod "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Nanosleep(time *Timespec, leftover *Timespec) (err error) {
-       _, _, e1 := Syscall(SYS_NANOSLEEP, uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
+       _, _, e1 := syscall(funcPC(libc_nanosleep_trampoline), uintptr(unsafe.Pointer(time)), uintptr(unsafe.Pointer(leftover)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_nanosleep_trampoline()
+
+//go:linkname libc_nanosleep libc_nanosleep
+//go:cgo_import_dynamic libc_nanosleep nanosleep "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Open(path string, mode int, perm uint32) (fd int, err error) {
@@ -784,7 +1124,7 @@ func Open(path string, mode int, perm uint32) (fd int, err error) {
        if err != nil {
                return
        }
-       r0, _, e1 := Syscall(SYS_OPEN, uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
+       r0, _, e1 := syscall(funcPC(libc_open_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(mode), uintptr(perm))
        fd = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -792,6 +1132,11 @@ func Open(path string, mode int, perm uint32) (fd int, err error) {
        return
 }
 
+func libc_open_trampoline()
+
+//go:linkname libc_open libc_open
+//go:cgo_import_dynamic libc_open open "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Pathconf(path string, name int) (val int, err error) {
@@ -800,7 +1145,7 @@ func Pathconf(path string, name int) (val int, err error) {
        if err != nil {
                return
        }
-       r0, _, e1 := Syscall(SYS_PATHCONF, uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
+       r0, _, e1 := syscall(funcPC(libc_pathconf_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(name), 0)
        val = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -808,6 +1153,11 @@ func Pathconf(path string, name int) (val int, err error) {
        return
 }
 
+func libc_pathconf_trampoline()
+
+//go:linkname libc_pathconf libc_pathconf
+//go:cgo_import_dynamic libc_pathconf pathconf "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Pread(fd int, p []byte, offset int64) (n int, err error) {
@@ -817,7 +1167,7 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) {
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall6(SYS_PREAD, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), 0)
+       r0, _, e1 := syscall6(funcPC(libc_pread_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -825,6 +1175,11 @@ func Pread(fd int, p []byte, offset int64) (n int, err error) {
        return
 }
 
+func libc_pread_trampoline()
+
+//go:linkname libc_pread libc_pread
+//go:cgo_import_dynamic libc_pread pread "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
@@ -834,7 +1189,7 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall6(SYS_PWRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), 0)
+       r0, _, e1 := syscall6(funcPC(libc_pwrite_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -842,6 +1197,11 @@ func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
        return
 }
 
+func libc_pwrite_trampoline()
+
+//go:linkname libc_pwrite libc_pwrite
+//go:cgo_import_dynamic libc_pwrite pwrite "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func read(fd int, p []byte) (n int, err error) {
@@ -851,7 +1211,7 @@ func read(fd int, p []byte) (n int, err error) {
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+       r0, _, e1 := syscall(funcPC(libc_read_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -859,6 +1219,11 @@ func read(fd int, p []byte) (n int, err error) {
        return
 }
 
+func libc_read_trampoline()
+
+//go:linkname libc_read libc_read
+//go:cgo_import_dynamic libc_read read "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Readlink(path string, buf []byte) (n int, err error) {
@@ -873,7 +1238,7 @@ func Readlink(path string, buf []byte) (n int, err error) {
        } else {
                _p1 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall(SYS_READLINK, uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
+       r0, _, e1 := syscall(funcPC(libc_readlink_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(_p1), uintptr(len(buf)))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -881,6 +1246,11 @@ func Readlink(path string, buf []byte) (n int, err error) {
        return
 }
 
+func libc_readlink_trampoline()
+
+//go:linkname libc_readlink libc_readlink
+//go:cgo_import_dynamic libc_readlink readlink "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Rename(from string, to string) (err error) {
@@ -894,13 +1264,18 @@ func Rename(from string, to string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_RENAME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+       _, _, e1 := syscall(funcPC(libc_rename_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_rename_trampoline()
+
+//go:linkname libc_rename libc_rename
+//go:cgo_import_dynamic libc_rename rename "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Revoke(path string) (err error) {
@@ -909,13 +1284,18 @@ func Revoke(path string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_REVOKE, uintptr(unsafe.Pointer(_p0)), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_revoke_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_revoke_trampoline()
+
+//go:linkname libc_revoke libc_revoke
+//go:cgo_import_dynamic libc_revoke revoke "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Rmdir(path string) (err error) {
@@ -924,64 +1304,78 @@ func Rmdir(path string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_RMDIR, uintptr(unsafe.Pointer(_p0)), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_rmdir_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
-// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func libc_rmdir_trampoline()
 
-func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
-       r0, _, e1 := Syscall6(SYS_LSEEK, uintptr(fd), 0, uintptr(offset), uintptr(whence), 0, 0)
-       newoffset = int64(r0)
-       if e1 != 0 {
-               err = errnoErr(e1)
-       }
-       return
-}
+//go:linkname libc_rmdir libc_rmdir
+//go:cgo_import_dynamic libc_rmdir rmdir "libc.so"
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) {
-       _, _, e1 := Syscall6(SYS_SELECT, uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
+       _, _, e1 := syscall6(funcPC(libc_select_trampoline), uintptr(n), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_select_trampoline()
+
+//go:linkname libc_select libc_select
+//go:cgo_import_dynamic libc_select select "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setegid(egid int) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETEGID, uintptr(egid), 0, 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setegid_trampoline), uintptr(egid), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setegid_trampoline()
+
+//go:linkname libc_setegid libc_setegid
+//go:cgo_import_dynamic libc_setegid setegid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Seteuid(euid int) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETEUID, uintptr(euid), 0, 0)
+       _, _, e1 := rawSyscall(funcPC(libc_seteuid_trampoline), uintptr(euid), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_seteuid_trampoline()
+
+//go:linkname libc_seteuid libc_seteuid
+//go:cgo_import_dynamic libc_seteuid seteuid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setgid(gid int) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETGID, uintptr(gid), 0, 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setgid_trampoline), uintptr(gid), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setgid_trampoline()
+
+//go:linkname libc_setgid libc_setgid
+//go:cgo_import_dynamic libc_setgid setgid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setlogin(name string) (err error) {
@@ -990,67 +1384,97 @@ func Setlogin(name string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_SETLOGIN, uintptr(unsafe.Pointer(_p0)), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_setlogin_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setlogin_trampoline()
+
+//go:linkname libc_setlogin libc_setlogin
+//go:cgo_import_dynamic libc_setlogin setlogin "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setpgid(pid int, pgid int) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETPGID, uintptr(pid), uintptr(pgid), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setpgid_trampoline), uintptr(pid), uintptr(pgid), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setpgid_trampoline()
+
+//go:linkname libc_setpgid libc_setpgid
+//go:cgo_import_dynamic libc_setpgid setpgid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setpriority(which int, who int, prio int) (err error) {
-       _, _, e1 := Syscall(SYS_SETPRIORITY, uintptr(which), uintptr(who), uintptr(prio))
+       _, _, e1 := syscall(funcPC(libc_setpriority_trampoline), uintptr(which), uintptr(who), uintptr(prio))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setpriority_trampoline()
+
+//go:linkname libc_setpriority libc_setpriority
+//go:cgo_import_dynamic libc_setpriority setpriority "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setregid(rgid int, egid int) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setregid_trampoline), uintptr(rgid), uintptr(egid), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setregid_trampoline()
+
+//go:linkname libc_setregid libc_setregid
+//go:cgo_import_dynamic libc_setregid setregid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setreuid(ruid int, euid int) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setreuid_trampoline), uintptr(ruid), uintptr(euid), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setreuid_trampoline()
+
+//go:linkname libc_setreuid libc_setreuid
+//go:cgo_import_dynamic libc_setreuid setreuid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setrlimit(which int, lim *Rlimit) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setrlimit_trampoline), uintptr(which), uintptr(unsafe.Pointer(lim)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setrlimit_trampoline()
+
+//go:linkname libc_setrlimit libc_setrlimit
+//go:cgo_import_dynamic libc_setrlimit setrlimit "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setsid() (pid int, err error) {
-       r0, _, e1 := RawSyscall(SYS_SETSID, 0, 0, 0)
+       r0, _, e1 := rawSyscall(funcPC(libc_setsid_trampoline), 0, 0, 0)
        pid = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -1058,26 +1482,41 @@ func Setsid() (pid int, err error) {
        return
 }
 
+func libc_setsid_trampoline()
+
+//go:linkname libc_setsid libc_setsid
+//go:cgo_import_dynamic libc_setsid setsid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Settimeofday(tp *Timeval) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETTIMEOFDAY, uintptr(unsafe.Pointer(tp)), 0, 0)
+       _, _, e1 := rawSyscall(funcPC(libc_settimeofday_trampoline), uintptr(unsafe.Pointer(tp)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_settimeofday_trampoline()
+
+//go:linkname libc_settimeofday libc_settimeofday
+//go:cgo_import_dynamic libc_settimeofday settimeofday "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Setuid(uid int) (err error) {
-       _, _, e1 := RawSyscall(SYS_SETUID, uintptr(uid), 0, 0)
+       _, _, e1 := rawSyscall(funcPC(libc_setuid_trampoline), uintptr(uid), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_setuid_trampoline()
+
+//go:linkname libc_setuid libc_setuid
+//go:cgo_import_dynamic libc_setuid setuid "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Stat(path string, stat *Stat_t) (err error) {
@@ -1086,13 +1525,18 @@ func Stat(path string, stat *Stat_t) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+       _, _, e1 := syscall(funcPC(libc_stat_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_stat_trampoline()
+
+//go:linkname libc_stat libc_stat
+//go:cgo_import_dynamic libc_stat stat "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Statfs(path string, stat *Statfs_t) (err error) {
@@ -1101,13 +1545,18 @@ func Statfs(path string, stat *Statfs_t) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
+       _, _, e1 := syscall(funcPC(libc_statfs_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_statfs_trampoline()
+
+//go:linkname libc_statfs libc_statfs
+//go:cgo_import_dynamic libc_statfs statfs "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Symlink(path string, link string) (err error) {
@@ -1121,23 +1570,33 @@ func Symlink(path string, link string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_SYMLINK, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
+       _, _, e1 := syscall(funcPC(libc_symlink_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_p1)), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_symlink_trampoline()
+
+//go:linkname libc_symlink libc_symlink
+//go:cgo_import_dynamic libc_symlink symlink "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Sync() (err error) {
-       _, _, e1 := Syscall(SYS_SYNC, 0, 0, 0)
+       _, _, e1 := syscall(funcPC(libc_sync_trampoline), 0, 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_sync_trampoline()
+
+//go:linkname libc_sync libc_sync
+//go:cgo_import_dynamic libc_sync sync "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Truncate(path string, length int64) (err error) {
@@ -1146,21 +1605,31 @@ func Truncate(path string, length int64) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length))
+       _, _, e1 := syscall(funcPC(libc_truncate_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_truncate_trampoline()
+
+//go:linkname libc_truncate libc_truncate
+//go:cgo_import_dynamic libc_truncate truncate "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Umask(newmask int) (oldmask int) {
-       r0, _, _ := Syscall(SYS_UMASK, uintptr(newmask), 0, 0)
+       r0, _, _ := syscall(funcPC(libc_umask_trampoline), uintptr(newmask), 0, 0)
        oldmask = int(r0)
        return
 }
 
+func libc_umask_trampoline()
+
+//go:linkname libc_umask libc_umask
+//go:cgo_import_dynamic libc_umask umask "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Unlink(path string) (err error) {
@@ -1169,13 +1638,18 @@ func Unlink(path string) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_UNLINK, uintptr(unsafe.Pointer(_p0)), 0, 0)
+       _, _, e1 := syscall(funcPC(libc_unlink_trampoline), uintptr(unsafe.Pointer(_p0)), 0, 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_unlink_trampoline()
+
+//go:linkname libc_unlink libc_unlink
+//go:cgo_import_dynamic libc_unlink unlink "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func Unmount(path string, flags int) (err error) {
@@ -1184,13 +1658,18 @@ func Unmount(path string, flags int) (err error) {
        if err != nil {
                return
        }
-       _, _, e1 := Syscall(SYS_UNMOUNT, uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
+       _, _, e1 := syscall(funcPC(libc_unmount_trampoline), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_unmount_trampoline()
+
+//go:linkname libc_unmount libc_unmount
+//go:cgo_import_dynamic libc_unmount unmount "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func write(fd int, p []byte) (n int, err error) {
@@ -1200,7 +1679,7 @@ func write(fd int, p []byte) (n int, err error) {
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(_p0), uintptr(len(p)))
+       r0, _, e1 := syscall(funcPC(libc_write_trampoline), uintptr(fd), uintptr(_p0), uintptr(len(p)))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -1208,10 +1687,15 @@ func write(fd int, p []byte) (n int, err error) {
        return
 }
 
+func libc_write_trampoline()
+
+//go:linkname libc_write libc_write
+//go:cgo_import_dynamic libc_write write "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) {
-       r0, _, e1 := Syscall9(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), 0, uintptr(pos), 0, 0)
+       r0, _, e1 := syscall6X(funcPC(libc_mmap_trampoline), uintptr(addr), uintptr(length), uintptr(prot), uintptr(flag), uintptr(fd), uintptr(pos))
        ret = uintptr(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -1219,20 +1703,66 @@ func mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (
        return
 }
 
+func libc_mmap_trampoline()
+
+//go:linkname libc_mmap libc_mmap
+//go:cgo_import_dynamic libc_mmap mmap "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func munmap(addr uintptr, length uintptr) (err error) {
-       _, _, e1 := Syscall(SYS_MUNMAP, uintptr(addr), uintptr(length), 0)
+       _, _, e1 := syscall(funcPC(libc_munmap_trampoline), uintptr(addr), uintptr(length), 0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_munmap_trampoline()
+
+//go:linkname libc_munmap libc_munmap
+//go:cgo_import_dynamic libc_munmap munmap "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error) {
+       var _p0 *byte
+       _p0, err = BytePtrFromString(path)
+       if err != nil {
+               return
+       }
+       _, _, e1 := syscall6(funcPC(libc_utimensat_trampoline), uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flag), 0, 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_utimensat_trampoline()
+
+//go:linkname libc_utimensat libc_utimensat
+//go:cgo_import_dynamic libc_utimensat utimensat "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func directSyscall(trap uintptr, a1 uintptr, a2 uintptr, a3 uintptr, a4 uintptr, a5 uintptr) (ret uintptr, err error) {
+       r0, _, e1 := syscall6X(funcPC(libc_syscall_trampoline), uintptr(trap), uintptr(a1), uintptr(a2), uintptr(a3), uintptr(a4), uintptr(a5))
+       ret = uintptr(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_syscall_trampoline()
+
+//go:linkname libc_syscall libc_syscall
+//go:cgo_import_dynamic libc_syscall syscall "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
-       r0, _, e1 := Syscall(SYS_READ, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+       r0, _, e1 := syscall(funcPC(libc_read_trampoline), uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -1243,7 +1773,7 @@ func readlen(fd int, buf *byte, nbuf int) (n int, err error) {
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
-       r0, _, e1 := Syscall(SYS_WRITE, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
+       r0, _, e1 := syscall(funcPC(libc_write_trampoline), uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf))
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -1253,19 +1783,20 @@ func writelen(fd int, buf *byte, nbuf int) (n int, err error) {
 
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
-func utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error) {
-       var _p0 *byte
-       _p0, err = BytePtrFromString(path)
-       if err != nil {
-               return
-       }
-       _, _, e1 := Syscall6(SYS_UTIMENSAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), uintptr(flag), 0, 0)
+func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
+       r0, _, e1 := syscallX(funcPC(libc_lseek_trampoline), uintptr(fd), uintptr(offset), uintptr(whence))
+       newoffset = int64(r0)
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
 
+func libc_lseek_trampoline()
+
+//go:linkname libc_lseek libc_lseek
+//go:cgo_import_dynamic libc_lseek lseek "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func getcwd(buf []byte) (n int, err error) {
@@ -1275,7 +1806,7 @@ func getcwd(buf []byte) (n int, err error) {
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       r0, _, e1 := Syscall(SYS___GETCWD, uintptr(_p0), uintptr(len(buf)), 0)
+       r0, _, e1 := syscall(funcPC(libc_getcwd_trampoline), uintptr(_p0), uintptr(len(buf)), 0)
        n = int(r0)
        if e1 != 0 {
                err = errnoErr(e1)
@@ -1283,6 +1814,11 @@ func getcwd(buf []byte) (n int, err error) {
        return
 }
 
+func libc_getcwd_trampoline()
+
+//go:linkname libc_getcwd libc_getcwd
+//go:cgo_import_dynamic libc_getcwd getcwd "libc.so"
+
 // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
 
 func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) {
@@ -1292,9 +1828,184 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr)
        } else {
                _p0 = unsafe.Pointer(&_zero)
        }
-       _, _, e1 := Syscall6(SYS___SYSCTL, uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
+       _, _, e1 := syscall6(funcPC(libc_sysctl_trampoline), uintptr(_p0), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen))
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_sysctl_trampoline()
+
+//go:linkname libc_sysctl libc_sysctl
+//go:cgo_import_dynamic libc_sysctl sysctl "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fork() (pid int, err error) {
+       r0, _, e1 := rawSyscall(funcPC(libc_fork_trampoline), 0, 0, 0)
+       pid = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_fork_trampoline()
+
+//go:linkname libc_fork libc_fork
+//go:cgo_import_dynamic libc_fork fork "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func ioctl(fd int, req int, arg int) (err error) {
+       _, _, e1 := rawSyscall(funcPC(libc_ioctl_trampoline), uintptr(fd), uintptr(req), uintptr(arg))
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_ioctl_trampoline()
+
+//go:linkname libc_ioctl libc_ioctl
+//go:cgo_import_dynamic libc_ioctl ioctl "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func execve(path *byte, argv **byte, envp **byte) (err error) {
+       _, _, e1 := rawSyscall(funcPC(libc_execve_trampoline), uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(argv)), uintptr(unsafe.Pointer(envp)))
        if e1 != 0 {
                err = errnoErr(e1)
        }
        return
 }
+
+func libc_execve_trampoline()
+
+//go:linkname libc_execve libc_execve
+//go:cgo_import_dynamic libc_execve execve "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func exit(res int) (err error) {
+       _, _, e1 := rawSyscall(funcPC(libc_exit_trampoline), uintptr(res), 0, 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_exit_trampoline()
+
+//go:linkname libc_exit libc_exit
+//go:cgo_import_dynamic libc_exit exit "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+//go:nosplit
+func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) {
+       _, _, e1 := syscall6(funcPC(libc_ptrace_trampoline), uintptr(request), uintptr(pid), uintptr(addr), uintptr(data), 0, 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_ptrace_trampoline()
+
+//go:linkname libc_ptrace libc_ptrace
+//go:cgo_import_dynamic libc_ptrace ptrace "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func getentropy(p []byte) (err error) {
+       var _p0 unsafe.Pointer
+       if len(p) > 0 {
+               _p0 = unsafe.Pointer(&p[0])
+       } else {
+               _p0 = unsafe.Pointer(&_zero)
+       }
+       _, _, e1 := rawSyscall(funcPC(libc_getentropy_trampoline), uintptr(_p0), uintptr(len(p)), 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_getentropy_trampoline()
+
+//go:linkname libc_getentropy libc_getentropy
+//go:cgo_import_dynamic libc_getentropy getentropy "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
+       var _p0 *byte
+       _p0, err = BytePtrFromString(path)
+       if err != nil {
+               return
+       }
+       _, _, e1 := syscall6(funcPC(libc_fstatat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_fstatat_trampoline()
+
+//go:linkname libc_fstatat libc_fstatat
+//go:cgo_import_dynamic libc_fstatat fstatat "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func fcntlPtr(fd int, cmd int, arg unsafe.Pointer) (val int, err error) {
+       r0, _, e1 := syscall(funcPC(libc_fcntl_trampoline), uintptr(fd), uintptr(cmd), uintptr(arg))
+       val = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func unlinkat(fd int, path string, flags int) (err error) {
+       var _p0 *byte
+       _p0, err = BytePtrFromString(path)
+       if err != nil {
+               return
+       }
+       _, _, e1 := syscall(funcPC(libc_unlinkat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(flags))
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_unlinkat_trampoline()
+
+//go:linkname libc_unlinkat libc_unlinkat
+//go:cgo_import_dynamic libc_unlinkat unlinkat "libc.so"
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
+func openat(fd int, path string, flags int, perm uint32) (fdret int, err error) {
+       var _p0 *byte
+       _p0, err = BytePtrFromString(path)
+       if err != nil {
+               return
+       }
+       r0, _, e1 := syscall6(funcPC(libc_openat_trampoline), uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(flags), uintptr(perm), 0, 0)
+       fdret = int(r0)
+       if e1 != 0 {
+               err = errnoErr(e1)
+       }
+       return
+}
+
+func libc_openat_trampoline()
+
+//go:linkname libc_openat libc_openat
+//go:cgo_import_dynamic libc_openat openat "libc.so"
diff --git a/src/syscall/zsyscall_openbsd_arm64.s b/src/syscall/zsyscall_openbsd_arm64.s
new file mode 100644 (file)
index 0000000..37778b1
--- /dev/null
@@ -0,0 +1,233 @@
+// go run mkasm.go openbsd arm64
+// Code generated by the command above; DO NOT EDIT.
+#include "textflag.h"
+TEXT ·libc_getgroups_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getgroups(SB)
+TEXT ·libc_setgroups_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setgroups(SB)
+TEXT ·libc_wait4_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_wait4(SB)
+TEXT ·libc_accept_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_accept(SB)
+TEXT ·libc_bind_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_bind(SB)
+TEXT ·libc_connect_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_connect(SB)
+TEXT ·libc_socket_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_socket(SB)
+TEXT ·libc_getsockopt_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getsockopt(SB)
+TEXT ·libc_setsockopt_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setsockopt(SB)
+TEXT ·libc_getpeername_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getpeername(SB)
+TEXT ·libc_getsockname_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getsockname(SB)
+TEXT ·libc_shutdown_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_shutdown(SB)
+TEXT ·libc_socketpair_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_socketpair(SB)
+TEXT ·libc_recvfrom_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_recvfrom(SB)
+TEXT ·libc_sendto_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_sendto(SB)
+TEXT ·libc_recvmsg_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_recvmsg(SB)
+TEXT ·libc_sendmsg_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_sendmsg(SB)
+TEXT ·libc_kevent_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_kevent(SB)
+TEXT ·libc_utimes_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_utimes(SB)
+TEXT ·libc_futimes_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_futimes(SB)
+TEXT ·libc_fcntl_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fcntl(SB)
+TEXT ·libc_pipe2_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_pipe2(SB)
+TEXT ·libc_accept4_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_accept4(SB)
+TEXT ·libc_getdents_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getdents(SB)
+TEXT ·libc_access_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_access(SB)
+TEXT ·libc_adjtime_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_adjtime(SB)
+TEXT ·libc_chdir_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_chdir(SB)
+TEXT ·libc_chflags_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_chflags(SB)
+TEXT ·libc_chmod_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_chmod(SB)
+TEXT ·libc_chown_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_chown(SB)
+TEXT ·libc_chroot_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_chroot(SB)
+TEXT ·libc_close_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_close(SB)
+TEXT ·libc_dup_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_dup(SB)
+TEXT ·libc_dup2_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_dup2(SB)
+TEXT ·libc_fchdir_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fchdir(SB)
+TEXT ·libc_fchflags_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fchflags(SB)
+TEXT ·libc_fchmod_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fchmod(SB)
+TEXT ·libc_fchown_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fchown(SB)
+TEXT ·libc_flock_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_flock(SB)
+TEXT ·libc_fpathconf_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fpathconf(SB)
+TEXT ·libc_fstat_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fstat(SB)
+TEXT ·libc_fstatfs_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fstatfs(SB)
+TEXT ·libc_fsync_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fsync(SB)
+TEXT ·libc_ftruncate_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_ftruncate(SB)
+TEXT ·libc_getegid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getegid(SB)
+TEXT ·libc_geteuid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_geteuid(SB)
+TEXT ·libc_getgid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getgid(SB)
+TEXT ·libc_getpgid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getpgid(SB)
+TEXT ·libc_getpgrp_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getpgrp(SB)
+TEXT ·libc_getpid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getpid(SB)
+TEXT ·libc_getppid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getppid(SB)
+TEXT ·libc_getpriority_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getpriority(SB)
+TEXT ·libc_getrlimit_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getrlimit(SB)
+TEXT ·libc_getrusage_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getrusage(SB)
+TEXT ·libc_getsid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getsid(SB)
+TEXT ·libc_gettimeofday_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_gettimeofday(SB)
+TEXT ·libc_getuid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getuid(SB)
+TEXT ·libc_issetugid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_issetugid(SB)
+TEXT ·libc_kill_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_kill(SB)
+TEXT ·libc_kqueue_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_kqueue(SB)
+TEXT ·libc_lchown_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_lchown(SB)
+TEXT ·libc_link_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_link(SB)
+TEXT ·libc_listen_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_listen(SB)
+TEXT ·libc_lstat_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_lstat(SB)
+TEXT ·libc_mkdir_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_mkdir(SB)
+TEXT ·libc_mkfifo_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_mkfifo(SB)
+TEXT ·libc_mknod_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_mknod(SB)
+TEXT ·libc_nanosleep_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_nanosleep(SB)
+TEXT ·libc_open_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_open(SB)
+TEXT ·libc_pathconf_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_pathconf(SB)
+TEXT ·libc_pread_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_pread(SB)
+TEXT ·libc_pwrite_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_pwrite(SB)
+TEXT ·libc_read_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_read(SB)
+TEXT ·libc_readlink_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_readlink(SB)
+TEXT ·libc_rename_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_rename(SB)
+TEXT ·libc_revoke_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_revoke(SB)
+TEXT ·libc_rmdir_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_rmdir(SB)
+TEXT ·libc_select_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_select(SB)
+TEXT ·libc_setegid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setegid(SB)
+TEXT ·libc_seteuid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_seteuid(SB)
+TEXT ·libc_setgid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setgid(SB)
+TEXT ·libc_setlogin_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setlogin(SB)
+TEXT ·libc_setpgid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setpgid(SB)
+TEXT ·libc_setpriority_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setpriority(SB)
+TEXT ·libc_setregid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setregid(SB)
+TEXT ·libc_setreuid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setreuid(SB)
+TEXT ·libc_setrlimit_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setrlimit(SB)
+TEXT ·libc_setsid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setsid(SB)
+TEXT ·libc_settimeofday_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_settimeofday(SB)
+TEXT ·libc_setuid_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_setuid(SB)
+TEXT ·libc_stat_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_stat(SB)
+TEXT ·libc_statfs_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_statfs(SB)
+TEXT ·libc_symlink_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_symlink(SB)
+TEXT ·libc_sync_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_sync(SB)
+TEXT ·libc_truncate_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_truncate(SB)
+TEXT ·libc_umask_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_umask(SB)
+TEXT ·libc_unlink_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_unlink(SB)
+TEXT ·libc_unmount_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_unmount(SB)
+TEXT ·libc_write_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_write(SB)
+TEXT ·libc_mmap_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_mmap(SB)
+TEXT ·libc_munmap_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_munmap(SB)
+TEXT ·libc_utimensat_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_utimensat(SB)
+TEXT ·libc_syscall_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_syscall(SB)
+TEXT ·libc_lseek_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_lseek(SB)
+TEXT ·libc_getcwd_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getcwd(SB)
+TEXT ·libc_sysctl_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_sysctl(SB)
+TEXT ·libc_fork_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fork(SB)
+TEXT ·libc_ioctl_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_ioctl(SB)
+TEXT ·libc_execve_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_execve(SB)
+TEXT ·libc_exit_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_exit(SB)
+TEXT ·libc_ptrace_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_ptrace(SB)
+TEXT ·libc_getentropy_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_getentropy(SB)
+TEXT ·libc_fstatat_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_fstatat(SB)
+TEXT ·libc_unlinkat_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_unlinkat(SB)
+TEXT ·libc_openat_trampoline(SB),NOSPLIT,$0-0
+       JMP     libc_openat(SB)
index acd3f4f3e5d85e99d9d4cc03fcb2844f44f58418..85fe720b30b667816908afd72da60d323c3c9837 100644 (file)
@@ -59,10 +59,10 @@ func f(n int) {
        ill := make([]byte, 64)
        switch runtime.GOARCH {
        case "386", "amd64":
-               ill = append(ill, 0x89, 0x04, 0x25, 0x00, 0x00, 0x00, 0x00) // MOVL AX, 0
+               ill = append(ill[:0], 0x89, 0x04, 0x25, 0x00, 0x00, 0x00, 0x00) // MOVL AX, 0
        case "arm":
-               binary.LittleEndian.PutUint32(ill, 0xe3a00000) // MOVW $0, R0
-               binary.LittleEndian.PutUint32(ill, 0xe5800000) // MOVW R0, (R0)
+               binary.LittleEndian.PutUint32(ill[0:4], 0xe3a00000) // MOVW $0, R0
+               binary.LittleEndian.PutUint32(ill[4:8], 0xe5800000) // MOVW R0, (R0)
        case "arm64":
                binary.LittleEndian.PutUint32(ill, 0xf90003ff) // MOVD ZR, (ZR)
        case "ppc64":
@@ -74,7 +74,7 @@ func f(n int) {
        case "mipsle", "mips64le":
                binary.LittleEndian.PutUint32(ill, 0xfc000000) // MOVV R0, (R0)
        case "s390x":
-               ill = append(ill, 0xa7, 0x09, 0x00, 0x00)             // MOVD $0, R0
+               ill = append(ill[:0], 0xa7, 0x09, 0x00, 0x00)         // MOVD $0, R0
                ill = append(ill, 0xe3, 0x00, 0x00, 0x00, 0x00, 0x24) // MOVD R0, (R0)
        case "riscv64":
                binary.LittleEndian.PutUint32(ill, 0x00003023) // MOV X0, (X0)