Commit f340b3de authored by Wei Guangjing's avatar Wei Guangjing Committed by Russ Cox

debug/pe: fixes ImportedSymbols for Win64.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/4639086
parent 67edf9cb
...@@ -245,6 +245,7 @@ func (f *File) DWARF() (*dwarf.Data, os.Error) { ...@@ -245,6 +245,7 @@ func (f *File) DWARF() (*dwarf.Data, os.Error) {
// satisfied by other libraries at dynamic load time. // satisfied by other libraries at dynamic load time.
// It does not return weak symbols. // It does not return weak symbols.
func (f *File) ImportedSymbols() ([]string, os.Error) { func (f *File) ImportedSymbols() ([]string, os.Error) {
pe64 := f.Machine == IMAGE_FILE_MACHINE_AMD64
ds := f.Section(".idata") ds := f.Section(".idata")
if ds == nil { if ds == nil {
// not dynamic, so no libraries // not dynamic, so no libraries
...@@ -274,17 +275,31 @@ func (f *File) ImportedSymbols() ([]string, os.Error) { ...@@ -274,17 +275,31 @@ func (f *File) ImportedSymbols() ([]string, os.Error) {
// seek to OriginalFirstThunk // seek to OriginalFirstThunk
d = d[dt.OriginalFirstThunk-ds.VirtualAddress:] d = d[dt.OriginalFirstThunk-ds.VirtualAddress:]
for len(d) > 0 { for len(d) > 0 {
va := binary.LittleEndian.Uint32(d[0:4]) if pe64 { // 64bit
d = d[4:] va := binary.LittleEndian.Uint64(d[0:8])
if va == 0 { d = d[8:]
break if va == 0 {
} break
if va&0x80000000 > 0 { // is Ordinal }
// TODO add dynimport ordinal support. if va&0x8000000000000000 > 0 { // is Ordinal
//ord := va&0x0000FFFF // TODO add dynimport ordinal support.
} else { } else {
fn, _ := getString(names, int(va-ds.VirtualAddress+2)) fn, _ := getString(names, int(uint32(va)-ds.VirtualAddress+2))
all = append(all, fn+":"+dt.dll) 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)
}
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment