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 | output=jmpvar.s |
| 9 | for i |
| 10 | do |
| 11 | case $i in |
| 12 | -o) |
| 13 | output=$2 |
| 14 | shift 2 |
| 15 | ;; |
| 16 | --) |
| 17 | shift |
| 18 | break |
| 19 | ;; |
| 20 | -*) |
| 21 | echo usage: genvar.sh [-o output] file... >&2 |
| 22 | ;; |
| 23 | esac |
| 24 | done |
| 25 | |
| 26 | tmp=`mktemp` |
| 27 | trap "rm -f $tmp" EXIT INT QUIT |
| 28 | |
| 29 | nm -a "$@" | |
| 30 | awk -v OFS="\n" ' |
| 31 | $3 == ".text" {print "\t.data", |
| 32 | "\t.globl\tjmptbl", |
| 33 | "\t.align\t4", |
| 34 | "jmptbl:\t.quad\t0x" $1}' > $tmp |
| 35 | |
| 36 | mv $tmp $output |