File tree Expand file tree Collapse file tree 2 files changed +24
-22
lines changed Expand file tree Collapse file tree 2 files changed +24
-22
lines changed Original file line number Diff line number Diff line change @@ -47,25 +47,3 @@ func TestNames(t *testing.T) {
47
47
}
48
48
}
49
49
}
50
-
51
- func TestNobitsSection (t * testing.T ) {
52
- const testdata = "testdata/gcc-amd64-linux-exec"
53
- f , err := Open (testdata )
54
- if err != nil {
55
- t .Fatalf ("could not read %s: %v" , testdata , err )
56
- }
57
- defer f .Close ()
58
- bss := f .Section (".bss" )
59
- bssData , err := bss .Data ()
60
- if err != nil {
61
- t .Fatalf ("error reading .bss section: %v" , err )
62
- }
63
- if g , w := uint64 (len (bssData )), bss .Size ; g != w {
64
- t .Errorf (".bss section length mismatch: got %d, want %d" , g , w )
65
- }
66
- for i := range bssData {
67
- if bssData [i ] != 0 {
68
- t .Fatalf ("unexpected non-zero byte at offset %d: %#x" , i , bssData [i ])
69
- }
70
- }
71
- }
Original file line number Diff line number Diff line change @@ -944,6 +944,30 @@ func TestNoSectionOverlaps(t *testing.T) {
944
944
}
945
945
}
946
946
947
+ func TestNobitsSection (t * testing.T ) {
948
+ const testdata = "testdata/gcc-amd64-linux-exec"
949
+ f , err := Open (testdata )
950
+ if err != nil {
951
+ t .Fatalf ("could not read %s: %v" , testdata , err )
952
+ }
953
+ defer f .Close ()
954
+
955
+ wantError := "unexpected read from SHT_NOBITS section"
956
+ bss := f .Section (".bss" )
957
+
958
+ _ , err = bss .Data ()
959
+ if err == nil || err .Error () != wantError {
960
+ t .Fatalf ("bss.Data() got error %q, want error %q" , err , wantError )
961
+ }
962
+
963
+ r := bss .Open ()
964
+ p := make ([]byte , 1 )
965
+ _ , err = r .Read (p )
966
+ if err == nil || err .Error () != wantError {
967
+ t .Fatalf ("r.Read(p) got error %q, want error %q" , err , wantError )
968
+ }
969
+ }
970
+
947
971
func TestIssue10996 (t * testing.T ) {
948
972
data := []byte ("\u007f ELF\x02 \x01 \x01 0000000000000" +
949
973
"\x01 0000000000000000000" +
You can’t perform that action at this time.
0 commit comments