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/runtime | |
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/runtime')
-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 |
5 files changed, 20 insertions, 20 deletions
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) |