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=jmptbl.s |
| 9 | |
| 10 | for i |
| 11 | do |
| 12 | case $i in |
| 13 | -o) |
| 14 | output=$2 |
| 15 | shift 2 |
| 16 | ;; |
| 17 | --) |
| 18 | shift |
| 19 | break |
| 20 | ;; |
| 21 | -*) |
| 22 | echo usage: gentbl.sh [-o output] file ... >&2 |
| 23 | exit 1 |
| 24 | ;; |
| 25 | esac |
| 26 | done |
| 27 | |
| 28 | tmp=`mktemp` |
| 29 | trap "rm -f $tmp" EXIT INT QUIT |
| 30 | |
| 31 | rm -f $output |
| 32 | |
| 33 | awk -v OFS="\n" ' |
| 34 | BEGIN {print "\t.text", |
| 35 | "\t.globl\tjmptbl", |
| 36 | "jmptbl:"} |
| 37 | {sub(/[:blank:]*#.*/,"")} |
| 38 | !/^$/ {print "\tb\t" $3}' "$@" > $tmp |
| 39 | |
| 40 | mv $tmp $output |