3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
6 # 1.0 of the CDDL.
7 #
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
11 #
12
13 # Copyright 2012, Richard Lowe.
14
15 function grep_test {
16 name=$1
17 pattern=$2
18
19 if /usr/bin/fgrep -q "${pattern}"; then
20 print -u2 "pass: $name"
21 else
22 print -u2 "FAIL: $name"
23 fi
24 }
25
26 function dis_test {
27 name=${1}
28 func=${2}
29 file=${3}
30 pattern=${4}
31
32 dis -F${func} ${file} | grep_test "${name}" "${pattern}"
33 }
34
35 make PROTO="${1}"
36
37 dis_test "addq-->leaq 1" func style1 \
38 'func+0x10: 48 8d 92 f8 ff ff leaq -0x8(%rdx),%rdx'
39 dis_test "addq-->leaq 2" func style1 \
40 'func+0x17: 48 8d b6 f0 ff ff leaq -0x10(%rsi),%rsi'
41
42 dis_test "addq-->leaq w/REX 1" func style1-with-r13 \
43 'func+0x10: 48 8d 92 f8 ff ff leaq -0x8(%rdx),%rdx'
44 dis_test "addq-->leaq w/REX 2" func style1-with-r13 \
45 'func+0x17: 4d 8d ad f0 ff ff leaq -0x10(%r13),%r13'
46
47 dis_test "addq-->addq for SIB 1" func style1-with-r12 \
48 'func+0x10: 48 8d 92 f8 ff ff leaq -0x8(%rdx),%rdx'
49 dis_test "addq-->addq for SIB 2" func style1-with-r12 \
50 'func+0x17: 49 81 c4 f0 ff ff addq $-0x10,%r12 <0xfffffffffffffff0>'
51
52 dis_test "movq-->movq" main style2 \
53 'main+0x4: 48 c7 c6 f0 ff ff movq $-0x10,%rsi <0xfffffffffffffff0>'
54
55 dis_test "movq-->movq w/REX" main style2-with-r13 \
56 'main+0x4: 49 c7 c5 f0 ff ff movq $-0x10,%r13 <0xfffffffffffffff0>'
57
58 dis_test "movq-->movq incase of SIB" main style2-with-r12 \
59 'main+0x4: 49 c7 c4 f0 ff ff movq $-0x10,%r12 <0xfffffffffffffff0>'
60
61 make PROTO="${1}" fail 2>&1 | grep_test "bad insn sequence" \
62 'ld: fatal: relocation error: R_AMD64_TPOFF32: file style2-with-badness.o: symbol foo: section .text: offset 0x7, relocation against unknown TLS instruction sequence'
|
3 # This file and its contents are supplied under the terms of the
4 # Common Development and Distribution License ("CDDL"), version 1.0.
5 # You may only use this file in accordance with the terms of version
6 # 1.0 of the CDDL.
7 #
8 # A full copy of the text of the CDDL should have accompanied this
9 # source. A copy of the CDDL is also available via the Internet at
10 # http://www.illumos.org/license/CDDL.
11 #
12
13 # Copyright 2012, Richard Lowe.
14
15 function grep_test {
16 name=$1
17 pattern=$2
18
19 if /usr/bin/fgrep -q "${pattern}"; then
20 print -u2 "pass: $name"
21 else
22 print -u2 "FAIL: $name"
23 exit 1
24 fi
25 }
26
27 function dis_test {
28 name=${1}
29 func=${2}
30 file=${3}
31 pattern=${4}
32
33 dis -F${func} ${file} | grep_test "${name}" "${pattern}"
34 }
35
36 TESTDIR=$(dirname $0)
37 make -f ${TESTDIR}/Makefile.test TESTDIR=${TESTDIR}
38
39 dis_test "addq-->leaq 1" func style1 \
40 'func+0x10: 48 8d 92 f8 ff ff leaq -0x8(%rdx),%rdx'
41 dis_test "addq-->leaq 2" func style1 \
42 'func+0x17: 48 8d b6 f0 ff ff leaq -0x10(%rsi),%rsi'
43
44 dis_test "addq-->leaq w/REX 1" func style1-with-r13 \
45 'func+0x10: 48 8d 92 f8 ff ff leaq -0x8(%rdx),%rdx'
46 dis_test "addq-->leaq w/REX 2" func style1-with-r13 \
47 'func+0x17: 4d 8d ad f0 ff ff leaq -0x10(%r13),%r13'
48
49 dis_test "addq-->addq for SIB 1" func style1-with-r12 \
50 'func+0x10: 48 8d 92 f8 ff ff leaq -0x8(%rdx),%rdx'
51 dis_test "addq-->addq for SIB 2" func style1-with-r12 \
52 'func+0x17: 49 81 c4 f0 ff ff addq $-0x10,%r12 <0xfffffffffffffff0>'
53
54 dis_test "movq-->movq" main style2 \
55 'main+0x4: 48 c7 c6 f0 ff ff movq $-0x10,%rsi <0xfffffffffffffff0>'
56
57 dis_test "movq-->movq w/REX" main style2-with-r13 \
58 'main+0x4: 49 c7 c5 f0 ff ff movq $-0x10,%r13 <0xfffffffffffffff0>'
59
60 dis_test "movq-->movq incase of SIB" main style2-with-r12 \
61 'main+0x4: 49 c7 c4 f0 ff ff movq $-0x10,%r12 <0xfffffffffffffff0>'
62
63 make -f ${TESTDIR}/Makefile.test fail TESTDIR=${TESTDIR} 2>&1 | grep_test "bad insn sequence" \
64 'ld: fatal: relocation error: R_AMD64_TPOFF32: file style2-with-badness.o: symbol foo: section .text: offset 0x7, relocation against unknown TLS instruction sequence'
|