Commit 960d7082 authored by Shenghou Ma's avatar Shenghou Ma

cmd/ld, runtime/cgo: allow a symbol to be both cgo_export and cgo_import.

Fixes #4878.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7420052
parent 72dd0145
......@@ -499,11 +499,16 @@ loadcgo(char *file, char *pkg, char *p, int n)
remote = local;
local = expandpkg(local, pkg);
s = lookup(local, 0);
// export overrides import, for openbsd/cgo.
// see issue 4878.
if(s->dynimplib != nil) {
fprint(2, "%s: symbol is both imported and exported: %s\n", argv0, local);
nerrors++;
s->dynimplib = nil;
s->extname = nil;
s->dynimpvers = nil;
s->type = 0;
}
if(s->cgoexport == 0) {
if(strcmp(f[0], "cgo_export_static") == 0)
s->cgoexport |= CgoExportStatic;
......
......@@ -48,9 +48,9 @@ tcb_fixup(int mainthread)
bcopy(oldtcb, newtcb + TLS_SIZE, TCB_SIZE);
__set_tcb(newtcb + TLS_SIZE);
// The main thread TCB is a static allocation - do not try to free it.
if(!mainthread)
free(oldtcb);
// NOTE(jsing, minux): we can't free oldtcb without causing double-free
// problem. so newtcb will be memory leaks. Get rid of this when OpenBSD
// has proper support for PT_TLS.
}
static void *
......
......@@ -48,9 +48,9 @@ tcb_fixup(int mainthread)
bcopy(oldtcb, newtcb + TLS_SIZE, TCB_SIZE);
__set_tcb(newtcb + TLS_SIZE);
// The main thread TCB is a static allocation - do not try to free it.
if(!mainthread)
free(oldtcb);
// NOTE(jsing, minux): we can't free oldtcb without causing double-free
// problem. so newtcb will be memory leaks. Get rid of this when OpenBSD
// has proper support for PT_TLS.
}
static void *
......
......@@ -74,7 +74,6 @@ go run $GOROOT/test/run.go - .
) || exit $?
[ "$CGO_ENABLED" != 1 ] ||
[ "$GOHOSTOS" == openbsd ] || # issue 4878
(xcd ../misc/cgo/test
go test
case "$GOHOSTOS-$GOARCH" in
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment