]> Cypherpunks.ru repositories - gostls13.git/commit
all: use ":" for compiler generated symbols
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Fri, 7 May 2021 17:45:06 +0000 (00:45 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 9 Aug 2022 11:28:56 +0000 (11:28 +0000)
commit0f8dffd0aa71ed996d32e77701ac5ec0bc7cde01
tree9840e8c7e2abac7674a9dfaa6b0c73655124f0fa
parent5639fcae7fee2cf04c1b87e9a81155ee3bb6ed71
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>
37 files changed:
misc/cgo/testshared/shared_test.go
src/cmd/compile/internal/base/link.go
src/cmd/compile/internal/dwarfgen/dwarf.go
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/gc/obj.go
src/cmd/compile/internal/ir/expr.go
src/cmd/compile/internal/noder/import.go
src/cmd/compile/internal/ppc64/ssa.go
src/cmd/compile/internal/reflectdata/reflect.go
src/cmd/compile/internal/staticdata/data.go
src/cmd/internal/dwarf/dwarf.go
src/cmd/internal/goobj/builtinlist.go
src/cmd/internal/goobj/mkbuiltin.go
src/cmd/internal/obj/objfile.go
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/ld/deadcode.go
src/cmd/link/internal/ld/deadcode_test.go
src/cmd/link/internal/ld/dwarf.go
src/cmd/link/internal/ld/elf.go
src/cmd/link/internal/ld/go.go
src/cmd/link/internal/ld/ld.go
src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/ld/macho.go
src/cmd/link/internal/ld/pcln.go
src/cmd/link/internal/ld/pe.go
src/cmd/link/internal/ld/symtab.go
src/cmd/link/internal/ld/xcoff.go
src/cmd/link/internal/loader/loader.go
src/cmd/link/internal/loader/loader_test.go
src/cmd/link/internal/wasm/asm.go
src/crypto/tls/link_test.go
src/debug/gosym/pclntab.go
src/debug/gosym/symtab.go
src/debug/gosym/symtab_test.go
src/runtime/symtab.go
test/codegen/strings.go
test/fixedbugs/issue29312.go