mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-16 01:24:27 +00:00

When TF-A is compiled with BTI enabled, the branches in the ROMLIB jumptable must be preceded by a "bti j" instruction. Moreover, when the additional "bti" instruction is inserted, the jumptable entries have a distance of 8 bytes between them instead of 4. Hence, the wrappers are also modified accordinly. If TF-A is compiled without BTI enabled, the ROMLIB jumptable and wrappers are generated as before. Change-Id: Iaa59897668f8e59888d39046233300c2241d8de7 Signed-off-by: John Tsichritzis <john.tsichritzis@arm.com>
66 lines
1.1 KiB
Bash
Executable file
66 lines
1.1 KiB
Bash
Executable file
#!/bin/sh
|
|
# Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
|
|
#
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
set -e
|
|
|
|
output=jmptbl.s
|
|
build=.
|
|
|
|
for i
|
|
do
|
|
case $i in
|
|
-o)
|
|
output=$2
|
|
shift 2
|
|
;;
|
|
-b)
|
|
build=$2
|
|
shift 2
|
|
;;
|
|
--bti=*)
|
|
enable_bti=$(echo $1 | sed 's/--bti=\(.*\)/\1/')
|
|
shift 1
|
|
;;
|
|
--)
|
|
shift
|
|
break
|
|
;;
|
|
-*)
|
|
echo usage: gentbl.sh [-o output] [-b dir] file ... >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
tmp=`mktemp`
|
|
trap "rm -f $$.tmp" EXIT INT QUIT
|
|
rm -f $output
|
|
|
|
# Pre-process include files
|
|
awk '!/^$/ && !/[:blank:]*#.*/{
|
|
if (NF == 2 && $1 == "include") {
|
|
while ((getline line < $2) > 0)
|
|
if (line !~ /^$/ && line !~ /[:blank:]*#.*/)
|
|
print line
|
|
close($2)
|
|
} else
|
|
print
|
|
}' "$@" |
|
|
awk -v OFS="\t" '
|
|
BEGIN{print "#index\tlib\tfunction\t[patch]"}
|
|
{print NR-1, $0}' | tee $build/jmptbl.i |
|
|
awk -v OFS="\n" -v BTI=$enable_bti '
|
|
BEGIN {print "\t.text",
|
|
"\t.globl\tjmptbl",
|
|
"jmptbl:"}
|
|
{sub(/[:blank:]*#.*/,"")}
|
|
!/^$/ {
|
|
if (BTI == 1)
|
|
print "\tbti\tj"
|
|
if ($3 == "reserved")
|
|
print "\t.word\t0x0"
|
|
else
|
|
print "\tb\t" $3}' > $$.tmp &&
|
|
mv $$.tmp $output
|