summaryrefslogtreecommitdiff
path: root/src/pkg/debug
diff options
context:
space:
mode:
authorWei Guangjing <vcc.163@gmail.com>2011-02-10 10:22:32 -0500
committerWei Guangjing <vcc.163@gmail.com>2011-02-10 10:22:32 -0500
commitc39a239b6bcc9a24d10e677fbbf7a3286c0bca04 (patch)
tree30ae3339cb08b5a95e1cfee9d27f65cb05387928 /src/pkg/debug
parent938c9fa288e505008dc52705df756cfa577077c3 (diff)
downloadgo-c39a239b6bcc9a24d10e677fbbf7a3286c0bca04.tar.gz
debug/pe: ImportedSymbols fixes
R=golang-dev, brainman, mattn, rsc CC=golang-dev http://codereview.appspot.com/4001058 Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/debug')
-rw-r--r--src/pkg/debug/pe/file.go33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/pkg/debug/pe/file.go b/src/pkg/debug/pe/file.go
index 82c02407b..1bcbdc5e9 100644
--- a/src/pkg/debug/pe/file.go
+++ b/src/pkg/debug/pe/file.go
@@ -57,7 +57,6 @@ type ImportDirectory struct {
FirstThunk uint32
dll string
- rva []uint32
}
// Data reads and returns the contents of the PE section.
@@ -267,34 +266,28 @@ func (f *File) ImportedSymbols() ([]string, os.Error) {
}
ida = append(ida, dt)
}
- for i, _ := range ida {
+ names, _ := ds.Data()
+ var all []string
+ for _, dt := range ida {
+ dt.dll, _ = getString(names, int(dt.Name-ds.VirtualAddress))
+ d, _ = ds.Data()
+ // seek to OriginalFirstThunk
+ d = d[dt.OriginalFirstThunk-ds.VirtualAddress:]
for len(d) > 0 {
va := binary.LittleEndian.Uint32(d[0:4])
d = d[4:]
if va == 0 {
break
}
- ida[i].rva = append(ida[i].rva, va)
- }
- }
- for _, _ = range ida {
- for len(d) > 0 {
- va := binary.LittleEndian.Uint32(d[0:4])
- d = d[4:]
- if va == 0 {
- break
+ if va&0x80000000 > 0 { // is Ordinal
+ // TODO add dynimport ordinal support.
+ //ord := va&0x0000FFFF
+ } else {
+ fn, _ := getString(names, int(va-ds.VirtualAddress+2))
+ all = append(all, fn+":"+dt.dll)
}
}
}
- names, _ := ds.Data()
- var all []string
- for _, dt := range ida {
- dt.dll, _ = getString(names, int(dt.Name-ds.VirtualAddress))
- for _, va := range dt.rva {
- fn, _ := getString(names, int(va-ds.VirtualAddress+2))
- all = append(all, fn+":"+dt.dll)
- }
- }
return all, nil
}