cmd/go, cmd/ld: fix libgcc order and add __image_base__ symbol for windows

Fixes #4063.

R=alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/6543066
This commit is contained in:
Shenghou Ma 2012-09-26 22:34:25 +08:00
parent e80fccb441
commit 5490814c30
3 changed files with 12 additions and 7 deletions

View File

@ -1597,9 +1597,12 @@ func (b *builder) cgo(p *Package, cgoExe, obj string, gccfiles []string) (outGo,
if err != nil {
return nil, nil, err
}
staticLibs := []string{libgcc}
var staticLibs []string
if goos == "windows" {
staticLibs = append(staticLibs, "-lmingwex", "-lmingw32")
// libmingw32 and libmingwex might also use libgcc, so libgcc must come last
staticLibs = []string{"-lmingwex", "-lmingw32", libgcc}
} else {
staticLibs = []string{libgcc}
}
for _, cfile := range cfiles {

View File

@ -148,6 +148,9 @@ peinit(void)
PESECTHEADR = rnd(PEFILEHEADR, PESECTALIGN);
nextsectoff = PESECTHEADR;
nextfileoff = PEFILEHEADR;
// some mingw libs depend on this symbol, for example, FindPESectionByName
xdefine("__image_base__", SDATA, PEBASE);
}
static void

View File

@ -64,11 +64,10 @@ echo.
:: cgo tests
if x%CGO_ENABLED% == x0 goto nocgo
:: TODO(brainman) disabled, because it is broken on go builder - http://golang.org/issue/4063
::echo # ..\misc\cgo\life
::go run %GOROOT%\test\run.go - ..\misc\cgo\life
::if errorlevel 1 goto fail
::echo.
echo # ..\misc\cgo\life
go run %GOROOT%\test\run.go - ..\misc\cgo\life
if errorlevel 1 goto fail
echo.
echo # ..\misc\cgo\stdio
go run %GOROOT%\test\run.go - ..\misc\cgo\stdio