Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 1 | #!/bin/sh |
John Tsichritzis | aec19d3 | 2019-03-08 16:54:13 +0000 | [diff] [blame] | 2 | # Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved. |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | |
| 6 | set -e |
| 7 | |
| 8 | build=. |
| 9 | out=output.a |
| 10 | |
| 11 | for i |
| 12 | do |
| 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 |
| 31 | done |
| 32 | |
| 33 | awk '{sub(/[:blank:]*#.*/,"")} |
John Tsichritzis | aec19d3 | 2019-03-08 16:54:13 +0000 | [diff] [blame] | 34 | !/^$/ && $NF != "patch" && $NF != "reserved" {print $1*4, $2, $3}' "$@" | |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 35 | while read idx lib sym |
| 36 | do |
| 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 Tsichritzis | aec19d3 | 2019-03-08 16:54:13 +0000 | [diff] [blame] | 44 | mov x16, #$idx |
Roberto Vargas | e92111a | 2018-05-22 16:05:42 +0100 | [diff] [blame] | 45 | add x16, x16, x17 |
| 46 | br x16 |
| 47 | EOF |
| 48 | |
| 49 | ${CROSS_COMPILE}as -o $file.o $file.s |
| 50 | done |
| 51 | |
| 52 | ${CROSS_COMPILE}ar -rc $out $build/*.o |