diff options
author | Nikhil Benesch <nikhil.benesch@gmail.com> | 2020-10-26 18:42:08 +0000 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2020-10-28 18:20:50 -0700 |
commit | 0cdde1e7ae197366e17e5ef50bf68d4d5760df01 (patch) | |
tree | 35bfb1e6e1551c39558abb3b699b032e952823c4 /libgo/go | |
parent | e93aae4a497c38b46df818a629c78149fe6af24b (diff) | |
download | gcc-0cdde1e7ae197366e17e5ef50bf68d4d5760df01.zip gcc-0cdde1e7ae197366e17e5ef50bf68d4d5760df01.tar.gz gcc-0cdde1e7ae197366e17e5ef50bf68d4d5760df01.tar.bz2 |
libgo: handle linking to NetBSD's versioned symbols
On NetBSD, for backwards compatibility, various libc symbols are
renamed to a symbol with a version suffix. For example, this is the
(abbreviated) definition of sigaction:
int sigaction(...) __asm__ ("__sigaction14")
This poses a challenge for libgo, which attempts to link sigaction by
way of an "//extern" comment:
//extern sigaction
func sigaction(...)
This results in a reference to the deprecated compatibility symbol
"sigaction", rather than the desired "__sigaction14" symbol.
This patch introduces a new "//extern-sysinfo" comment to handle this
situation. The new mklinknames.awk script scans a package for these
comments and outputs a "//go:linkname" directive that links the wrapper
to the correct versioned symbol, as determined by parsing the __asm__
annotation on the function's declaration in gen-sysinfo.go.
For now, only the following packages are scanned by mklinknames.awk:
os
os/user
runtime
syscall
gotools/:
* Makefile.am (check-runtime): Add runtime_linknames.go to
--extrafiles.
* Makefile.in: Regenerate.
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/265125
Diffstat (limited to 'libgo/go')
-rw-r--r-- | libgo/go/os/dir_regfile.go | 2 | ||||
-rw-r--r-- | libgo/go/os/user/decls_unix.go | 10 | ||||
-rw-r--r-- | libgo/go/runtime/netpoll_kqueue.go | 4 | ||||
-rw-r--r-- | libgo/go/runtime/os_gccgo.go | 4 | ||||
-rw-r--r-- | libgo/go/runtime/os_netbsd.go | 8 | ||||
-rw-r--r-- | libgo/go/runtime/signal_gccgo.go | 22 | ||||
-rw-r--r-- | libgo/go/runtime/stubs2.go | 2 | ||||
-rw-r--r-- | libgo/go/syscall/mksyscall.awk | 4 |
8 files changed, 28 insertions, 28 deletions
diff --git a/libgo/go/os/dir_regfile.go b/libgo/go/os/dir_regfile.go index 1f18bab..b2e66235 100644 --- a/libgo/go/os/dir_regfile.go +++ b/libgo/go/os/dir_regfile.go @@ -15,5 +15,5 @@ package os import "syscall" -//extern readdir_r +//extern-sysinfo readdir_r func libc_readdir_r(*syscall.DIR, *syscall.Dirent, **syscall.Dirent) syscall.Errno diff --git a/libgo/go/os/user/decls_unix.go b/libgo/go/os/user/decls_unix.go index 276468c..6ffaced 100644 --- a/libgo/go/os/user/decls_unix.go +++ b/libgo/go/os/user/decls_unix.go @@ -11,17 +11,17 @@ import "syscall" // Declarations for the libc functions on most Unix systems. -//extern getpwnam_r +//extern-sysinfo getpwnam_r func libc_getpwnam_r(name *byte, pwd *syscall.Passwd, buf *byte, buflen syscall.Size_t, result **syscall.Passwd) int -//extern getpwuid_r +//extern-sysinfo getpwuid_r func libc_getpwuid_r(uid syscall.Uid_t, pwd *syscall.Passwd, buf *byte, buflen syscall.Size_t, result **syscall.Passwd) int -//extern getgrnam_r +//extern-sysinfo getgrnam_r func libc_getgrnam_r(name *byte, grp *syscall.Group, buf *byte, buflen syscall.Size_t, result **syscall.Group) int -//extern getgrgid_r +//extern-sysinfo getgrgid_r func libc_getgrgid_r(gid syscall.Gid_t, grp *syscall.Group, buf *byte, buflen syscall.Size_t, result **syscall.Group) int -//extern getgrouplist +//extern-sysinfo getgrouplist func libc_getgrouplist(user *byte, group syscall.Gid_t, groups *syscall.Gid_t, ngroups *int32) int diff --git a/libgo/go/runtime/netpoll_kqueue.go b/libgo/go/runtime/netpoll_kqueue.go index c41a7d0..1724f37 100644 --- a/libgo/go/runtime/netpoll_kqueue.go +++ b/libgo/go/runtime/netpoll_kqueue.go @@ -13,11 +13,11 @@ import ( "unsafe" ) -//extern kqueue +//extern-sysinfo kqueue func kqueue() int32 //go:noescape -//extern kevent +//extern-sysinfo kevent func kevent(kq int32, ch *keventt, nch uintptr, ev *keventt, nev uintptr, ts *timespec) int32 var ( diff --git a/libgo/go/runtime/os_gccgo.go b/libgo/go/runtime/os_gccgo.go index a8859c0..79331c5 100644 --- a/libgo/go/runtime/os_gccgo.go +++ b/libgo/go/runtime/os_gccgo.go @@ -52,7 +52,7 @@ func getRandomData(r []byte) { } //go:noescape -//extern pipe +//extern-sysinfo pipe func libcPipe(*[2]int32) int32 func pipe() (r, w int32, e int32) { @@ -65,7 +65,7 @@ func pipe() (r, w int32, e int32) { } //go:noescape -//extern pipe2 +//extern-sysinfo pipe2 func libcPipe2(*[2]int32, int32) int32 func pipe2(flags int32) (r, w int32, e int32) { diff --git a/libgo/go/runtime/os_netbsd.go b/libgo/go/runtime/os_netbsd.go index 9ebb652..00c3285 100644 --- a/libgo/go/runtime/os_netbsd.go +++ b/libgo/go/runtime/os_netbsd.go @@ -18,19 +18,19 @@ func getProcID() uint64 { return uint64(lwp_self()) } -//extern _lwp_self +//extern-sysinfo _lwp_self func lwp_self() int32 //go:noescape -//extern _lwp_park +//extern-sysinfo _lwp_park func lwp_park(ts int32, rel int32, abstime *timespec, unpark int32, hint, unparkhint unsafe.Pointer) int32 //go:noescape -//extern _lwp_unpark +//extern-sysinfo _lwp_unpark func lwp_unpark(lwp int32, hint unsafe.Pointer) int32 //go:noescape -//extern sysctl +//extern-sysinfo sysctl func sysctl(*uint32, uint32, *byte, *uintptr, *byte, uintptr) int32 func getncpu() int32 { diff --git a/libgo/go/runtime/signal_gccgo.go b/libgo/go/runtime/signal_gccgo.go index c555712..2eece68 100644 --- a/libgo/go/runtime/signal_gccgo.go +++ b/libgo/go/runtime/signal_gccgo.go @@ -14,44 +14,44 @@ import ( // these are written in OS-specific files and in assembler. //go:noescape -//extern sigaction +//extern-sysinfo sigaction func sigaction(signum uint32, act *_sigaction, oact *_sigaction) int32 //go:noescape -//extern sigprocmask +//extern-sysinfo sigprocmask func sigprocmask(how int32, set *sigset, oldset *sigset) int32 //go:noescape -//extern sigfillset +//extern-sysinfo sigfillset func sigfillset(set *sigset) int32 //go:noescape -//extern sigemptyset +//extern-sysinfo sigemptyset func sigemptyset(set *sigset) int32 //go:noescape -//extern sigaddset +//extern-sysinfo sigaddset func c_sigaddset(set *sigset, signum uint32) int32 //go:noescape -//extern sigdelset +//extern-sysinfo sigdelset func c_sigdelset(set *sigset, signum uint32) int32 //go:noescape -//extern sigaltstack +//extern-sysinfo sigaltstack func sigaltstack(ss *_stack_t, oss *_stack_t) int32 -//extern raise +//extern-sysinfo raise func raise(sig uint32) int32 -//extern getpid +//extern-sysinfo getpid func getpid() _pid_t -//extern kill +//extern-sysinfo kill func kill(pid _pid_t, sig uint32) int32 //go:noescape -//extern setitimer +//extern-sysinfo setitimer func setitimer(which int32, new *_itimerval, old *_itimerval) int32 type sigctxt struct { diff --git a/libgo/go/runtime/stubs2.go b/libgo/go/runtime/stubs2.go index 454afee..0aaed29 100644 --- a/libgo/go/runtime/stubs2.go +++ b/libgo/go/runtime/stubs2.go @@ -17,7 +17,7 @@ func read(fd int32, p unsafe.Pointer, n int32) int32 func closefd(fd int32) int32 -//extern exit +//extern-sysinfo exit func exit(code int32) func usleep(usec uint32) diff --git a/libgo/go/syscall/mksyscall.awk b/libgo/go/syscall/mksyscall.awk index 50802d9..5f46727 100644 --- a/libgo/go/syscall/mksyscall.awk +++ b/libgo/go/syscall/mksyscall.awk @@ -28,7 +28,7 @@ # type, without a name. BEGIN { - print "// This file was automatically generated by mksyscall.awk" + print "// Code generated by mksyscall.awk. DO NOT EDIT." print "" print "package syscall" print "" @@ -99,7 +99,7 @@ BEGIN { if (!(cfnname in cfns)) { cfns[cfnname] = 1 printf("//go:noescape\n") - printf("//extern %s\n", cfnname) + printf("//extern-sysinfo %s\n", cfnname) printf("func c_%s(%s) %s\n", cfnname, cfnparams, cfnresult) } printf("func %s(%s) %s%s%s%s{\n", |