mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/go: fix -buildmode=c-archive should work on windows
Add supporting code for runtime initialization, including both 32- and 64-bit x86 architectures. Add .ctors section on Windows to PE .o files, and INITENTRY to .ctors section to plug in to the GCC C/C++ startup initialization mechanism. This allows the Go runtime to initialize itself. Add .text section symbol for .ctor relocations. Note: This is unlikely to be useful for MSVC-based toolchains. Fixes #13494 Change-Id: I4286a96f70e5f5228acae88eef46e2bed95813f3 Reviewed-on: https://go-review.googlesource.com/18057 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
386c0e6598
commit
ed8f0e5c33
10 changed files with 248 additions and 18 deletions
|
|
@ -324,6 +324,12 @@ func (mode *BuildMode) Set(s string) error {
|
|||
case "c-archive":
|
||||
switch goos {
|
||||
case "darwin", "linux":
|
||||
case "windows":
|
||||
switch goarch {
|
||||
case "amd64", "386":
|
||||
default:
|
||||
return badmode()
|
||||
}
|
||||
default:
|
||||
return badmode()
|
||||
}
|
||||
|
|
@ -1020,6 +1026,15 @@ func archive() {
|
|||
}
|
||||
|
||||
mayberemoveoutfile()
|
||||
|
||||
// Force the buffer to flush here so that external
|
||||
// tools will see a complete file.
|
||||
Cflush()
|
||||
if err := coutbuf.f.Close(); err != nil {
|
||||
Exitf("close: %v", err)
|
||||
}
|
||||
coutbuf.f = nil
|
||||
|
||||
argv := []string{extar, "-q", "-c", "-s", outfile}
|
||||
argv = append(argv, filepath.Join(tmpdir, "go.o"))
|
||||
argv = append(argv, hostobjCopy()...)
|
||||
|
|
@ -1890,7 +1905,6 @@ func genasmsym(put func(*LSym, string, int, int64, int64, int, *LSym)) {
|
|||
// These symbols won't show up in the first loop below because we
|
||||
// skip STEXT symbols. Normal STEXT symbols are emitted by walking textp.
|
||||
s := Linklookup(Ctxt, "runtime.text", 0)
|
||||
|
||||
if s.Type == obj.STEXT {
|
||||
put(s, s.Name, 'T', s.Value, s.Size, int(s.Version), nil)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue