Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/link: dwarf code badly confused by repeated local symbols #21566
When using -linkmode=internal, the linker's DWARF code gets badly confused if there are local (file-static) symbols in multiple objects with the same name. It creates a symbol go.info.name for each, but without distinct version numbers or any other distinguishing information. Then the code that walks the real symbols and builds a list of DWARF symbols puts the same DWARF symbol onto the list twice. Then the code that assigns DWARF symbols to sections gets confused because it stops when it finds a non-SDWARFINFO symbol, and when it reaches the second instance of a symbol, that symbol has already been converted to SRODATA, so the loop stops prematurely. That in turn causes missing DWARF info.
This only happens with internal linking, and nothing in the standard library happens to link against any code that tickles the bug today, but it certainly could in the future. I ran into this trying to use internal linking with BoringCrypto (much larger than our glibc cgo code).
The last time the linker correctly handled this situation (probably by not trying to collect that DWARF info at all) was Go 1.6.
On dev.boringcrypto I will just skip over the duplicates, which works well enough, but it's not the right fix:
I took a flying leap at this and moved the