Index: src/pkg/debug/elf/file.go |
=================================================================== |
--- a/src/pkg/debug/elf/file.go |
+++ b/src/pkg/debug/elf/file.go |
@@ -272,7 +272,8 @@ |
shnum = int(hdr.Shnum) |
shstrndx = int(hdr.Shstrndx) |
} |
- if shstrndx < 0 || shstrndx >= shnum { |
+ |
+ if shnum > 0 && shoff > 0 && (shstrndx < 0 || shstrndx >= shnum) { |
dvyukov
2015/05/29 18:41:47
shouldn't this be:
if shnum < 0 || shoff < 0 ||
|
return nil, &FormatError{0, "invalid ELF shstrndx", shstrndx} |
} |
@@ -367,6 +368,10 @@ |
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 { |