diff options
| author | Alex Brainman <alex.brainman@gmail.com> | 2016-04-18 16:12:48 +1000 |
|---|---|---|
| committer | Alex Brainman <alex.brainman@gmail.com> | 2016-04-20 02:01:36 +0000 |
| commit | d697a9d5d7d75cecd8d49b95ed9a0d1f2f3e8ed4 (patch) | |
| tree | ce5001fcfeef7924800cb1bf691d0e96207c8fed /src/debug/pe/file.go | |
| parent | 5183ad696c708ab5fc65006413019b1ef96aa91b (diff) | |
| download | go-d697a9d5d7d75cecd8d49b95ed9a0d1f2f3e8ed4.tar.xz | |
debug/pe: introduce StringTable type
PE specification requires that long section and symbol names
are stored in PE string table. Introduce StringTable that
implements this functionality. Only string table reading is
implemented.
Updates #15345
Change-Id: Ib9638617f2ab1881ad707111d96fc68b0e47340e
Reviewed-on: https://go-review.googlesource.com/22181
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Diffstat (limited to 'src/debug/pe/file.go')
| -rw-r--r-- | src/debug/pe/file.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/debug/pe/file.go b/src/debug/pe/file.go index bfc4cf8a18..f7b74e92a4 100644 --- a/src/debug/pe/file.go +++ b/src/debug/pe/file.go @@ -21,6 +21,7 @@ type File struct { OptionalHeader interface{} // of type *OptionalHeader32 or *OptionalHeader64 Sections []*Section Symbols []*Symbol + StringTable StringTable closer io.Closer } @@ -133,6 +134,14 @@ func NewFile(r io.ReaderAt) (*File, error) { return nil, errors.New("Invalid PE File Format.") } + var err error + + // Read string table. + f.StringTable, err = readStringTable(&f.FileHeader, sr) + if err != nil { + return nil, err + } + var ss []byte if f.FileHeader.NumberOfSymbols > 0 { // Get COFF string table, which is located at the end of the COFF symbol table. @@ -237,13 +246,6 @@ func NewFile(r io.ReaderAt) (*File, error) { return f, nil } -func cstring(b []byte) string { - var i int - for i = 0; i < len(b) && b[i] != 0; i++ { - } - return string(b[0:i]) -} - // getString extracts a string from symbol string table. func getString(section []byte, start int) (string, bool) { if start < 0 || start >= len(section) { |
