From f264915ca2964ad8f34ce1deee4f42c2f9dc21bf Mon Sep 17 00:00:00 2001 From: Aditya Sirish A Yelgundhalli Date: Tue, 26 Aug 2025 13:20:17 -0400 Subject: [PATCH] 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. --- src/debug/elf/file.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/debug/elf/file.go b/src/debug/elf/file.go index 50452b5bef45f4..3059365fa125d9 100644 --- a/src/debug/elf/file.go +++ b/src/debug/elf/file.go @@ -640,7 +640,7 @@ func (f *File) getSymbols32(typ SectionType) ([]Symbol, []byte, error) { return nil, nil, fmt.Errorf("cannot load symbol section: %w", err) } if len(data) == 0 { - return nil, nil, errors.New("symbol section is empty") + return nil, nil, ErrNoSymbols } if len(data)%Sym32Size != 0 { 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) { if err != nil { return nil, nil, fmt.Errorf("cannot load symbol section: %w", err) } - if len(data)%Sym64Size != 0 { - return nil, nil, errors.New("length of symbol section is not a multiple of Sym64Size") - } if len(data) == 0 { return nil, nil, ErrNoSymbols } + if len(data)%Sym64Size != 0 { + return nil, nil, errors.New("length of symbol section is not a multiple of Sym64Size") + } strdata, err := f.stringTable(symtabSection.Link) if err != nil {