genwrappers.sh 713 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
# Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

set -e

build=.
out=output.a

for i
do
	case $i in
	-o)
		out=$2
		shift 2
		;;
	-b)
		build=$2
		shift 2
		;;
	--)
		shift
		break
		;;
	-*)
		echo usage: genwrappers.sh [-o output] [-b dir] file ... >&2
		exit 1
		;;
	esac
done

awk  '{sub(/[:blank:]*#.*/,"")}
34
!/^$/ && !/\\tpatch$/ !/\\treserved$/ {print $1*4, $2, $3}' "$@" |
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
while read idx lib sym
do
	file=$build/${lib}_$sym

	cat <<EOF > $file.s
	.globl	$sym
$sym:
	ldr	x17, =jmptbl
	ldr	x17, [x17]
	mov	x16, $idx
	add	x16, x16, x17
	br	x16
EOF

	${CROSS_COMPILE}as -o $file.o $file.s
done

${CROSS_COMPILE}ar -rc $out $build/*.o