diff options
Diffstat (limited to 'libgo/go/debug/elf/file.go')
-rw-r--r-- | libgo/go/debug/elf/file.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/libgo/go/debug/elf/file.go b/libgo/go/debug/elf/file.go index f462375dc64..eb3d72f7126 100644 --- a/libgo/go/debug/elf/file.go +++ b/libgo/go/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 { |