]> Cypherpunks repositories - gostls13.git/commitdiff
debug/plan9obj: export ErrNoSymbols
authorDan Kortschak <dan@kortschak.io>
Sun, 29 Aug 2021 04:31:03 +0000 (14:01 +0930)
committerIan Lance Taylor <iant@golang.org>
Fri, 5 Nov 2021 21:27:19 +0000 (21:27 +0000)
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>
src/debug/plan9obj/file.go

index 314608da6108331b37adfc190a0d166dfd882662..c054635148d10aee6010da24c7e4aaecf582d046 100644 (file)
@@ -301,11 +301,15 @@ func newTable(symtab []byte, ptrsz int) ([]Sym, error) {
        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()