summaryrefslogtreecommitdiff
path: root/src/cmd/objdump
diff options
context:
space:
mode:
authorAlex Brainman <alex.brainman@gmail.com>2014-05-15 12:44:29 +1000
committerAlex Brainman <alex.brainman@gmail.com>2014-05-15 12:44:29 +1000
commit60e7bded6e3d15c580f152d5452bd2469bd5a766 (patch)
tree82a800ef5afe114cb9ed18896b56ca931169d9c5 /src/cmd/objdump
parent68773c7adfd19ff5a1b5d20ff44c8fe8058bf6ca (diff)
downloadgo-60e7bded6e3d15c580f152d5452bd2469bd5a766.tar.gz
cmd/addr2line, cmd/objdump: fix pe text section starting address
fixes windows build LGTM=bradfitz R=golang-codereviews, bradfitz CC=golang-codereviews https://codereview.appspot.com/97500043
Diffstat (limited to 'src/cmd/objdump')
-rw-r--r--src/cmd/objdump/main.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cmd/objdump/main.go b/src/cmd/objdump/main.go
index 1b6b3d0fc..fb79ba3a2 100644
--- a/src/cmd/objdump/main.go
+++ b/src/cmd/objdump/main.go
@@ -318,8 +318,17 @@ func loadTables(f *os.File) (textStart uint64, textData, symtab, pclntab []byte,
}
if obj, err := pe.NewFile(f); err == nil {
+ var imageBase uint64
+ switch oh := obj.OptionalHeader.(type) {
+ case *pe.OptionalHeader32:
+ imageBase = uint64(oh.ImageBase)
+ case *pe.OptionalHeader64:
+ imageBase = oh.ImageBase
+ default:
+ return 0, nil, nil, nil, fmt.Errorf("pe file format not recognized")
+ }
if sect := obj.Section(".text"); sect != nil {
- textStart = uint64(sect.VirtualAddress)
+ textStart = imageBase + uint64(sect.VirtualAddress)
textData, _ = sect.Data()
}
if pclntab, err = loadPETable(obj, "pclntab", "epclntab"); err != nil {