GOPATH=$(pwd) go build iface
LD_LIBRARY_PATH=$(pwd) ./iface
+function _timeout() (
+ set -e
+ $2 &
+ p=$!
+ (sleep $1; kill $p 2>/dev/null) &
+ p2=$!
+ wait $p 2>/dev/null
+ kill -0 $p2 2>/dev/null
+)
+
# Test for issue 18676 - make sure we don't add the same itab twice.
# The buggy code hangs forever, so use a timeout to check for that.
GOPATH=$(pwd) go build -buildmode=plugin -o plugin.so src/issue18676/plugin.go
GOPATH=$(pwd) go build -o issue18676 src/issue18676/main.go
-timeout 10s ./issue18676
+_timeout 10 ./issue18676
# Test for issue 19534 - that we can load a plugin built in a path with non-alpha
# characters
switch pair {
case "linux-386", "linux-amd64", "linux-arm", "linux-s390x":
return true
+ case "darwin-amd64":
+ return true
}
return false
default:
switch platform {
case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x",
"android/amd64", "android/arm", "android/arm64", "android/386":
+ case "darwin/amd64":
+ // Skip DWARF generation due to #21647
+ cfg.BuildLdflags = append(cfg.BuildLdflags, "-w")
default:
base.Fatalf("-buildmode=plugin not supported on %s\n", platform)
}
package ld
import (
+ "cmd/internal/objabi"
"cmd/internal/sys"
"sort"
"strings"
if !ctxt.DynlinkingGo() || s.Attr.Local() {
return false
}
- if Buildmode == BuildmodePlugin && strings.HasPrefix(s.Extname, *flagPluginPath) {
+ if Buildmode == BuildmodePlugin && strings.HasPrefix(s.Extname, objabi.PathToPrefix(*flagPluginPath)) {
+ return true
+ }
+ if strings.HasPrefix(s.Name, "go.itab.") {
return true
}
if strings.HasPrefix(s.Name, "type.") && !strings.HasPrefix(s.Name, "type..") {
// ftab is lookup table for function by program counter.
nftab := len(datap.ftab) - 1
- var pcCache pcvalueCache
for i := 0; i < nftab; i++ {
// NOTE: ftab[nftab].entry is legal; it is the address beyond the final function.
if datap.ftab[i].entry > datap.ftab[i+1].entry {
}
throw("invalid runtime symbol table")
}
-
- if debugPcln || nftab-i < 5 {
- // Check a PC near but not at the very end.
- // The very end might be just padding that is not covered by the tables.
- // No architecture rounds function entries to more than 16 bytes,
- // but if one came along we'd need to subtract more here.
- // But don't use the next PC if it corresponds to a foreign object chunk
- // (no pcln table, f2.pcln == 0). That chunk might have an alignment
- // more than 16 bytes.
- f := funcInfo{(*_func)(unsafe.Pointer(&datap.pclntable[datap.ftab[i].funcoff])), datap}
- end := f.entry
- if i+1 < nftab {
- f2 := funcInfo{(*_func)(unsafe.Pointer(&datap.pclntable[datap.ftab[i+1].funcoff])), datap}
- if f2.pcln != 0 {
- end = f2.entry - 16
- if end < f.entry {
- end = f.entry
- }
- }
- }
- pcvalue(f, f.pcfile, end, &pcCache, true)
- pcvalue(f, f.pcln, end, &pcCache, true)
- pcvalue(f, f.pcsp, end, &pcCache, true)
- }
}
if datap.minpc != datap.ftab[0].entry ||