abstract-machine/scripts/riscv64-mycpu.mk
Zihao Yu 07eb9ba416 klib: move muldi3.S and div.S to riscv64-mycpu
* they will cause compile error with other ARCHs
2021-07-13 16:41:40 +08:00

24 lines
868 B
Makefile

CROSS_COMPILE := riscv64-linux-gnu-
COMMON_FLAGS := -fno-pic -march=rv64ifd -mcmodel=medany
CFLAGS += $(COMMON_FLAGS) -static
ASFLAGS += $(COMMON_FLAGS) -O0
LDFLAGS += -melf64lriscv
AM_SRCS := mycpu/start.S \
mycpu/trm.c \
mycpu/libgcc/muldi3.S \
mycpu/libgcc/div.S \
mycpu/ioe.c \
mycpu/timer.c \
mycpu/input.c
CFLAGS += -fdata-sections -ffunction-sections
LDFLAGS += -T $(AM_HOME)/scripts/platform/nemu.ld --defsym=_pmem_start=0x80000000 --defsym=_entry_offset=0x0
LDFLAGS += --gc-sections -e _start
CFLAGS += -DMAINARGS=\"$(mainargs)\"
.PHONY: $(AM_HOME)/am/src/mycpu/trm.c
image: $(IMAGE).elf
@$(OBJDUMP) -d $(IMAGE).elf > $(IMAGE).txt
@echo + OBJCOPY "->" $(IMAGE_REL).bin
@$(OBJCOPY) -S --set-section-flags .bss=alloc,contents -O binary $(IMAGE).elf $(IMAGE).bin