mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd, runtime: fix C trampolines on aix/ppc64
C trampolines are made by fixup CSECTS which are added between two symbols. If such CSECTS is added inside Go functions, all method offsets stored in moduledatas will be wrong. In order to prevent this, every C code is moved at the end of the executable and long calls are created for GO functions called by C code. The main function can't longer be made in Go as AIX __start isn't using a long call to branch on it. Therefore, a main is defined on runtime/cgo. Change-Id: I214b18decdb83107cf7325b298609eef9f9d1330 Reviewed-on: https://go-review.googlesource.com/c/go/+/164010 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
ca36af215f
commit
0cd74d1f11
8 changed files with 85 additions and 6 deletions
|
|
@ -1288,6 +1288,25 @@ func (ctxt *Link) hostlink() {
|
|||
|
||||
argv = append(argv, filepath.Join(*flagTmpdir, "go.o"))
|
||||
argv = append(argv, hostobjCopy()...)
|
||||
if ctxt.HeadType == objabi.Haix {
|
||||
// We want to have C files after Go files to remove
|
||||
// trampolines csects made by ld.
|
||||
argv = append(argv, "-nostartfiles")
|
||||
argv = append(argv, "/lib/crt0_64.o")
|
||||
|
||||
extld := ctxt.extld()
|
||||
// Get starting files.
|
||||
getPathFile := func(file string) string {
|
||||
args := []string{"-maix64", "--print-file-name=" + file}
|
||||
out, err := exec.Command(extld, args...).CombinedOutput()
|
||||
if err != nil {
|
||||
log.Fatalf("running %s failed: %v\n%s", extld, err, out)
|
||||
}
|
||||
return strings.Trim(string(out), "\n")
|
||||
}
|
||||
argv = append(argv, getPathFile("crtcxa.o"))
|
||||
argv = append(argv, getPathFile("crtdbase.o"))
|
||||
}
|
||||
|
||||
if ctxt.linkShared {
|
||||
seenDirs := make(map[string]bool)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue