aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorPatrick Meyer <meyerpatrick@google.com>2021-05-15 14:40:58 +0200
committerDmitry Vyukov <dvyukov@google.com>2021-05-20 13:29:54 +0200
commitebc32b110a66a9bebfced77df99dcd3001489158 (patch)
tree082b076a1430f4f08a1966d64c4bc385351e7b2e /pkg
parent5fd3595a15c0c86d52a0cad61e20453d33fa21c1 (diff)
pkg/symbolizer: check if binutils was build with macho support
Diffstat (limited to 'pkg')
-rw-r--r--pkg/symbolizer/symbolizer.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/pkg/symbolizer/symbolizer.go b/pkg/symbolizer/symbolizer.go
index 96b62fb95..158cb9dd1 100644
--- a/pkg/symbolizer/symbolizer.go
+++ b/pkg/symbolizer/symbolizer.go
@@ -7,6 +7,7 @@ package symbolizer
import (
"bufio"
+ "bytes"
"fmt"
"io"
"os/exec"
@@ -63,6 +64,22 @@ func (s *Symbolizer) Close() {
}
}
+func (s *Symbolizer) checkBinSupport(addr2line string) error {
+ cmd := exec.Command(addr2line, "--help")
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ return fmt.Errorf("addr2line execution failed: %s", err)
+ }
+ if !bytes.Contains(out, []byte("supported targets:")) {
+ return fmt.Errorf("addr2line output didn't contain supported targets")
+ }
+ if s.target.OS == targets.Darwin && s.target.Arch == targets.AMD64 &&
+ !bytes.Contains(out, []byte("mach-o-x86-64")) {
+ return fmt.Errorf("addr2line was built without mach-o-x86-64 support")
+ }
+ return nil
+}
+
func (s *Symbolizer) getSubprocess(bin string) (*subprocess, error) {
if sub := s.subprocs[bin]; sub != nil {
return sub, nil
@@ -71,6 +88,10 @@ func (s *Symbolizer) getSubprocess(bin string) (*subprocess, error) {
if s.target.Triple != "" {
addr2line = s.target.Triple + "-" + addr2line
}
+ err := s.checkBinSupport(addr2line)
+ if err != nil {
+ return nil, err
+ }
cmd := osutil.Command(addr2line, "-afi", "-e", bin)
stdin, err := cmd.StdinPipe()
if err != nil {