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