diff --git a/tests/C/long_test1/Makefile b/tests/C/long_test1/Makefile index fc446be..220c92f 100644 --- a/tests/C/long_test1/Makefile +++ b/tests/C/long_test1/Makefile @@ -1,16 +1,16 @@ TARGET = long_test1 -TARGET_ARCH=riscv32 +TARGET_ARCH = riscv32 CC = riscv32-unknown-elf-gcc # compiling flags here CFLAGS = -Wall -I. -O0 -static -march=rv32imac -mabi=ilp32 --specs=nosys.specs +# CFLAGS = -Wall -I. -O0 -static -march=rv32imac -mabi=ilp32 --specs=nano.specs - -LINKER = riscv32-unknown-linux-gnu-gcc +LINKER = riscv32-unknown-elf-gcc # linking flags here -LDFLAGS = -I. --entry main -L/opt/riscv/riscv32-unknown-elf/lib/ -T ld_script.ld +LDFLAGS = -I. -static LIBS = $(EXTRA_LIBS) @@ -30,15 +30,14 @@ rm = rm -f $(BINDIR)/$(TARGET): $(OBJECTS) -# $(LINKER) $(OBJECTS) $(LDFLAGS) $(LIBS) $(LIBDIR) -o $@ - riscv32-unknown-elf-objdump -d $< > dump - riscv32-unknown-elf-objcopy -Oihex $< $(TARGET).hex -# @echo "Linking complete!" + $(LINKER) $(CFLAGS) $(LDFLAGS) $(LIBS) $(LIBDIR) $(OBJECTS) -o $@ + riscv32-unknown-elf-objdump -d $@ > dump + riscv32-unknown-elf-objcopy -Oihex $@ $(TARGET).hex + @echo "Linking complete!" $(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c @echo "Compiling "$<" ..." -# $(CC) $(CFLAGS) $(INCDIR) -c $< -o $@ - $(CC) $(CFLAGS) $(INCDIR) $< -o $@ + $(CC) $(CFLAGS) $(INCDIR) -c $< -o $@ @echo "Done!" .PHONY: clean diff --git a/tests/C/long_test1/helper_functions.c b/tests/C/long_test1/helper_functions.c new file mode 100644 index 0000000..18efcba --- /dev/null +++ b/tests/C/long_test1/helper_functions.c @@ -0,0 +1,35 @@ +#include +#include + + +#define TRACE (*(unsigned char *)0x40000000) +int _read(int file, char* ptr, int len) { + return 0; +} + +int _close(int fd){ + return 0; +} + +int _fstat_r(int fd) { + return 0; +} + +int _lseek_r(struct _reent *ptr, FILE *fp, long offset, int whence){ + return 0; +} + +int _isatty_r(struct _reent *ptr, int fd) { + return 0; +} + +int _write(int file, const char *ptr, int len) { + int x; + + for (x = 0; x < len; x++) { + TRACE = *ptr++; + } + + return (len); +} + diff --git a/tests/C/long_test1/long_test1.c b/tests/C/long_test1/long_test1.c index d2d8a70..71fcb49 100644 --- a/tests/C/long_test1/long_test1.c +++ b/tests/C/long_test1/long_test1.c @@ -1,36 +1,7 @@ #include #include -#define TRACE (*(unsigned char *)0x40000000) -int _read(int file, char* ptr, int len) { - return 0; -} -int _close(int fd){ - return 0; -} - -int _fstat_r(int fd) { - return 0; -} - -int _lseek_r(struct _reent *ptr, FILE *fp, long offset, int whence){ - return 0; -} - -int _isatty_r(struct _reent *ptr, int fd) { - return 0; -} - -int _write(int file, const char *ptr, int len) { - int x; - - for (x = 0; x < len; x++) { - TRACE = *ptr++; - } - - return (len); -} int main(void) {