Skip to content

Commit 878cabe

Browse files
authored
Merge pull request #56 from bjjwwang/main
update test6
2 parents e014bee + 1e32453 commit 878cabe

File tree

2 files changed

+16
-34
lines changed

2 files changed

+16
-34
lines changed

Assignment-3/Tests/buf/test6.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ void mem_insert(void *buffer, const void *data, int data_size, int position);
33
extern void OVERFLOW(void* data, int size);
44
extern void svf_assert(bool condition);
55
int main() {
6-
char buffer[10] = {0};
7-
mem_insert(buffer, "abcdef", 3, 5);
8-
svf_assert(buffer[3] == 'a');
9-
svf_assert(buffer[4] == 'b');
10-
svf_assert(buffer[5] == 'c');
11-
svf_assert(buffer[6] == 'd');
12-
svf_assert(buffer[7] == 'e');
13-
svf_assert(buffer[8] != 'f');
6+
char buffer[10] = {0};
7+
mem_insert(buffer, "abcdef", 3, 5);
8+
svf_assert(buffer[5] == 'a');
9+
svf_assert(buffer[6] == 'b');
10+
svf_assert(buffer[7] == 'c');
11+
svf_assert(buffer[8] != 'd');
1412
return 0;
1513
}

Assignment-3/Tests/buf/test6.ll

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
; ModuleID = './test14.ll'
2-
source_filename = "test14.c"
1+
; ModuleID = './test6.ll'
2+
source_filename = "test6.c"
33
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
44
target triple = "arm64-apple-macosx14.0.0"
55

@@ -13,37 +13,27 @@ entry:
1313
call void @llvm.memset.p0.i64(ptr align 1 %buffer, i8 0, i64 10, i1 false), !dbg !25
1414
%arraydecay = getelementptr inbounds [10 x i8], ptr %buffer, i64 0, i64 0, !dbg !26
1515
call void @mem_insert(ptr noundef %arraydecay, ptr noundef @.str, i32 noundef 3, i32 noundef 5), !dbg !27
16-
%arrayidx = getelementptr inbounds [10 x i8], ptr %buffer, i64 0, i64 3, !dbg !28
16+
%arrayidx = getelementptr inbounds [10 x i8], ptr %buffer, i64 0, i64 5, !dbg !28
1717
%0 = load i8, ptr %arrayidx, align 1, !dbg !28
1818
%conv = sext i8 %0 to i32, !dbg !28
1919
%cmp = icmp eq i32 %conv, 97, !dbg !29
2020
call void @svf_assert(i1 noundef zeroext %cmp), !dbg !30
21-
%arrayidx2 = getelementptr inbounds [10 x i8], ptr %buffer, i64 0, i64 4, !dbg !31
21+
%arrayidx2 = getelementptr inbounds [10 x i8], ptr %buffer, i64 0, i64 6, !dbg !31
2222
%1 = load i8, ptr %arrayidx2, align 1, !dbg !31
2323
%conv3 = sext i8 %1 to i32, !dbg !31
2424
%cmp4 = icmp eq i32 %conv3, 98, !dbg !32
2525
call void @svf_assert(i1 noundef zeroext %cmp4), !dbg !33
26-
%arrayidx6 = getelementptr inbounds [10 x i8], ptr %buffer, i64 0, i64 5, !dbg !34
26+
%arrayidx6 = getelementptr inbounds [10 x i8], ptr %buffer, i64 0, i64 7, !dbg !34
2727
%2 = load i8, ptr %arrayidx6, align 1, !dbg !34
2828
%conv7 = sext i8 %2 to i32, !dbg !34
2929
%cmp8 = icmp eq i32 %conv7, 99, !dbg !35
3030
call void @svf_assert(i1 noundef zeroext %cmp8), !dbg !36
31-
%arrayidx10 = getelementptr inbounds [10 x i8], ptr %buffer, i64 0, i64 6, !dbg !37
31+
%arrayidx10 = getelementptr inbounds [10 x i8], ptr %buffer, i64 0, i64 8, !dbg !37
3232
%3 = load i8, ptr %arrayidx10, align 1, !dbg !37
3333
%conv11 = sext i8 %3 to i32, !dbg !37
34-
%cmp12 = icmp eq i32 %conv11, 100, !dbg !38
34+
%cmp12 = icmp ne i32 %conv11, 100, !dbg !38
3535
call void @svf_assert(i1 noundef zeroext %cmp12), !dbg !39
36-
%arrayidx14 = getelementptr inbounds [10 x i8], ptr %buffer, i64 0, i64 7, !dbg !40
37-
%4 = load i8, ptr %arrayidx14, align 1, !dbg !40
38-
%conv15 = sext i8 %4 to i32, !dbg !40
39-
%cmp16 = icmp eq i32 %conv15, 101, !dbg !41
40-
call void @svf_assert(i1 noundef zeroext %cmp16), !dbg !42
41-
%arrayidx18 = getelementptr inbounds [10 x i8], ptr %buffer, i64 0, i64 8, !dbg !43
42-
%5 = load i8, ptr %arrayidx18, align 1, !dbg !43
43-
%conv19 = sext i8 %5 to i32, !dbg !43
44-
%cmp20 = icmp ne i32 %conv19, 102, !dbg !44
45-
call void @svf_assert(i1 noundef zeroext %cmp20), !dbg !45
46-
ret i32 0, !dbg !46
36+
ret i32 0, !dbg !40
4737
}
4838

4939
; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
@@ -67,7 +57,7 @@ attributes #3 = { "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-pr
6757

6858
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
6959
!1 = distinct !DIGlobalVariable(scope: null, file: !2, line: 7, type: !3, isLocal: true, isDefinition: true)
70-
!2 = !DIFile(filename: "test14.c", directory: "/Users/z5489735/2023/0718/Software-Security-Analysis/Assignment-3/Tests/buf")
60+
!2 = !DIFile(filename: "test6.c", directory: "/Users/z5489735/2023/0718/Software-Security-Analysis/teaching/Assignment-3/Tests/buf")
7161
!3 = !DICompositeType(tag: DW_TAG_array_type, baseType: !4, size: 56, elements: !5)
7262
!4 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
7363
!5 = !{!6}
@@ -105,10 +95,4 @@ attributes #3 = { "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-pr
10595
!37 = !DILocation(line: 11, column: 16, scope: !16)
10696
!38 = !DILocation(line: 11, column: 26, scope: !16)
10797
!39 = !DILocation(line: 11, column: 5, scope: !16)
108-
!40 = !DILocation(line: 12, column: 16, scope: !16)
109-
!41 = !DILocation(line: 12, column: 26, scope: !16)
110-
!42 = !DILocation(line: 12, column: 5, scope: !16)
111-
!43 = !DILocation(line: 13, column: 16, scope: !16)
112-
!44 = !DILocation(line: 13, column: 26, scope: !16)
113-
!45 = !DILocation(line: 13, column: 5, scope: !16)
114-
!46 = !DILocation(line: 14, column: 5, scope: !16)
98+
!40 = !DILocation(line: 12, column: 5, scope: !16)

0 commit comments

Comments
 (0)