blob: bcf670b980fefde374d3866617fe3fb1d06521ae [file] [log] [blame]
Roberto Vargase92111a2018-05-22 16:05:42 +01001#!/bin/sh
2# Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
3#
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:]*#.*/,"")}
34!/^$/ {print $1*4, $2, $3}' "$@" |
35while 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]
44 mov x16, $idx
45 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