aboutsummaryrefslogtreecommitdiff
path: root/src/debug/elf/elf_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/debug/elf/elf_test.go')
-rw-r--r--src/debug/elf/elf_test.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/debug/elf/elf_test.go b/src/debug/elf/elf_test.go
index a61b491090d..b8c310dba55 100644
--- a/src/debug/elf/elf_test.go
+++ b/src/debug/elf/elf_test.go
@@ -47,3 +47,25 @@ func TestNames(t *testing.T) {
}
}
}
+
+func TestNobitsSection(t *testing.T) {
+ const testdata = "testdata/gcc-amd64-linux-exec"
+ f, err := Open(testdata)
+ if err != nil {
+ t.Fatalf("could not read %s: %v", testdata, err)
+ }
+ defer f.Close()
+ bss := f.Section(".bss")
+ bssData, err := bss.Data()
+ if err != nil {
+ t.Fatalf("error reading .bss section: %v", err)
+ }
+ if g, w := uint64(len(bssData)), bss.Size; g != w {
+ t.Errorf(".bss section length mismatch: got %d, want %d", g, w)
+ }
+ for i := range bssData {
+ if bssData[i] != 0 {
+ t.Fatalf("unexpected non-zero byte at offset %d: %#x", i, bssData[i])
+ }
+ }
+}