mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.link] cmd/link: allow either of duplicated symbols being dupok
If two symbols have the same name, the old code allows either one being dupok (preferably both, but either is ok). Currently, the new code only works when the new symbol being dupok (or both). Allow only old symbol being dupok as well. One example for this is the tls_g variable on ARM64 and PPC64 when the race detector is enabled. Should fix Linux/ARM64 build. Change-Id: I8dd21c017e826847f13471c30dfd71bf225d8076 Reviewed-on: https://go-review.googlesource.com/c/go/+/201642 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
c3459eaab0
commit
5777ffd6e6
1 changed files with 7 additions and 4 deletions
|
|
@ -152,14 +152,17 @@ func (l *Loader) AddSym(name string, ver int, i Sym, r *oReader, dupok bool, typ
|
|||
if dupok {
|
||||
return false
|
||||
}
|
||||
oldr, li := l.toLocal(oldi)
|
||||
oldsym := goobj2.Sym{}
|
||||
oldsym.Read(oldr.Reader, oldr.SymOff(li))
|
||||
if oldsym.Dupok() {
|
||||
return false
|
||||
}
|
||||
overwrite := r.DataSize(int(i-l.startIndex(r))) != 0
|
||||
if overwrite {
|
||||
// new symbol overwrites old symbol.
|
||||
oldr, li := l.toLocal(oldi)
|
||||
oldsym := goobj2.Sym{}
|
||||
oldsym.Read(oldr.Reader, oldr.SymOff(li))
|
||||
oldtyp := sym.AbiSymKindToSymKind[objabi.SymKind(oldsym.Type)]
|
||||
if !oldsym.Dupok() && !((oldtyp == sym.SDATA || oldtyp == sym.SNOPTRDATA || oldtyp == sym.SBSS || oldtyp == sym.SNOPTRBSS) && oldr.DataSize(li) == 0) { // only allow overwriting 0-sized data symbol
|
||||
if !((oldtyp == sym.SDATA || oldtyp == sym.SNOPTRDATA || oldtyp == sym.SBSS || oldtyp == sym.SNOPTRBSS) && oldr.DataSize(li) == 0) { // only allow overwriting 0-sized data symbol
|
||||
log.Fatalf("duplicated definition of symbol " + name)
|
||||
}
|
||||
l.overwrite[oldi] = i
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue