summaryrefslogtreecommitdiff
path: root/src/pkg/debug/pe
diff options
context:
space:
mode:
authorWei Guangjing <vcc.163@gmail.com>2011-07-12 11:29:38 -0700
committerWei Guangjing <vcc.163@gmail.com>2011-07-12 11:29:38 -0700
commit1ea13cc6b4409de51851e1d9106c642ff4a41c96 (patch)
treee135590d6b60d6ad4db0346b7756d11c9c319211 /src/pkg/debug/pe
parent0f190c9038c80e1dcbc4ba9cafaa30a9c06c481f (diff)
downloadgo-1ea13cc6b4409de51851e1d9106c642ff4a41c96.tar.gz
debug/pe: fixes ImportedSymbols for Win64.
R=golang-dev, alex.brainman CC=golang-dev http://codereview.appspot.com/4639086 Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/debug/pe')
-rw-r--r--src/pkg/debug/pe/file.go37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/pkg/debug/pe/file.go b/src/pkg/debug/pe/file.go
index 04991f781..c934dd447 100644
--- a/src/pkg/debug/pe/file.go
+++ b/src/pkg/debug/pe/file.go
@@ -245,6 +245,7 @@ func (f *File) DWARF() (*dwarf.Data, os.Error) {
// satisfied by other libraries at dynamic load time.
// It does not return weak symbols.
func (f *File) ImportedSymbols() ([]string, os.Error) {
+ pe64 := f.Machine == IMAGE_FILE_MACHINE_AMD64
ds := f.Section(".idata")
if ds == nil {
// not dynamic, so no libraries
@@ -274,17 +275,31 @@ func (f *File) ImportedSymbols() ([]string, os.Error) {
// 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
- }
- 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)
+ if pe64 { // 64bit
+ va := binary.LittleEndian.Uint64(d[0:8])
+ d = d[8:]
+ if va == 0 {
+ break
+ }
+ if va&0x8000000000000000 > 0 { // is Ordinal
+ // TODO add dynimport ordinal support.
+ } else {
+ fn, _ := getString(names, int(uint32(va)-ds.VirtualAddress+2))
+ all = append(all, fn+":"+dt.dll)
+ }
+ } else { // 32bit
+ 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)
+ }
}
}
}