aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/symbolizer/nm.go
diff options
context:
space:
mode:
authorAlexander Egorenkov <Alexander.Egorenkov@ibm.com>2020-06-02 08:17:38 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-06-18 19:31:40 +0200
commitbc258b506da8ceda014bf1d40d695d1890e9f785 (patch)
tree8ad9a8a035b9a14ac9d35840050e589428a440b8 /pkg/symbolizer/nm.go
parentb1b22865fc4567c79793620400109f2220335f84 (diff)
pkg: support compiler triple for 'nm' and 'addr2line'
In preparation to support big-endian architectures.
Diffstat (limited to 'pkg/symbolizer/nm.go')
-rw-r--r--pkg/symbolizer/nm.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/pkg/symbolizer/nm.go b/pkg/symbolizer/nm.go
index 09baf8119..626d08fd8 100644
--- a/pkg/symbolizer/nm.go
+++ b/pkg/symbolizer/nm.go
@@ -9,6 +9,7 @@ import (
"strconv"
"github.com/google/syzkaller/pkg/osutil"
+ "github.com/google/syzkaller/sys/targets"
)
type Symbol struct {
@@ -17,21 +18,25 @@ type Symbol struct {
}
// ReadTextSymbols returns list of text symbols in the binary bin.
-func ReadTextSymbols(bin string) (map[string][]Symbol, error) {
- return read(bin, "t", "T")
+func (s *Symbolizer) ReadTextSymbols(bin string) (map[string][]Symbol, error) {
+ return read(s.target, bin, "t", "T")
}
// ReadRodataSymbols returns list of rodata symbols in the binary bin.
-func ReadRodataSymbols(bin string) (map[string][]Symbol, error) {
- return read(bin, "r", "R")
+func (s *Symbolizer) ReadRodataSymbols(bin string) (map[string][]Symbol, error) {
+ return read(s.target, bin, "r", "R")
}
-func read(bin string, types ...string) (map[string][]Symbol, error) {
+func read(target *targets.Target, bin string, types ...string) (map[string][]Symbol, error) {
if len(types) != 2 || len(types[0]) != 1 || len(types[1]) != 1 {
// We assume these things below.
panic("bad types")
}
- cmd := osutil.Command("nm", "-Ptx", bin)
+ nm := "nm"
+ if target != nil && target.Triple != "" {
+ nm = target.Triple + "-" + nm
+ }
+ cmd := osutil.Command(nm, "-Ptx", bin)
stdout, err := cmd.StdoutPipe()
if err != nil {
return nil, err