1
0
mirror of https://github.com/golang/go synced 2024-11-23 07:20:06 -07:00

cmd/link: allow buildmode c-archive for aix/ppc64

Change-Id: Ia268b0d64dc89866aa09bfffcaa109741088a904
Reviewed-on: https://go-review.googlesource.com/c/go/+/169119
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Clément Chigot 2019-03-25 10:33:49 +01:00 committed by Ian Lance Taylor
parent f7f4eef385
commit 697f4183e6
3 changed files with 14 additions and 3 deletions

View File

@ -51,7 +51,7 @@ func (mode *BuildMode) Set(s string) error {
*mode = BuildModePIE
case "c-archive":
switch objabi.GOOS {
case "darwin", "linux":
case "aix", "darwin", "linux":
case "freebsd":
switch objabi.GOARCH {
case "amd64":

View File

@ -1000,7 +1000,7 @@ func dosymtype(ctxt *Link) {
for _, s := range ctxt.Syms.Allsym {
// Create a new entry in the .init_array section that points to the
// library initializer function.
if s.Name == *flagEntrySymbol {
if s.Name == *flagEntrySymbol && ctxt.HeadType != objabi.Haix {
addinitarrdata(ctxt, s)
}
}
@ -1380,6 +1380,13 @@ func (ctxt *Link) dodata() {
case BuildModeCArchive, BuildModeCShared, BuildModeShared, BuildModePlugin:
hasinitarr = true
}
if ctxt.HeadType == objabi.Haix {
if len(data[sym.SINITARR]) > 0 {
Errorf(nil, "XCOFF format doesn't allow .init_array section")
}
}
if hasinitarr && len(data[sym.SINITARR]) > 0 {
sect := addsection(ctxt.Arch, &Segdata, ".init_array", 06)
sect.Align = dataMaxAlign[sym.SINITARR]

View File

@ -1102,7 +1102,11 @@ func (ctxt *Link) archive() {
}
ctxt.Out.f = nil
argv := []string{*flagExtar, "-q", "-c", "-s", *flagOutfile}
argv := []string{*flagExtar, "-q", "-c", "-s"}
if ctxt.HeadType == objabi.Haix {
argv = append(argv, "-X64")
}
argv = append(argv, *flagOutfile)
argv = append(argv, filepath.Join(*flagTmpdir, "go.o"))
argv = append(argv, hostobjCopy()...)