mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: always read type data for dynimport symbols
Consider three shared libraries: libBase.so -- defines a type T lib2.so -- references type T lib3.so -- also references type T, and something from lib2 lib2.so will contain a type symbol for T in its symbol table, but no definition. If, when linking lib3.so the linker reads the symbols from lib2.so before libBase.so, the linker didn't read the type data and later crashed. The fix is trivial but the test change is a bit messy because the order the linker reads the shared libraries in ends up depending on the order of the import statements in the file so I had to rename one of the test packages so that gofmt doesn't fix the test by accident... Fixes #15516 Change-Id: I124b058f782c900a3a54c15ed66a0d91d0cde5ce Reviewed-on: https://go-review.googlesource.com/22744 Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
ba6765c237
commit
2f41edf120
10 changed files with 92 additions and 46 deletions
|
|
@ -1522,9 +1522,10 @@ func ldshlibsyms(shlib string) {
|
|||
}
|
||||
lsym := Linklookup(Ctxt, elfsym.Name, 0)
|
||||
// Because loadlib above loads all .a files before loading any shared
|
||||
// libraries, any symbols we find that duplicate symbols already
|
||||
// loaded should be ignored (the symbols from the .a files "win").
|
||||
if lsym.Type != 0 {
|
||||
// libraries, any non-dynimport symbols we find that duplicate symbols
|
||||
// already loaded should be ignored (the symbols from the .a files
|
||||
// "win").
|
||||
if lsym.Type != 0 && lsym.Type != obj.SDYNIMPORT {
|
||||
continue
|
||||
}
|
||||
lsym.Type = obj.SDYNIMPORT
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue