mirror of
https://github.com/golang/go
synced 2024-11-26 20:21:25 -07:00
debug/pe: handle files with no string table
pecoff.doc (https://goo.gl/ayvckk) in section 5.6 says: Immediately following the COFF symbol table is the COFF string table. The position of this table is found by taking the symbol table address in the COFF header, and adding the number of symbols multiplied by the size of a symbol. So it is unclear what to do when symbol table address is 0. Lets assume executable does not have any string table. Added new test with executable with no symbol table. The gcc -s testdata\hello.c -o testdata\gcc-386-mingw-no-symbols-exec. command was used to generate the executable. Fixes #16084 Change-Id: Ie74137ac64b15daadd28e1f0315f3b62d1bf2059 Reviewed-on: https://go-review.googlesource.com/24200 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
f3d54789f7
commit
691c5c1568
@ -104,6 +104,41 @@ var fileTests = []fileTest{
|
||||
{".debug_loc", 0x38, 0xf000, 0x200, 0x3a00, 0x0, 0x0, 0x0, 0x0, 0x42100000},
|
||||
},
|
||||
},
|
||||
{
|
||||
file: "testdata/gcc-386-mingw-no-symbols-exec",
|
||||
hdr: FileHeader{0x14c, 0x8, 0x69676572, 0x0, 0x0, 0xe0, 0x30f},
|
||||
opthdr: &OptionalHeader32{0x10b, 0x2, 0x18, 0xe00, 0x1e00, 0x200, 0x1280, 0x1000, 0x2000, 0x400000, 0x1000, 0x200, 0x4, 0x0, 0x1, 0x0, 0x4, 0x0, 0x0, 0x9000, 0x400, 0x5306, 0x3, 0x0, 0x200000, 0x1000, 0x100000, 0x1000, 0x0, 0x10,
|
||||
[16]DataDirectory{
|
||||
{0x0, 0x0},
|
||||
{0x6000, 0x378},
|
||||
{0x0, 0x0},
|
||||
{0x0, 0x0},
|
||||
{0x0, 0x0},
|
||||
{0x0, 0x0},
|
||||
{0x0, 0x0},
|
||||
{0x0, 0x0},
|
||||
{0x0, 0x0},
|
||||
{0x8004, 0x18},
|
||||
{0x0, 0x0},
|
||||
{0x0, 0x0},
|
||||
{0x60b8, 0x7c},
|
||||
{0x0, 0x0},
|
||||
{0x0, 0x0},
|
||||
{0x0, 0x0},
|
||||
},
|
||||
},
|
||||
sections: []*SectionHeader{
|
||||
{".text", 0xc64, 0x1000, 0xe00, 0x400, 0x0, 0x0, 0x0, 0x0, 0x60500060},
|
||||
{".data", 0x10, 0x2000, 0x200, 0x1200, 0x0, 0x0, 0x0, 0x0, 0xc0300040},
|
||||
{".rdata", 0x134, 0x3000, 0x200, 0x1400, 0x0, 0x0, 0x0, 0x0, 0x40300040},
|
||||
{".eh_fram", 0x3a0, 0x4000, 0x400, 0x1600, 0x0, 0x0, 0x0, 0x0, 0x40300040},
|
||||
{".bss", 0x60, 0x5000, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0300080},
|
||||
{".idata", 0x378, 0x6000, 0x400, 0x1a00, 0x0, 0x0, 0x0, 0x0, 0xc0300040},
|
||||
{".CRT", 0x18, 0x7000, 0x200, 0x1e00, 0x0, 0x0, 0x0, 0x0, 0xc0300040},
|
||||
{".tls", 0x20, 0x8000, 0x200, 0x2000, 0x0, 0x0, 0x0, 0x0, 0xc0300040},
|
||||
},
|
||||
hasNoDwarfInfo: true,
|
||||
},
|
||||
{
|
||||
file: "testdata/gcc-amd64-mingw-obj",
|
||||
hdr: FileHeader{0x8664, 0x6, 0x0, 0x198, 0x12, 0x0, 0x4},
|
||||
|
@ -24,6 +24,9 @@ type _StringTable []byte
|
||||
|
||||
func readStringTable(fh *FileHeader, r io.ReadSeeker) (_StringTable, error) {
|
||||
// COFF string table is located right after COFF symbol table.
|
||||
if fh.PointerToSymbolTable <= 0 {
|
||||
return nil, nil
|
||||
}
|
||||
offset := fh.PointerToSymbolTable + COFFSymbolSize*fh.NumberOfSymbols
|
||||
_, err := r.Seek(int64(offset), io.SeekStart)
|
||||
if err != nil {
|
||||
|
BIN
src/debug/pe/testdata/gcc-386-mingw-no-symbols-exec
vendored
Normal file
BIN
src/debug/pe/testdata/gcc-386-mingw-no-symbols-exec
vendored
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user