| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | |
| 3 | # aarch64_tlsdesc.sh -- test R_AARCH64_TLSDESC_* relocations. |
| 4 | |
| 5 | # Copyright (C) 2017-2020 Free Software Foundation, Inc. |
| 6 | # Written by Igor Kudrin <[email protected]>. |
| 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 | file=aarch64_tlsdesc.stdout |
| 26 | |
| 27 | get_address_by_relocscip-shell shell binutils-djgpp 2.35.1+dfsg-2 get_address_by_reloc().() |
| 28 | { |
| 29 | var=$1 |
| 30 | pattern="\<R_AARCH64_TLSDESC\>" |
| 31 | found=$(grepscip-shell system . . grep. "$pattern" "$file") |
| 32 | if testscip-shell system . . test. -z "$found"; then |
| 33 | echoscip-shell system . . echo. "GOT entry for a TLS symbol is not found in file $file." |
| 34 | echoscip-shell system . . echo. "Search pattern: $pattern" |
| 35 | echoscip-shell system . . echo. "" |
| 36 | echoscip-shell system . . echo. "Actual output below:" |
| 37 | catscip-shell system . . cat. "$file" |
| 38 | exit 1 |
| 39 | fi |
| 40 | eval $var="0x0$(echoscip-shell system . . echo. $found | awkscip-shell system . . awk. -F'[: ]' '{ print $1 }')" |
| 41 | } |
| 42 | |
| 43 | check_adrpscip-shell shell binutils-djgpp 2.35.1+dfsg-2 check_adrp().() |
| 44 | { |
| 45 | pattern="\<adrp[[:space:]]\+x0, 0\>" |
| 46 | found=$(grepscip-shell system . . grep. "$pattern" "$file") |
| 47 | if testscip-shell system . . test. -z "$found"; then |
| 48 | echoscip-shell system . . echo. "An ADRP immediate is supposed to be 0" |
| 49 | echoscip-shell system . . echo. "Search pattern: $pattern" |
| 50 | echoscip-shell system . . echo. "" |
| 51 | echoscip-shell system . . echo. "Actual output below:" |
| 52 | catscip-shell system . . cat. "$file" |
| 53 | exit 1 |
| 54 | fi |
| 55 | } |
| 56 | |
| 57 | get_address_from_ldrscip-shell shell binutils-djgpp 2.35.1+dfsg-2 get_address_from_ldr().() |
| 58 | { |
| 59 | var=$1 |
| 60 | pattern="\<ldr[[:space:]]\+x1\>" |
| 61 | found=$(grepscip-shell system . . grep. "$pattern" "$file") |
| 62 | if testscip-shell system . . test. -z "$found"; then |
| 63 | echoscip-shell system . . echo. "An LDR instruction is not found in file $file." |
| 64 | echoscip-shell system . . echo. "Search pattern: $pattern" |
| 65 | echoscip-shell system . . echo. "" |
| 66 | echoscip-shell system . . echo. "Actual output below:" |
| 67 | catscip-shell system . . cat. "$file" |
| 68 | exit 1 |
| 69 | fi |
| 70 | eval $var="$(echoscip-shell system . . echo. $found | awkscip-shell system . . awk. -F'[#\\]]' '{ print $2 }')" |
| 71 | } |
| 72 | |
| 73 | get_address_from_addscip-shell shell binutils-djgpp 2.35.1+dfsg-2 get_address_from_add().() |
| 74 | { |
| 75 | var=$1 |
| 76 | pattern="\<add[[:space:]]\+x0\>" |
| 77 | found=$(grepscip-shell system . . grep. "$pattern" "$file") |
| 78 | if testscip-shell system . . test. -z "$found"; then |
| 79 | echoscip-shell system . . echo. "An ADD instruction is not found in file $file." |
| 80 | echoscip-shell system . . echo. "Search pattern: $pattern" |
| 81 | echoscip-shell system . . echo. "" |
| 82 | echoscip-shell system . . echo. "Actual output below:" |
| 83 | catscip-shell system . . cat. "$file" |
| 84 | exit 1 |
| 85 | fi |
| 86 | eval $var="$(echoscip-shell system . . echo. $found | awkscip-shell system . . awk. -F'#' '{ print $2 }')" |
| 87 | } |
| 88 | |
| 89 | check_adrpscip-shell shell binutils-djgpp 2.35.1+dfsg-2 check_adrp(). |
| 90 | get_address_by_relocscip-shell shell binutils-djgpp 2.35.1+dfsg-2 get_address_by_reloc(). address_by_reloc |
| 91 | get_address_from_ldrscip-shell shell binutils-djgpp 2.35.1+dfsg-2 get_address_from_ldr(). address_from_ldr |
| 92 | get_address_from_addscip-shell shell binutils-djgpp 2.35.1+dfsg-2 get_address_from_add(). address_from_add |
| 93 | |
| 94 | if testscip-shell system . . test. $(($address_by_reloc)) -ne $(($address_from_ldr)); then |
| 95 | echoscip-shell system . . echo. "The address in LDR instruction is wrong." |
| 96 | echoscip-shell system . . echo. "" |
| 97 | echoscip-shell system . . echo. "Actual output below:" |
| 98 | catscip-shell system . . cat. "$file" |
| 99 | exit 1 |
| 100 | fi |
| 101 | |
| 102 | if testscip-shell system . . test. $(($address_by_reloc)) -ne $(($address_from_add)); then |
| 103 | echoscip-shell system . . echo. "The address in ADD instruction is wrong." |
| 104 | echoscip-shell system . . echo. "" |
| 105 | echoscip-shell system . . echo. "Actual output below:" |
| 106 | catscip-shell system . . cat. "$file" |
| 107 | exit 1 |
| 108 | fi |
| 109 | |
| 110 | exit 0 |