1
0
mirror of https://github.com/golang/go synced 2024-11-05 17:46:16 -07:00
go/misc/cgo
Cuong Manh Le 0f8dffd0aa all: use ":" for compiler generated symbols
As it can't appear in user package paths.

There is a hack for handling "go:buildid" and "type:*" on windows/386.

Previously, windows/386 requires underscore prefix on external symbols,
but that's only applied for SHOSTOBJ/SUNDEFEXT or cgo export symbols.
"go.buildid" is STEXT, "type.*" is STYPE, thus they are not prefixed
with underscore.

In external linking mode, the external linker can't resolve them as
external symbols. But we are lucky that they have "." in their name,
so the external linker see them as Forwarder RVA exports. See:

 - https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#export-address-table
 - https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/pe-dll.c;h=e7b82ba6ffadf74dc1b9ee71dc13d48336941e51;hb=HEAD#l972)

This CL changes "." to ":" in symbols name, so theses symbols can not be
found by external linker anymore. So a hacky way is adding the
underscore prefix for these 2 symbols. I don't have enough knowledge to
verify whether adding the underscore for all STEXT/STYPE symbols are
fine, even if it could be, that would be done in future CL.

Fixes #37762

Change-Id: I92eaaf24c0820926a36e0530fdb07b07af1fcc35
Reviewed-on: https://go-review.googlesource.com/c/go/+/317917
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-09 11:28:56 +00:00
..
errors cmd/go: prepend builtin prolog when checking for preamble errors 2022-06-25 19:07:01 +00:00
fortran
gmp all: gofmt main repo 2022-04-11 16:34:30 +00:00
life all: update references to symbols moved from io/ioutil to io 2021-04-05 17:51:15 +00:00
nocgo
stdio all: update references to symbols moved from io/ioutil to io 2021-04-05 17:51:15 +00:00
test all: disable tests that fail on Alpine 2022-08-02 17:23:42 +00:00
testasan
testcarchive all: disable tests that fail on Alpine 2022-08-02 17:23:42 +00:00
testcshared all: disable tests that fail on Alpine 2022-08-02 17:23:42 +00:00
testgodefs cmd/cgo: retain original file paths in godefs generated comment 2022-04-03 07:18:10 +00:00
testplugin cmd/compile: make jump table symbol local 2022-07-22 20:12:19 +00:00
testsanitizers misc/cgo/testsanitizers: buffer the signal channel in TestTSAN/tsan11 2022-05-27 15:58:52 +00:00
testshared all: use ":" for compiler generated symbols 2022-08-09 11:28:56 +00:00
testsigfwd
testso all: gofmt more (but vendor, testdata, and top-level test directories) 2021-08-13 20:45:17 +00:00
testsovar all: gofmt more (but vendor, testdata, and top-level test directories) 2021-08-13 20:45:17 +00:00
testtls all: gofmt more (but vendor, testdata, and top-level test directories) 2021-08-13 20:45:17 +00:00