This allows callers of *File.Symbols to distinguish absence of symbols
from other errors as can already by done in debug/elf.
Fixes #48052
Change-Id: I5ba15d8473911e516c016a69c1f1c710f7fc4cd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/350229
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
return syms, nil
}
+// ErrNoSymbols is returned by File.Symbols if there is no such section
+// in the File.
+var ErrNoSymbols = errors.New("no symbol section")
+
// Symbols returns the symbol table for f.
func (f *File) Symbols() ([]Sym, error) {
symtabSection := f.Section("syms")
if symtabSection == nil {
- return nil, errors.New("no symbol section")
+ return nil, ErrNoSymbols
}
symtab, err := symtabSection.Data()