Tested by running
GOTRACEBACK=2 CGO_CFLAGS="-Wa,--elf-stt-common=yes" go test -ldflags=-linkmode=internal
in misc/cgo/test. That failed before this CL, succeeded after.
I don't think it's worth doing that as a regular test, though,
especially since only recent versions of the GNU binutils support the
--elf-stt-common option.
Fixes #18088.
Change-Id: I893d86181faee217b1504c054b0ed3f7c8d977d3
Reviewed-on: https://go-review.googlesource.com/33653
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
ElfSymTypeFunc = 2
ElfSymTypeSection = 3
ElfSymTypeFile = 4
+ ElfSymTypeCommon = 5
+ ElfSymTypeTLS = 6
)
const (
goto bad
}
symbols[i] = sym.sym
- if sym.type_ != ElfSymTypeFunc && sym.type_ != ElfSymTypeObject && sym.type_ != ElfSymTypeNone {
+ if sym.type_ != ElfSymTypeFunc && sym.type_ != ElfSymTypeObject && sym.type_ != ElfSymTypeNone && sym.type_ != ElfSymTypeCommon {
continue
}
- if sym.shndx == ElfSymShnCommon {
+ if sym.shndx == ElfSymShnCommon || sym.type_ == ElfSymTypeCommon {
s = sym.sym
if uint64(s.Size) < sym.size {
s.Size = int64(sym.size)
case ElfSymTypeSection:
s = elfobj.sect[sym.shndx].sym
- case ElfSymTypeObject, ElfSymTypeFunc, ElfSymTypeNone:
+ case ElfSymTypeObject, ElfSymTypeFunc, ElfSymTypeNone, ElfSymTypeCommon:
switch sym.bind {
case ElfSymBindGlobal:
if needSym != 0 {