From c7aa602b018d2681aa21b5a15b61cf7df3a24279 Mon Sep 17 00:00:00 2001 From: David Harris Date: Wed, 22 Mar 2023 11:17:17 -0700 Subject: [PATCH] Makefile improvements --- .gitignore | 2 ++ tests/coverage/Makefile | 28 +++++++++++++++++++++------- tests/coverage/badinstr.S | 12 ------------ 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 38d466cd..1f8e8b15 100644 --- a/.gitignore +++ b/.gitignore @@ -112,3 +112,5 @@ sim/results-error/ sim/test1.rep sim/vsim.log tests/coverage/*.S +tests/coverage/*.elf +*.elf.memfile \ No newline at end of file diff --git a/tests/coverage/Makefile b/tests/coverage/Makefile index e026fa41..57a8a1b5 100644 --- a/tests/coverage/Makefile +++ b/tests/coverage/Makefile @@ -1,13 +1,27 @@ -SRCS = $(wildcard *.S) -PROGS = $(patsubst %.S,%,$(SRCS)) +CEXT := c +CPPEXT := cpp +AEXT := s +SEXT := S +SRCEXT := \([$(CEXT)$(AEXT)$(SEXT)]\|$(CPPEXT)\) +#SRCS = $(wildcard *.S) +#PROGS = $(patsubst %.S,%,$(SRCS)) +SRCDIR = . +SRCEXT = S +SOURCES ?= $(shell find $(SRCDIR) -type f -regex ".*\.$(SRCEXT)" | sort) +OBJEXT = elf +OBJECTS := $(SOURCES:.$(SEXT)=.$(OBJEXT)) -all: $(PROGS) +all: $(OBJECTS) -%: %.S WALLY-init-lib.h Makefile +%.elf.objdump: %.elf + +%.elf: $(SRCDIR)/%.$(SEXT) WALLY-init-lib.h Makefile echo $@ - riscv64-unknown-elf-gcc -g -o $@.elf -march=rv64gc -mabi=lp64 -mcmodel=medany \ - -nostartfiles -T../../examples/link/link.ld $@.S - riscv64-unknown-elf-objdump -D $@.elf > $@.objdump + riscv64-unknown-elf-gcc -g -o $@ -march=rv64gc -mabi=lp64 -mcmodel=medany \ + -nostartfiles -T../../examples/link/link.ld $< + riscv64-unknown-elf-objdump -D $@ > $@.objdump + riscv64-unknown-elf-elf2hex --bit-width $(if $(findstring rv64,$*),64,32) --input $@ --output $@.memfile + extractFunctionRadix.sh $@.objdump sim: %.elf spike +signature=%.signature.output +signature-granularity=8 %.elf diff --git a/tests/coverage/badinstr.S b/tests/coverage/badinstr.S index e77f5c98..ec875eaa 100644 --- a/tests/coverage/badinstr.S +++ b/tests/coverage/badinstr.S @@ -33,16 +33,4 @@ main: .word 0x00000000 // illegal instruction j done -/* -main: - # Change to user mode - li a0, 0 # a0 = 0: argument to enter user mode - ecall # System call to enter user mode - # Wait for timer interrupts - li t0, 0x1000 # loop counter start value -loop: - addi t0, t0, -1 # decrement counter - bne t0, zero, loop # and repeat until zero - -*/ \ No newline at end of file