diff options
author | Colin Cross <ccross@android.com> | 2018-02-23 17:10:34 -0800 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2018-02-23 18:24:48 -0800 |
commit | 64c6d4bf14ef109f08cfb976e3e71a18aee0f009 (patch) | |
tree | 5231b977f6f7d09e3ba3ca2c54099be3fdf1982c /cmd | |
parent | d2092dbc0dde66212a57bc62d9b5ea7cfd623e0a (diff) | |
download | build_soong-64c6d4bf14ef109f08cfb976e3e71a18aee0f009.tar.gz build_soong-64c6d4bf14ef109f08cfb976e3e71a18aee0f009.tar.bz2 build_soong-64c6d4bf14ef109f08cfb976e3e71a18aee0f009.zip |
Fix symbol_inject on win32 exes
Win32 exes seem to prefix each symbol with an underscore like
macho.
Test: build_version_test
Change-Id: I9de0a0f5f25f93ad17d34b7c1b993511c77a57eb
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/symbol_inject/macho.go | 2 | ||||
-rw-r--r-- | cmd/symbol_inject/pe.go | 5 |
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 |