aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/symbol_inject/macho.go2
-rw-r--r--cmd/symbol_inject/pe.go5
2 files changed, 6 insertions, 1 deletions
diff --git a/cmd/symbol_inject/macho.go b/cmd/symbol_inject/macho.go
index 0945293f..6a1de99a 100644
--- a/cmd/symbol_inject/macho.go
+++ b/cmd/symbol_inject/macho.go
@@ -26,7 +26,7 @@ func findMachoSymbol(r io.ReaderAt, symbolName string) (uint64, uint64, error) {
return maxUint64, maxUint64, cantParseError{err}
}
- // TODO(ccross): why?
+ // symbols in macho files seem to be prefixed with an underscore
symbolName = "_" + symbolName
for i, symbol := range machoFile.Symtab.Syms {
diff --git a/cmd/symbol_inject/pe.go b/cmd/symbol_inject/pe.go
index 86f61621..dad530d4 100644
--- a/cmd/symbol_inject/pe.go
+++ b/cmd/symbol_inject/pe.go
@@ -27,6 +27,11 @@ func findPESymbol(r io.ReaderAt, symbolName string) (uint64, uint64, error) {
return maxUint64, maxUint64, cantParseError{err}
}
+ if peFile.FileHeader.Machine == pe.IMAGE_FILE_MACHINE_I386 {
+ // symbols in win32 exes seem to be prefixed with an underscore
+ symbolName = "_" + symbolName
+ }
+
sort.Slice(peFile.Symbols, func(i, j int) bool {
if peFile.Symbols[i].SectionNumber != peFile.Symbols[j].SectionNumber {
return peFile.Symbols[i].SectionNumber < peFile.Symbols[j].SectionNumber