2020-11-10 00:19:42 -07:00
|
|
|
all: text.hex data.hex
|
2020-09-27 18:04:08 -06:00
|
|
|
|
|
|
|
CC = riscv64-linux-gnu-gcc
|
|
|
|
# CFLAGS = -march=rv32i -mabi=ilp32
|
2020-10-03 13:49:14 -06:00
|
|
|
CFLAGS = -march=rv64i -mabi=lp64 -o0
|
2020-09-27 18:04:08 -06:00
|
|
|
|
|
|
|
AS = riscv64-linux-gnu-as
|
|
|
|
ASFLAGS = $(CFLAGS)
|
|
|
|
|
|
|
|
LD = riscv64-linux-gnu-ld
|
|
|
|
LDFLAGS = -T test.ld
|
|
|
|
|
|
|
|
%.o: %.S
|
|
|
|
$(AS) $(ASFLAGS) $^ -o $@
|
|
|
|
|
2020-09-27 18:38:35 -06:00
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) $^ -o $@
|
|
|
|
|
2020-09-27 18:04:08 -06:00
|
|
|
%.elf: %.o
|
|
|
|
$(LD) $(LDFLAGS) $^ -o $@
|
|
|
|
|
2020-11-10 00:19:42 -07:00
|
|
|
text.hex: test.elf
|
|
|
|
riscv64-linux-gnu-objdump -s $^ | sed -n '/.text/,$$p' | tail -n+2 | sed -n '/.data/,$$!p' | cut -f3-6 -d ' ' | sed -e 's/ /\n/g' | sed 's/^\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/' > $@
|
|
|
|
|
|
|
|
data.hex: test.elf
|
|
|
|
riscv64-linux-gnu-objdump -s $^ | sed -n '/.data/,$$p' | tail -n+2 | sed -n '/.bss/,$$!p' | cut -f3-6 -d ' ' | sed -e 's/ /\n/g' | sed 's/^\(..\)\(..\)\(..\)\(..\)/\4\3\2\1/' > $@
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm test.elf text.hex data.hex
|