diff options
| author | Russ Cox <rsc@golang.org> | 2013-03-07 09:19:02 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2013-03-07 09:19:02 -0500 |
| commit | 60f783d92bc07fa7ca78e8efccbbc841d9f9cbcb (patch) | |
| tree | 8677601561fbb007429777514911480aa4c871fd /src/cmd/ld/symtab.c | |
| parent | 8aafb44b0bbba85535feb67e7ae0f4f254524c0f (diff) | |
| download | go-60f783d92bc07fa7ca78e8efccbbc841d9f9cbcb.tar.xz | |
cmd/ld: host linking support for linux/amd64
Still to do: non-linux and non-amd64.
It may work on other ELF-based amd64 systems too, but untested.
"go test -ldflags -hostobj $GOROOT/misc/cgo/test" passes.
Much may yet change, but this seems a reasonable checkpoint.
R=iant
CC=golang-dev
https://golang.org/cl/7369057
Diffstat (limited to 'src/cmd/ld/symtab.c')
| -rw-r--r-- | src/cmd/ld/symtab.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/cmd/ld/symtab.c b/src/cmd/ld/symtab.c index 89a594872e..d8b8b93289 100644 --- a/src/cmd/ld/symtab.c +++ b/src/cmd/ld/symtab.c @@ -121,7 +121,17 @@ putelfsym(Sym *x, char *s, int t, vlong addr, vlong size, int ver, Sym *go) // One pass for each binding: STB_LOCAL, STB_GLOBAL, // maybe one day STB_WEAK. - bind = (ver || (x->type & SHIDDEN)) ? STB_LOCAL : STB_GLOBAL; + bind = STB_GLOBAL; + if(ver || (x->type & SHIDDEN)) + bind = STB_LOCAL; + + // In external linking mode, we have to invoke gcc with -rdynamic + // to get the exported symbols put into the dynamic symbol table. + // To avoid filling the dynamic table with lots of unnecessary symbols, + // mark all Go symbols local (not global) in the final executable. + if(linkmode == LinkExternal && !(x->cgoexport&CgoExportStatic)) + bind = STB_LOCAL; + if(bind != elfbind) return; |
