1 | # $Id: op-validate.sed 1 1970-01-01 00:00:00Z vboxsync $
|
---|
2 | ## @file
|
---|
3 | #
|
---|
4 | # Just some quit sed hacks for validating an op.S assembly file.
|
---|
5 | # Will try this with gcc 4.x later to see if we can permit gcc 4
|
---|
6 | # to build op.c by using this script as guard against bad code.
|
---|
7 | #
|
---|
8 |
|
---|
9 | ## @todo need to check that we've the got two __op_label[0-1].op_goto_tb[0-1] symbols!
|
---|
10 |
|
---|
11 | # if (ret) goto return
|
---|
12 | /^[[:space:]]*ret[[:space:]]*$/b return
|
---|
13 | #/^[[:space:]]*retn[[:space:]]*$/b bad
|
---|
14 |
|
---|
15 | # if (jmp) goto jump
|
---|
16 | /^[[:space:]]*[^j]/b skip_jump_checks
|
---|
17 | /^[[:space:]]*jmp[[:space:]][[:space:]]*/b jump
|
---|
18 | /^[[:space:]]*ja[[:space:]][[:space:]]*/b jump
|
---|
19 | /^[[:space:]]*jae[[:space:]][[:space:]]*/b jump
|
---|
20 | /^[[:space:]]*jb[[:space:]][[:space:]]*/b jump
|
---|
21 | /^[[:space:]]*jbe[[:space:]][[:space:]]*/b jump
|
---|
22 | /^[[:space:]]*jc[[:space:]][[:space:]]*/b jump
|
---|
23 | /^[[:space:]]*je[[:space:]][[:space:]]*/b jump
|
---|
24 | /^[[:space:]]*jg[[:space:]][[:space:]]*/b jump
|
---|
25 | /^[[:space:]]*jge[[:space:]][[:space:]]*/b jump
|
---|
26 | /^[[:space:]]*jl[[:space:]][[:space:]]*/b jump
|
---|
27 | /^[[:space:]]*jle[[:space:]][[:space:]]*/b jump
|
---|
28 | /^[[:space:]]*jnae[[:space:]][[:space:]]*/b jump
|
---|
29 | /^[[:space:]]*jnb[[:space:]][[:space:]]*/b jump
|
---|
30 | /^[[:space:]]*jnbe[[:space:]][[:space:]]*/b jump
|
---|
31 | /^[[:space:]]*jnc[[:space:]][[:space:]]*/b jump
|
---|
32 | /^[[:space:]]*jne[[:space:]][[:space:]]*/b jump
|
---|
33 | /^[[:space:]]*jng[[:space:]][[:space:]]*/b jump
|
---|
34 | /^[[:space:]]*jnge[[:space:]][[:space:]]*/b jump
|
---|
35 | /^[[:space:]]*jnl[[:space:]][[:space:]]*/b jump
|
---|
36 | /^[[:space:]]*jnle[[:space:]][[:space:]]*/b jump
|
---|
37 | /^[[:space:]]*jno[[:space:]][[:space:]]*/b jump
|
---|
38 | /^[[:space:]]*jnp[[:space:]][[:space:]]*/b jump
|
---|
39 | /^[[:space:]]*jns[[:space:]][[:space:]]*/b jump
|
---|
40 | /^[[:space:]]*jnz[[:space:]][[:space:]]*/b jump
|
---|
41 | /^[[:space:]]*jo[[:space:]][[:space:]]*/b jump
|
---|
42 | /^[[:space:]]*jp[[:space:]][[:space:]]*/b jump
|
---|
43 | /^[[:space:]]*jpe[[:space:]][[:space:]]*/b jump
|
---|
44 | /^[[:space:]]*jpo[[:space:]][[:space:]]*/b jump
|
---|
45 | /^[[:space:]]*js[[:space:]][[:space:]]*/b jump
|
---|
46 | /^[[:space:]]*jz[[:space:]][[:space:]]*/b jump
|
---|
47 | :skip_jump_checks
|
---|
48 |
|
---|
49 | # Everything else is discarded!
|
---|
50 | d
|
---|
51 | b end
|
---|
52 |
|
---|
53 |
|
---|
54 | #
|
---|
55 | # Verify that all ret statements are at the end of a function by
|
---|
56 | # inspecting what's on the following line. It must either be a
|
---|
57 | # .size statement, a .LfeXXXX label or #NO_APP comment.
|
---|
58 | #
|
---|
59 | # @todo figure out how to discard the first line in a simpler fashion.
|
---|
60 | :return
|
---|
61 | N
|
---|
62 | s/^[[:blank:]]*ret[[:blank:]]*\n*[[:blank:]]*//
|
---|
63 | /\.Lfe[0-9][0-9]*:/d
|
---|
64 | /size[[:space:]]/d
|
---|
65 | /^[/#]NO_APP[[:space:]]*$/d
|
---|
66 | /^$/!b bad
|
---|
67 | b end
|
---|
68 |
|
---|
69 | #
|
---|
70 | # Verify that all jumps are to internal labels or to few select
|
---|
71 | # external labels.
|
---|
72 | #
|
---|
73 | #/^[[:blank:]]*jmp/
|
---|
74 | :jump
|
---|
75 | s/^[[:space:]]*j[a-z]*[[:space:]][[:space:]]*//
|
---|
76 | /^\.L/d
|
---|
77 | /^[1-9][fb]$/d
|
---|
78 | /^__op_gen_label1$/d
|
---|
79 | # two very special cases.
|
---|
80 | /^\*__op_param1+48[[:space:]][[:space:]]*#[[:space:]]*<variable>.tb_next[[:space:]]*$/d
|
---|
81 | /^\*__op_param1+52[[:space:]][[:space:]]*#[[:space:]]*<variable>.tb_next[[:space:]]*$/d
|
---|
82 | /^$/!b bad
|
---|
83 | b end
|
---|
84 |
|
---|
85 | # An error was found
|
---|
86 | :bad
|
---|
87 | q 1
|
---|
88 |
|
---|
89 | # next expression
|
---|
90 | :end
|
---|
91 |
|
---|