riscv32-nemu: add integer library functions to pass linking

* they are called in __udivmoddi4(), which is used with uint64_t
  division in klib/src/stdio.c
This commit is contained in:
Zihao Yu 2020-02-10 13:22:36 +08:00
parent c2c8e24392
commit aca9a5dd6d
3 changed files with 17 additions and 1 deletions

View File

@ -18,7 +18,7 @@ NEMU_ARGS = -b $(MAINARGS) -l $(shell dirname $(BINARY))/nemu-log.txt $(BINARY).
image: image:
@echo + LD "->" $(BINARY_REL).elf @echo + LD "->" $(BINARY_REL).elf
@$(LD) $(LDFLAGS) --gc-sections -T $(LD_SCRIPT) -e _start -o $(BINARY).elf $(LINK_FILES) @$(LD) $(LDFLAGS) --gc-sections -T $(LD_SCRIPT) -e _start -o $(BINARY).elf --start-group $(LINK_FILES) --end-group
@$(OBJDUMP) -d $(BINARY).elf > $(BINARY).txt @$(OBJDUMP) -d $(BINARY).elf > $(BINARY).txt
@echo + OBJCOPY "->" $(BINARY_REL).bin @echo + OBJCOPY "->" $(BINARY_REL).bin
@$(OBJCOPY) -S --set-section-flags .bss=alloc,contents -O binary $(BINARY).elf $(BINARY).bin @$(OBJCOPY) -S --set-section-flags .bss=alloc,contents -O binary $(BINARY).elf $(BINARY).bin

View File

@ -1,2 +1,4 @@
include $(AM_HOME)/am/arch/isa/riscv32.mk include $(AM_HOME)/am/arch/isa/riscv32.mk
include $(AM_HOME)/am/arch/platform/nemu.mk include $(AM_HOME)/am/arch/platform/nemu.mk
AM_SRCS += riscv32/nemu/libint.c

View File

@ -0,0 +1,14 @@
#include <klib.h>
// for more details, refer to
// https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html
// only use for linking
int __clzsi2 (unsigned int a) {
assert(0);
}
int __ctzsi2 (unsigned int a) {
assert(0);
}