Skip to content

Commit eec1afe

Browse files
adityasakygopherbot
authored andcommitted
debug/elf: make check for empty symbol section consistent for 64-bit and 32-bit binaries
The check for whether a binary's symbols section is empty is inconsistent across the 32-bit and 64-bit flows. Change-Id: I1abc235320a53cf957cfb83c9e7bcad6e52bc529 GitHub-Last-Rev: f264915 GitHub-Pull-Request: #75334 Reviewed-on: https://go-review.googlesource.com/c/go/+/702195 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Keith Randall <khr@google.com>
1 parent 3f94f3d commit eec1afe

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/debug/elf/file.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@ func (f *File) getSymbols32(typ SectionType) ([]Symbol, []byte, error) {
641641
return nil, nil, fmt.Errorf("cannot load symbol section: %w", err)
642642
}
643643
if len(data) == 0 {
644-
return nil, nil, errors.New("symbol section is empty")
644+
return nil, nil, ErrNoSymbols
645645
}
646646
if len(data)%Sym32Size != 0 {
647647
return nil, nil, errors.New("length of symbol section is not a multiple of SymSize")
@@ -690,12 +690,12 @@ func (f *File) getSymbols64(typ SectionType) ([]Symbol, []byte, error) {
690690
if err != nil {
691691
return nil, nil, fmt.Errorf("cannot load symbol section: %w", err)
692692
}
693-
if len(data)%Sym64Size != 0 {
694-
return nil, nil, errors.New("length of symbol section is not a multiple of Sym64Size")
695-
}
696693
if len(data) == 0 {
697694
return nil, nil, ErrNoSymbols
698695
}
696+
if len(data)%Sym64Size != 0 {
697+
return nil, nil, errors.New("length of symbol section is not a multiple of Sym64Size")
698+
}
699699

700700
strdata, err := f.stringTable(symtabSection.Link)
701701
if err != nil {

0 commit comments

Comments
 (0)