OLD | NEW |
| (Empty) |
1 #!/bin/bash | |
2 # Copyright (c) 2012 The Native Client Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 # Checks that a given assembyl file is decoded identically to objdump. | |
7 # | |
8 # Usage: | |
9 # decoder_test_one_file.sh GAS=... OBJDUMP=... DECODER=... ASMFILE=... | |
10 | |
11 set -e | |
12 set -u | |
13 | |
14 # Parse arguments. | |
15 eval "$@" | |
16 | |
17 # Sanity check arguments. | |
18 if [[ ! -x "${GAS% *}" || ! -x "${OBJDUMP% *}" || ! -x "${DECODER% *}" ]] ; then | |
19 echo >&2 "error: GAS or OBJDUMP or DECODER incorrect" | |
20 exit 2 | |
21 fi | |
22 | |
23 if [[ ! -f "$ASMFILE" ]] ; then | |
24 echo >&2 "error: ASMFILE is not a regular file: $ASMFILE" | |
25 exit 3 | |
26 fi | |
27 | |
28 # Produce an object file, disassemble it in 2 ways and compare results. | |
29 $GAS "$ASMFILE" -o "$ASMFILE.o" | |
30 rm -f "$ASMFILE" | |
31 $DECODER "$ASMFILE.o" > "$ASMFILE.decoder" | |
32 # Take objdump output starting at line 8 to skip the unimportant header that | |
33 # is not emulated in the decoder test. | |
34 $OBJDUMP -d "$ASMFILE.o" | | |
35 tail -n+8 - | | |
36 cmp - "$ASMFILE.decoder" | |
37 rm -f "$ASMFILE.o" "$ASMFILE.decoder" | |
OLD | NEW |