aboutsummaryrefslogtreecommitdiffstats
path: root/lib/romlib/genwrappers.sh
diff options
context:
space:
mode:
authorJohn Tsichritzis <john.tsichritzis@arm.com>2019-05-21 15:47:37 +0100
committerJohn Tsichritzis <john.tsichritzis@arm.com>2019-05-24 12:36:52 +0100
commitbbb24f611c92ada192ed7a6825da8b477fd6bcfb (patch)
tree42047e91ddba7294625ad3bdc85397e0d4f9d10a /lib/romlib/genwrappers.sh
parentced1711297347f24fee45e75e73c7767507a0982 (diff)
downloadplatform_external_arm-trusted-firmware-bbb24f611c92ada192ed7a6825da8b477fd6bcfb.tar.gz
platform_external_arm-trusted-firmware-bbb24f611c92ada192ed7a6825da8b477fd6bcfb.tar.bz2
platform_external_arm-trusted-firmware-bbb24f611c92ada192ed7a6825da8b477fd6bcfb.zip
Introduce BTI support in ROMLIB
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>
Diffstat (limited to 'lib/romlib/genwrappers.sh')
-rwxr-xr-xlib/romlib/genwrappers.sh27
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/romlib/genwrappers.sh b/lib/romlib/genwrappers.sh
index 07d59ac45..e092548e0 100755
--- a/lib/romlib/genwrappers.sh
+++ b/lib/romlib/genwrappers.sh
@@ -19,6 +19,14 @@ do
build=$2
shift 2
;;
+ --bti=*)
+ enable_bti=$(echo $1 | sed 's/--bti=\(.*\)/\1/')
+ shift 1
+ ;;
+ --asflags=*)
+ asflags=$(echo $1 | sed 's/--asflags=\(.*\)/\1/')
+ shift 1
+ ;;
--)
shift
break
@@ -30,8 +38,13 @@ do
esac
done
-awk '{sub(/[:blank:]*#.*/,"")}
-!/^$/ && $NF != "patch" && $NF != "reserved" {print $1*4, $2, $3}' "$@" |
+awk -v BTI=$enable_bti '
+{sub(/[:blank:]*#.*/,"")}
+!/^$/ && $NF != "patch" && $NF != "reserved" {
+ if (BTI == 1)
+ print $1*8, $2, $3
+ else
+ print $1*4, $2, $3}' "$@" |
while read idx lib sym
do
file=$build/${lib}_$sym
@@ -39,14 +52,20 @@ do
cat <<EOF > $file.s
.globl $sym
$sym:
+EOF
+if [ $enable_bti = 1 ]
+then
+ echo "\tbti\tjc" >> $file.s
+fi
+ cat <<EOF >> $file.s
ldr x17, =jmptbl
- ldr x17, [x17]
mov x16, #$idx
+ ldr x17, [x17]
add x16, x16, x17
br x16
EOF
- ${CROSS_COMPILE}as -o $file.o $file.s
+ ${CROSS_COMPILE}as ${asflags} -o $file.o $file.s
done
${CROSS_COMPILE}ar -rc $out $build/*.o