Automatic date update in version.in
[binutils-gdb.git] / gold / testsuite / aarch64_tlsdesc.sh
blobd5a875475fbda866a1dcd46e13bfd61386833e2c
1 #!/bin/sh
3 # aarch64_tlsdesc.sh -- test R_AARCH64_TLSDESC_* relocations.
5 # Copyright (C) 2017-2022 Free Software Foundation, Inc.
6 # Written by Igor Kudrin <ikudrin@accesssoftek.com>.
8 # This file is part of gold.
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.
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.
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.
25 file=aarch64_tlsdesc.stdout
27 get_address_by_reloc()
29 var=$1
30 pattern="\<R_AARCH64_TLSDESC\>"
31 found=$(grep "$pattern" "$file")
32 if test -z "$found"; then
33 echo "GOT entry for a TLS symbol is not found in file $file."
34 echo "Search pattern: $pattern"
35 echo ""
36 echo "Actual output below:"
37 cat "$file"
38 exit 1
40 eval $var="0x0$(echo $found | awk -F'[: ]' '{ print $1 }')"
43 check_adrp()
45 pattern="\<adrp[[:space:]]\+x0, 0\>"
46 found=$(grep "$pattern" "$file")
47 if test -z "$found"; then
48 echo "An ADRP immediate is supposed to be 0"
49 echo "Search pattern: $pattern"
50 echo ""
51 echo "Actual output below:"
52 cat "$file"
53 exit 1
57 get_address_from_ldr()
59 var=$1
60 pattern="\<ldr[[:space:]]\+x1\>"
61 found=$(grep "$pattern" "$file")
62 if test -z "$found"; then
63 echo "An LDR instruction is not found in file $file."
64 echo "Search pattern: $pattern"
65 echo ""
66 echo "Actual output below:"
67 cat "$file"
68 exit 1
70 eval $var="$(echo $found | awk -F'[#\\]]' '{ print $2 }')"
73 get_address_from_add()
75 var=$1
76 pattern="\<add[[:space:]]\+x0\>"
77 found=$(grep "$pattern" "$file")
78 if test -z "$found"; then
79 echo "An ADD instruction is not found in file $file."
80 echo "Search pattern: $pattern"
81 echo ""
82 echo "Actual output below:"
83 cat "$file"
84 exit 1
86 eval $var="$(echo $found | awk -F'#' '{ print $2 }')"
89 check_adrp
90 get_address_by_reloc address_by_reloc
91 get_address_from_ldr address_from_ldr
92 get_address_from_add address_from_add
94 if test $(($address_by_reloc)) -ne $(($address_from_ldr)); then
95 echo "The address in LDR instruction is wrong."
96 echo ""
97 echo "Actual output below:"
98 cat "$file"
99 exit 1
102 if test $(($address_by_reloc)) -ne $(($address_from_add)); then
103 echo "The address in ADD instruction is wrong."
104 echo ""
105 echo "Actual output below:"
106 cat "$file"
107 exit 1
110 exit 0