]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gold/testsuite/aarch64_relocs.sh
3219bab3cd8c9883f877c35dd448cdebb068acf3
[thirdparty/binutils-gdb.git] / gold / testsuite / aarch64_relocs.sh
1 #!/bin/sh
2
3 # aarch64_relocs.sh -- test AArch64 relocations.
4
5 # Copyright (C) 2016-2022 Free Software Foundation, Inc.
6 # Written by Igor Kudrin <ikudrin@accesssoftek.com>
7
8 # This file is part of gold.
9
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 3 of the License, or
13 # (at your option) any later version.
14
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
19
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
23 # MA 02110-1301, USA.
24
25 check()
26 {
27 file=$1
28 lbl=$2
29 line=$3
30 pattern=$4
31
32 found=`grep "<$lbl>:" $file`
33 if test -z "$found"; then
34 echo "Label $lbl not found."
35 exit 1
36 fi
37
38 match_pattern=`grep "<$lbl>:" -A$line $file | tail -n 1 | grep -e "$pattern"`
39 if test -z "$match_pattern"; then
40 echo "Expected pattern did not found in line $line after label $lbl:"
41 echo " $pattern"
42 echo ""
43 echo "Extract:"
44 grep "<$lbl>:" -A$line $file
45 echo ""
46 echo "Actual output below:"
47 cat "$file"
48 exit 1
49 fi
50 }
51
52 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G0" 1 "\<mov[[:space:]]\+x4,[[:space:]]\+#0x1234\b"
53 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G0" 2 "\<R_AARCH64_MOVW_UABS_G0[[:space:]]\+abs_0x1234\b"
54 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G0" 3 "\<mov[[:space:]]\+x4,[[:space:]]\+#0x1238\b"
55 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G0" 4 "\<R_AARCH64_MOVW_UABS_G0[[:space:]]\+abs_0x1234+0x4\b"
56
57 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G0_NC" 1 "\<mov[[:space:]]\+x4,[[:space:]]\+#0x1234\b"
58 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G0_NC" 2 "\<R_AARCH64_MOVW_UABS_G0_NC[[:space:]]\+abs_0x1234\b"
59 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G0_NC" 3 "\<mov[[:space:]]\+x4,[[:space:]]\+#0x6234\b"
60 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G0_NC" 4 "\<R_AARCH64_MOVW_UABS_G0_NC[[:space:]]\+abs_0x1234+0x45000\b"
61
62 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G1" 1 "\<movz[[:space:]]\+x4,[[:space:]]\+#0x0, lsl #16\b"
63 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G1" 2 "\<R_AARCH64_MOVW_UABS_G1[[:space:]]\+abs_0x1234-0x4\b"
64 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G1" 3 "\<mov[[:space:]]\+x4,[[:space:]]\+#0x10000\b"
65 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G1" 4 "\<R_AARCH64_MOVW_UABS_G1[[:space:]]\+abs_0x11000\b"
66 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G1" 5 "\<mov[[:space:]]\+x4,[[:space:]]\+#0x60000\b"
67 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G1" 6 "\<R_AARCH64_MOVW_UABS_G1[[:space:]]\+abs_0x45000+0x20010\b"
68
69 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G1_NC" 1 "\<movz[[:space:]]\+x4,[[:space:]]\+#0x0, lsl #16\b"
70 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G1_NC" 2 "\<R_AARCH64_MOVW_UABS_G1_NC[[:space:]]\+abs_0x1234-0x4\b"
71 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G1_NC" 3 "\<mov[[:space:]]\+x4,[[:space:]]\+#0x10000\b"
72 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G1_NC" 4 "\<R_AARCH64_MOVW_UABS_G1_NC[[:space:]]\+abs_0x11000\b"
73 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G1_NC" 5 "\<mov[[:space:]]\+x4,[[:space:]]\+#0x60000\b"
74 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G1_NC" 6 "\<R_AARCH64_MOVW_UABS_G1_NC[[:space:]]\+abs_0x45000+0x100020010\b"
75
76 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G2" 1 "\<movz[[:space:]]\+x4,[[:space:]]\+#0x0, lsl #32\b"
77 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G2" 2 "\<R_AARCH64_MOVW_UABS_G2[[:space:]]\+abs_0x45000+0x20010\b"
78 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G2" 3 "\<mov[[:space:]]\+x4,[[:space:]]\+#0x3700000000\b"
79 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G2" 4 "\<R_AARCH64_MOVW_UABS_G2[[:space:]]\+abs_0x3600010000+0x100020010\b"
80
81 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G2_NC" 1 "\<movz[[:space:]]\+x4,[[:space:]]\+#0x0, lsl #32\b"
82 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G2_NC" 2 "\<R_AARCH64_MOVW_UABS_G2_NC[[:space:]]\+abs_0x45000+0x20010\b"
83 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G2_NC" 3 "\<mov[[:space:]]\+x4,[[:space:]]\+#0x3700000000\b"
84 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G2_NC" 4 "\<R_AARCH64_MOVW_UABS_G2_NC[[:space:]]\+abs_0x3600010000+0x3000100020010\b"
85
86 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G3" 1 "\<movz[[:space:]]\+x4,[[:space:]]\+#0x0, lsl #48\b"
87 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G3" 2 "\<R_AARCH64_MOVW_UABS_G3[[:space:]]\+abs_0x3600010000+0x100020010\b"
88 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G3" 3 "\<mov[[:space:]]\+x4,[[:space:]]\+#0x3000000000000\b"
89 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_UABS_G3" 4 "\<R_AARCH64_MOVW_UABS_G3[[:space:]]\+abs_0x3600010000+0x3000100020010\b"
90
91 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G0" 1 "\<mov[[:space:]]\+x4,[[:space:]]\+#0x1238\b"
92 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G0" 2 "\<R_AARCH64_MOVW_SABS_G0[[:space:]]\+abs_0x1234+0x4\b"
93 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G0" 3 "\<mov[[:space:]]\+x4,[[:space:]]\+#0xffffffffffffeeef\b"
94 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G0" 4 "\<R_AARCH64_MOVW_SABS_G0[[:space:]]\+abs_0x1234-0x2345\b"
95
96 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G1" 1 "\<movn[[:space:]]\+x4,[[:space:]]\+#0x0, lsl #16\b"
97 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G1" 2 "\<R_AARCH64_MOVW_SABS_G1[[:space:]]\+abs_0x1234-0x2345\b"
98 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G1" 3 "\<mov[[:space:]]\+x4,[[:space:]]\+#0x60000\b"
99 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G1" 4 "\<R_AARCH64_MOVW_SABS_G1[[:space:]]\+abs_0x45000+0x20010\b"
100 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G1" 5 "\<mov[[:space:]]\+x4,[[:space:]]\+#0xfffffffffffeffff\b"
101 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G1" 6 "\<R_AARCH64_MOVW_SABS_G1[[:space:]]\+abs_0x45000-0x56000\b"
102
103 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G2" 1 "\<movz[[:space:]]\+x4,[[:space:]]\+#0x0, lsl #32\b"
104 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G2" 2 "\<R_AARCH64_MOVW_SABS_G2[[:space:]]\+abs_0x45000+0x20010\b"
105 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G2" 3 "\<mov[[:space:]]\+x4,[[:space:]]\+#0x3700000000\b"
106 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G2" 4 "\<R_AARCH64_MOVW_SABS_G2[[:space:]]\+abs_0x3600010000+0x100020010\b"
107 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G2" 5 "\<mov[[:space:]]\+x4,[[:space:]]\+#0xfffffff2ffffffff\b"
108 check "aarch64_relocs.stdout" "test_R_AARCH64_MOVW_SABS_G2" 6 "\<R_AARCH64_MOVW_SABS_G2[[:space:]]\+abs_0x3600010000-0x4400010000\b"
109
110 exit 0