]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix addmoduledata to follow the platform ABI
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Mon, 11 May 2015 23:59:14 +0000 (11:59 +1200)
committerIan Lance Taylor <iant@golang.org>
Tue, 12 May 2015 00:50:32 +0000 (00:50 +0000)
addmoduledata is called from a .init_array function and need to follow the
platform ABI. It contains accesses to global data which are rewritten to use
R15 by the assembler, and as R15 is callee-save we need to save it.

Change-Id: I03893efb1576aed4f102f2465421f256f3bb0f30
Reviewed-on: https://go-review.googlesource.com/9941
Reviewed-by: Ian Lance Taylor <iant@golang.org>
misc/cgo/testshared/test.bash
src/runtime/asm_amd64.s

index 21004adaf87cb9ca11235b8af3b576d9b68945ee..0b0d0411f7a8276b279c2a49756450143f91bf85 100755 (executable)
@@ -78,6 +78,7 @@ ensure_ldd $rootdir/libdep.so $std_install_dir/$soname
 
 # And exe that links against both
 go install -installsuffix="$mysuffix" -linkshared exe
+./bin/exe || die "./bin/exe failed with code $?"
 ensure_ldd ./bin/exe $rootdir/libdep.so
 ensure_ldd ./bin/exe $std_install_dir/$soname
 
index 36353d108f0c59f87d9ad3186b33abe8774f4ab6..0f9aeb8f370b0be8bea2bf8db65ab94402d0d016 100644 (file)
@@ -1693,8 +1693,10 @@ TEXT runtime·prefetchnta(SB),NOSPLIT,$0-8
        RET
 
 // This is called from .init_array and follows the platform, not Go, ABI.
-TEXT runtime·addmoduledata(SB),NOSPLIT,$0-8
+TEXT runtime·addmoduledata(SB),NOSPLIT,$0-0
+       PUSHQ   R15 // The access to global variables below implicitly uses R15, which is callee-save
        MOVQ    runtime·lastmoduledatap(SB), AX
        MOVQ    DI, moduledata_next(AX)
        MOVQ    DI, runtime·lastmoduledatap(SB)
+       POPQ    R15
        RET