aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/debug
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/debug')
-rw-r--r--src/pkg/debug/gosym/pclntab_test.go2
-rw-r--r--src/pkg/debug/gosym/symtab.go12
2 files changed, 11 insertions, 3 deletions
diff --git a/src/pkg/debug/gosym/pclntab_test.go b/src/pkg/debug/gosym/pclntab_test.go
index ade704335d..5f2242eba0 100644
--- a/src/pkg/debug/gosym/pclntab_test.go
+++ b/src/pkg/debug/gosym/pclntab_test.go
@@ -129,7 +129,7 @@ func TestLineFromAline(t *testing.T) {
if !ok {
t.Errorf("file %s starts on line %d", path, line)
} else if line != ll+1 {
- t.Errorf("expected next line of file %s to be %d, got %d", path, ll+1, line)
+ t.Fatalf("expected next line of file %s to be %d, got %d", path, ll+1, line)
}
lastline[path] = line
}
diff --git a/src/pkg/debug/gosym/symtab.go b/src/pkg/debug/gosym/symtab.go
index 52d7d55a33..cc01e0b9d6 100644
--- a/src/pkg/debug/gosym/symtab.go
+++ b/src/pkg/debug/gosym/symtab.go
@@ -13,6 +13,7 @@ package gosym
// and the Go format is the runtime source, specifically ../../runtime/symtab.c.
import (
+ "bytes"
"encoding/binary"
"fmt"
"strconv"
@@ -104,11 +105,18 @@ type sym struct {
name []byte
}
+var littleEndianSymtab = []byte{0xFE, 0xFF, 0xFF, 0xFF, 0x00, 0x00}
+
func walksymtab(data []byte, fn func(sym) error) error {
+ var order binary.ByteOrder = binary.BigEndian
+ if bytes.HasPrefix(data, littleEndianSymtab) {
+ data = data[6:]
+ order = binary.LittleEndian
+ }
var s sym
p := data
for len(p) >= 6 {
- s.value = binary.BigEndian.Uint32(p[0:4])
+ s.value = order.Uint32(p[0:4])
typ := p[4]
if typ&0x80 == 0 {
return &DecodingError{len(data) - len(p) + 4, "bad symbol type", typ}
@@ -139,7 +147,7 @@ func walksymtab(data []byte, fn func(sym) error) error {
}
s.name = p[0:i]
i += nnul
- s.gotype = binary.BigEndian.Uint32(p[i : i+4])
+ s.gotype = order.Uint32(p[i : i+4])
p = p[i+4:]
fn(s)
}