return nil, &FormatError{0, "invalid ELF shstrndx", shstrndx}
}
+ var wantPhentsize, wantShentsize int
+ switch f.Class {
+ case ELFCLASS32:
+ wantPhentsize = 8 * 4
+ wantShentsize = 10 * 4
+ case ELFCLASS64:
+ wantPhentsize = 2*4 + 6*8
+ wantShentsize = 4*4 + 6*8
+ }
+ if phnum > 0 && phentsize < wantPhentsize {
+ return nil, &FormatError{0, "invalid ELF phentsize", phentsize}
+ }
+
// Read program headers
f.Progs = make([]*Prog, phnum)
for i := 0; i < phnum; i++ {
}
}
+ if shnum > 0 && shentsize < wantShentsize {
+ return nil, &FormatError{0, "invalid ELF shentsize", shentsize}
+ }
+
// Read section headers
f.Sections = make([]*Section, shnum)
names := make([]uint32, shnum)