mirror of
https://github.com/golang/go
synced 2024-10-04 21:11:22 -06:00
debug/pe: add some documentation and TODO
No code changes. Just moved ImportDirectory next to ImportedSymbols. And moved useless FormatError to the bottom of file.go. Updates #15345 Change-Id: I91ff243cefd18008b1c5ee9ec4326583deee431b Reviewed-on: https://go-review.googlesource.com/22182 Reviewed-by: David Crawshaw <crawshaw@golang.org> Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
bfe0cbdc50
commit
5183ad696c
@ -59,16 +59,6 @@ type Symbol struct {
|
||||
StorageClass uint8
|
||||
}
|
||||
|
||||
type ImportDirectory struct {
|
||||
OriginalFirstThunk uint32
|
||||
TimeDateStamp uint32
|
||||
ForwarderChain uint32
|
||||
Name uint32
|
||||
FirstThunk uint32
|
||||
|
||||
dll string
|
||||
}
|
||||
|
||||
// Data reads and returns the contents of the PE section.
|
||||
func (s *Section) Data() ([]byte, error) {
|
||||
dat := make([]byte, s.sr.Size())
|
||||
@ -82,21 +72,6 @@ func (s *Section) Data() ([]byte, error) {
|
||||
// Open returns a new ReadSeeker reading the PE section.
|
||||
func (s *Section) Open() io.ReadSeeker { return io.NewSectionReader(s.sr, 0, 1<<63-1) }
|
||||
|
||||
type FormatError struct {
|
||||
off int64
|
||||
msg string
|
||||
val interface{}
|
||||
}
|
||||
|
||||
func (e *FormatError) Error() string {
|
||||
msg := e.msg
|
||||
if e.val != nil {
|
||||
msg += fmt.Sprintf(" '%v'", e.val)
|
||||
}
|
||||
msg += fmt.Sprintf(" in record at byte %#x", e.off)
|
||||
return msg
|
||||
}
|
||||
|
||||
// Open opens the named file using os.Open and prepares it for use as a PE binary.
|
||||
func Open(name string) (*File, error) {
|
||||
f, err := os.Open(name)
|
||||
@ -320,6 +295,18 @@ func (f *File) DWARF() (*dwarf.Data, error) {
|
||||
return dwarf.New(abbrev, nil, nil, info, line, nil, ranges, str)
|
||||
}
|
||||
|
||||
// TODO(brainman): document ImportDirectory once we decide what to do with it.
|
||||
|
||||
type ImportDirectory struct {
|
||||
OriginalFirstThunk uint32
|
||||
TimeDateStamp uint32
|
||||
ForwarderChain uint32
|
||||
Name uint32
|
||||
FirstThunk uint32
|
||||
|
||||
dll string
|
||||
}
|
||||
|
||||
// ImportedSymbols returns the names of all symbols
|
||||
// referred to by the binary f that are expected to be
|
||||
// satisfied by other libraries at dynamic load time.
|
||||
@ -347,6 +334,12 @@ func (f *File) ImportedSymbols() ([]string, error) {
|
||||
}
|
||||
ida = append(ida, dt)
|
||||
}
|
||||
// TODO(brainman): this needs to be rewritten
|
||||
// ds.Data() return contets of .idata section. Why store in variable called "names"?
|
||||
// Why we are retrieving it second time? We already have it in "d", and it is not modified anywhere.
|
||||
// getString does not extracts a string from symbol string table (as getString doco says).
|
||||
// Why ds.Data() called again and again in the loop?
|
||||
// Needs test before rewrite.
|
||||
names, _ := ds.Data()
|
||||
var all []string
|
||||
for _, dt := range ida {
|
||||
@ -395,3 +388,12 @@ func (f *File) ImportedLibraries() ([]string, error) {
|
||||
// cgo -dynimport don't use this for windows PE, so just return.
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// FormatError is unused.
|
||||
// The type is retained for compatibility.
|
||||
type FormatError struct {
|
||||
}
|
||||
|
||||
func (e *FormatError) Error() string {
|
||||
return "unknown error"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user