diff options
Diffstat (limited to 'src/pkg/debug/elf/file.go')
| -rw-r--r-- | src/pkg/debug/elf/file.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/pkg/debug/elf/file.go b/src/pkg/debug/elf/file.go index b030b043df..acb9817af0 100644 --- a/src/pkg/debug/elf/file.go +++ b/src/pkg/debug/elf/file.go @@ -272,7 +272,8 @@ func NewFile(r io.ReaderAt) (*File, error) { shnum = int(hdr.Shnum) shstrndx = int(hdr.Shstrndx) } - if shstrndx < 0 || shstrndx >= shnum { + + if shnum > 0 && shoff > 0 && (shstrndx < 0 || shstrndx >= shnum) { return nil, &FormatError{0, "invalid ELF shstrndx", shstrndx} } @@ -367,6 +368,10 @@ func NewFile(r io.ReaderAt) (*File, error) { f.Sections[i] = s } + if len(f.Sections) == 0 { + return f, nil + } + // Load section header string table. shstrtab, err := f.Sections[shstrndx].Data() if err != nil { |
