Minimal executable, cleaned up from vendor code

- Removed extraneous and/or oversized(?) align from linker script
- Handle init_array properly
- Remove legacy init code paths (.ctors, .init)
- Don't do nonstandard interrupt mode handling by default
This commit is contained in:
R
2024-04-12 17:50:23 +01:00
parent 2f3d484844
commit 40082ed533
6 changed files with 232 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
.PHONY: all clean
RV_ARCH = rv32imacxw
CC = riscv-none-elf-gcc
OBJDUMP = riscv-none-elf-objdump
CFLAGS = -ggdb3 -Os -march=$(RV_ARCH) -ffunction-sections -fdata-sections
LDFLAGS = -ggdb3 -march=$(RV_ARCH) -Wl,--gc-sections --specs=nosys.specs
all: main.elf
main.elf: startup.o main.o
%.elf: linker.lds
$(CC) -Xlinker -Map=$(@:.elf=.map) -Wl,--script=linker.lds -nostartfiles -o $@ $(filter-out linker.lds,$+)
$(OBJDUMP) -xdsS $@ >$(@:.elf=.dump)
%.o: %.S
$(CC) $(CFLAGS) -c -o $@ $<
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -f *.o *.elf *.map *.dump