blob: 07d59ac4591e07ca424255918b0662e161e8118e [file] [log] [blame]
Roberto Vargase92111a2018-05-22 16:05:42 +01001#!/bin/sh
John Tsichritzisaec19d32019-03-08 16:54:13 +00002# Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
Roberto Vargase92111a2018-05-22 16:05:42 +01003#
4# SPDX-License-Identifier: BSD-3-Clause
5
6set -e
7
8build=.
9out=output.a
10
11for i
12do
13 case $i in
14 -o)
15 out=$2
16 shift 2
17 ;;
18 -b)
19 build=$2
20 shift 2
21 ;;
22 --)
23 shift
24 break
25 ;;
26 -*)
27 echo usage: genwrappers.sh [-o output] [-b dir] file ... >&2
28 exit 1
29 ;;
30 esac
31done
32
33awk '{sub(/[:blank:]*#.*/,"")}
John Tsichritzisaec19d32019-03-08 16:54:13 +000034!/^$/ && $NF != "patch" && $NF != "reserved" {print $1*4, $2, $3}' "$@" |
Roberto Vargase92111a2018-05-22 16:05:42 +010035while read idx lib sym
36do
37 file=$build/${lib}_$sym
38
39 cat <<EOF > $file.s
40 .globl $sym
41$sym:
42 ldr x17, =jmptbl
43 ldr x17, [x17]
John Tsichritzisaec19d32019-03-08 16:54:13 +000044 mov x16, #$idx
Roberto Vargase92111a2018-05-22 16:05:42 +010045 add x16, x16, x17
46 br x16
47EOF
48
49 ${CROSS_COMPILE}as -o $file.o $file.s
50done
51
52${CROSS_COMPILE}ar -rc $out $build/*.o