1 | # $Id: op-validate.sed 2429 2007-04-30 13:09:10Z 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, 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 | /\.LFE[0-9][0-9]*:/d
|
---|
65 | /size[[:space:]]/d
|
---|
66 | /^[/#]NO_APP[[:space:]]*$/d
|
---|
67 | /^$/!b bad
|
---|
68 | b end
|
---|
69 |
|
---|
70 | #
|
---|
71 | # Verify that all jumps are to internal labels or to few select
|
---|
72 | # external labels.
|
---|
73 | #
|
---|
74 | #/^[[:blank:]]*jmp/
|
---|
75 | :jump
|
---|
76 | s/^[[:space:]]*j[a-z]*[[:space:]][[:space:]]*//
|
---|
77 | /^\.L/d
|
---|
78 | /^[1-9][fb]$/d
|
---|
79 | /^__op_gen_label1$/d
|
---|
80 | # two very special cases.
|
---|
81 | /^\*__op_param1+48[[:space:]][[:space:]]*#[[:space:]]*<variable>.tb_next[[:space:]]*$/d
|
---|
82 | /^\*__op_param1+52[[:space:]][[:space:]]*#[[:space:]]*<variable>.tb_next[[:space:]]*$/d
|
---|
83 | /^$/!b bad
|
---|
84 | b end
|
---|
85 |
|
---|
86 | # An error was found
|
---|
87 | :bad
|
---|
88 | q 1
|
---|
89 |
|
---|
90 | # next expression
|
---|
91 | :end
|
---|
92 |
|
---|