-
Notifications
You must be signed in to change notification settings - Fork 17.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/link: load symbols from .syso in external link mode
Fix linking with a package having a .syso file in external link mode, that would otherwise cause an error before executing the external linker because it can't find symbols that are exported in the said .syso file. Fixes #33139
- Loading branch information
Showing
2 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Test that we can link a syso file that is embedded in a package, that is | ||
# referenced by an assembly stub. See issue 33139. | ||
# | ||
# We use cgo only to enforce external linkage of the main executable. | ||
[!cgo] stop | ||
[!gc] stop | ||
[linux] cc -c -o syso/test.syso syso/asm/test_linux.s | ||
[darwin] cc -c -o syso/test.syso syso/asm/test_darwin.s | ||
go build ./cmd/main.go | ||
|
||
-- syso/test.s -- | ||
#include "textflag.h" | ||
|
||
TEXT ·Test(SB), NOSPLIT, $0 | ||
JMP asmTest(SB) | ||
|
||
-- syso/test.go -- | ||
package syso | ||
|
||
func Test() | ||
|
||
-- syso/asm/test_linux.s -- | ||
.globl asmTest | ||
asmTest: | ||
ret | ||
|
||
-- syso/asm/test_darwin.s -- | ||
.globl _asmTest | ||
_asmTest: | ||
ret | ||
|
||
-- cmd/main.go -- | ||
package main | ||
|
||
/* | ||
// Force use of external linker | ||
#include <stdio.h> | ||
*/ | ||
import "C" | ||
|
||
import ( | ||
"syso" | ||
) | ||
|
||
func main() { | ||
syso.Test() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters