]> Cypherpunks repositories - gostls13.git/commit
cmd/link/internal/ld: emit better complex types for COFF symbols
authorqmuntal <quimmuntal@gmail.com>
Mon, 13 Mar 2023 14:10:59 +0000 (15:10 +0100)
committerQuim Muntal <quimmuntal@gmail.com>
Mon, 20 Mar 2023 17:59:01 +0000 (17:59 +0000)
commit6e57ecdb03fba66007e081c7d5fce99d39d9fab8
treeb6b83b42c23262bfa074755a4dbb395fe0ec3776
parentda4687923b8c2d42c23f61fa3db9f4d3ce0c5f54
cmd/link/internal/ld: emit better complex types for COFF symbols

The Go linker has always used IMAGE_SYM_TYPE_NULL as COFF symbol
type [1] when external linking and array of structs
(IMAGE_SYM_DTYPE_ARRAY<<4+IMAGE_SYM_TYPE_STRUCT) when internal linking.
This behavior seems idiosyncratic, and looking at the git history it
seems that it has probably been cargo culted from earlier toolchains.

This CL updates the Go linker to use IMAGE_SYM_DTYPE_FUNCTION<<4 for
those symbols representing functions, and IMAGE_SYM_TYPE_NULL otherwise.

This new behavior better represents the symbol types, and can help
other tools interpreting the intent of each symbol, e.g. debuggers or
tools extracting debug info from Go binaries. It also mimics what other
toolchains do, i.e. MSVC, LLVM, and GCC.

[1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#type-representation

Change-Id: I6b39b2048e95f0324b2eb90c85802ce42db455d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/475856
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
src/cmd/link/internal/ld/pe.go