-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Closed
Copy link
Labels
Description
On Linux:
mwhudson@narsil:go-test-cases$ cat trivial.go
package main
func main() {
}
mwhudson@narsil:go-test-cases$ go build trivial.go
mwhudson@narsil:go-test-cases$ nm trivial | grep -F runtime.main.f
0000000000470e90 R runtime.main.f
0000000000470e98 R runtime.main.f
This is because the linker normalizes middle dots to periods. The source of the two symbols:
- The runtime package defines a variable called runtime·main·f (in asm_$GOARCH.s)
- As with all functions, the compiler creates a symbol called "".main·f to support indirect calls to runtime.main, which is read by the linker as runtime.main·f
This doesn't really cause problems today because the collision happens so late in the writing process, when you're executing an elf binary nothing really cares about the symbol names. It's a problem when you want to do dynamic linking stuff though, because the symbol names start mattering again.
It feels like these two symbols are actually meant to be the same, but I don't know how to make that happen. The simplest fix would be to make the names different enough to not collide in the symbol table.