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,
25 file=aarch64_tlsdesc.stdout
27 get_address_by_reloc
()
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"
36 echo "Actual output below:"
40 eval $var="0x0$(echo $found | awk -F'[: ]' '{ print $1 }')"
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"
51 echo "Actual output below:"
57 get_address_from_ldr
()
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"
66 echo "Actual output below:"
70 eval $var="$(echo $found | awk -F'[#\\]]' '{ print $2 }')"
73 get_address_from_add
()
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"
82 echo "Actual output below:"
86 eval $var="$(echo $found | awk -F'#' '{ print $2 }')"
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."
97 echo "Actual output below:"
102 if test $
(($address_by_reloc)) -ne $
(($address_from_add)); then
103 echo "The address in ADD instruction is wrong."
105 echo "Actual output below:"