Skip to content

Commit f264915

Browse files
committed
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.
1 parent af03343 commit f264915

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
@@ -640,7 +640,7 @@ func (f *File) getSymbols32(typ SectionType) ([]Symbol, []byte, error) {
640640
return nil, nil, fmt.Errorf("cannot load symbol section: %w", err)
641641
}
642642
if len(data) == 0 {
643-
return nil, nil, errors.New("symbol section is empty")
643+
return nil, nil, ErrNoSymbols
644644
}
645645
if len(data)%Sym32Size != 0 {
646646
return nil, nil, errors.New("length of symbol section is not a multiple of SymSize")
@@ -689,12 +689,12 @@ func (f *File) getSymbols64(typ SectionType) ([]Symbol, []byte, error) {
689689
if err != nil {
690690
return nil, nil, fmt.Errorf("cannot load symbol section: %w", err)
691691
}
692-
if len(data)%Sym64Size != 0 {
693-
return nil, nil, errors.New("length of symbol section is not a multiple of Sym64Size")
694-
}
695692
if len(data) == 0 {
696693
return nil, nil, ErrNoSymbols
697694
}
695+
if len(data)%Sym64Size != 0 {
696+
return nil, nil, errors.New("length of symbol section is not a multiple of Sym64Size")
697+
}
698698

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

0 commit comments

Comments
 (0)