Skip to content

Commit 697f418

Browse files
Clément Chigotianlancetaylor
Clément Chigot
authored andcommitted
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 <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent f7f4eef commit 697f418

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/cmd/link/internal/ld/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (mode *BuildMode) Set(s string) error {
5151
*mode = BuildModePIE
5252
case "c-archive":
5353
switch objabi.GOOS {
54-
case "darwin", "linux":
54+
case "aix", "darwin", "linux":
5555
case "freebsd":
5656
switch objabi.GOARCH {
5757
case "amd64":

src/cmd/link/internal/ld/data.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ func dosymtype(ctxt *Link) {
10001000
for _, s := range ctxt.Syms.Allsym {
10011001
// Create a new entry in the .init_array section that points to the
10021002
// library initializer function.
1003-
if s.Name == *flagEntrySymbol {
1003+
if s.Name == *flagEntrySymbol && ctxt.HeadType != objabi.Haix {
10041004
addinitarrdata(ctxt, s)
10051005
}
10061006
}
@@ -1380,6 +1380,13 @@ func (ctxt *Link) dodata() {
13801380
case BuildModeCArchive, BuildModeCShared, BuildModeShared, BuildModePlugin:
13811381
hasinitarr = true
13821382
}
1383+
1384+
if ctxt.HeadType == objabi.Haix {
1385+
if len(data[sym.SINITARR]) > 0 {
1386+
Errorf(nil, "XCOFF format doesn't allow .init_array section")
1387+
}
1388+
}
1389+
13831390
if hasinitarr && len(data[sym.SINITARR]) > 0 {
13841391
sect := addsection(ctxt.Arch, &Segdata, ".init_array", 06)
13851392
sect.Align = dataMaxAlign[sym.SINITARR]

src/cmd/link/internal/ld/lib.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,11 @@ func (ctxt *Link) archive() {
11021102
}
11031103
ctxt.Out.f = nil
11041104

1105-
argv := []string{*flagExtar, "-q", "-c", "-s", *flagOutfile}
1105+
argv := []string{*flagExtar, "-q", "-c", "-s"}
1106+
if ctxt.HeadType == objabi.Haix {
1107+
argv = append(argv, "-X64")
1108+
}
1109+
argv = append(argv, *flagOutfile)
11061110
argv = append(argv, filepath.Join(*flagTmpdir, "go.o"))
11071111
argv = append(argv, hostobjCopy()...)
11081112

0 commit comments

Comments
 (0)