summaryrefslogtreecommitdiff
path: root/tools/asm_processor/compile.sh
blob: feef7fc9b920be15d405cfba9970f80fde091a3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash

CC="$1"
AS="$2"
OBJ="$3"
SRC="$4"

PADDED_SRC="$(mktemp --suffix=.c padded-XXXXXX)"
PADDED_OBJ="$(mktemp --suffix=.o padded-XXXXXX)"

# Create a .c file replacing the nonmatching function with volatile int writes, 
# and compile.
../tools/asm_processor/asm_processor.py "$SRC" --assembler "$AS" > "$PADDED_SRC"
$CC -c "$PADDED_SRC" -o "$PADDED_OBJ"

PRELUDE=$(mktemp)
cat ../include/macros.inc >> "$PRELUDE"
cat global.inc >> "$PRELUDE"

# Inject the matching assembly into the padded obj file.
../tools/asm_processor/asm_processor.py "$SRC" --post-process "$PADDED_OBJ" --assembler "$AS" --asm-prelude "$PRELUDE"

arm-none-eabi-objcopy --remove-section .comment "$PADDED_OBJ" "$OBJ"

rm "$PADDED_SRC"
rm "$PADDED_OBJ"
rm "$PRELUDE"
rm output.txt
rm asm_processor_temp.s
rm asm_processor_temp.o