mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: fix bug in -strictdups checking of BSS symbols
The linker's -strictdups debugging option was not properly checking for cases where you have two dupok BSS symbols with different length (the check examined data length and content, but not symbol size). Updates #46653. Change-Id: I3844f25ef76dd6e4a84ffd5caed5d19a1b1a57c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/326210 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
bcecae2af6
commit
07ca28d529
2 changed files with 41 additions and 14 deletions
|
|
@ -699,12 +699,18 @@ func (l *Loader) checkdup(name string, r *oReader, li uint32, dup Sym) {
|
|||
p := r.Data(li)
|
||||
rdup, ldup := l.toLocal(dup)
|
||||
pdup := rdup.Data(ldup)
|
||||
if bytes.Equal(p, pdup) {
|
||||
return
|
||||
}
|
||||
reason := "same length but different contents"
|
||||
if len(p) != len(pdup) {
|
||||
reason = fmt.Sprintf("new length %d != old length %d", len(p), len(pdup))
|
||||
} else if bytes.Equal(p, pdup) {
|
||||
// For BSS symbols, we need to check size as well, see issue 46653.
|
||||
szdup := l.SymSize(dup)
|
||||
sz := int64(r.Sym(li).Siz())
|
||||
if szdup == sz {
|
||||
return
|
||||
}
|
||||
reason = fmt.Sprintf("different sizes: new size %d != old size %d",
|
||||
sz, szdup)
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "cmd/link: while reading object for '%v': duplicate symbol '%s', previous def at '%v', with mismatched payload: %s\n", r.unit.Lib, name, rdup.unit.Lib, reason)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue