Compare commits
No commits in common. "14fd0faefd033806f2918b79afe0f2d7d6086520" and "989ee41ac747287e7f1b7d24ffd5656934e4c965" have entirely different histories.
14fd0faefd
...
989ee41ac7
8 changed files with 10 additions and 55 deletions
9
Makefile
9
Makefile
|
@ -72,11 +72,11 @@ include $(AM_HOME)/scripts/$(ARCH).mk
|
||||||
BUILDDIR := $(DST_DIR)
|
BUILDDIR := $(DST_DIR)
|
||||||
COMMON_CFLAGS := $(CFLAGS) -g -O3 -MMD -Wall \
|
COMMON_CFLAGS := $(CFLAGS) -g -O3 -MMD -Wall \
|
||||||
-fno-asynchronous-unwind-tables -fno-builtin -fno-stack-protector \
|
-fno-asynchronous-unwind-tables -fno-builtin -fno-stack-protector \
|
||||||
-U_FORTIFY_SOURCE -fvisibility=hidden -fno-exceptions -std=gnu11
|
-Wno-main -U_FORTIFY_SOURCE -fvisibility=hidden
|
||||||
INTERFACE_LDFLAGS += -z noexecstack
|
INTERFACE_LDFLAGS += -z noexecstack
|
||||||
INTERFACE_CFLAGS += -fno-asynchronous-unwind-tables \
|
INTERFACE_CFLAGS += -fno-asynchronous-unwind-tables \
|
||||||
-fno-builtin -fno-stack-protector \
|
-fno-builtin -fno-stack-protector \
|
||||||
-U_FORTIFY_SOURCE -fvisibility=hidden -fno-exceptions
|
-Wno-main -U_FORTIFY_SOURCE -fvisibility=hidden
|
||||||
### Build libam
|
### Build libam
|
||||||
#### Include archetecture specific build flags
|
#### Include archetecture specific build flags
|
||||||
COMMON_CFLAGS += -D__ARCH_$(shell echo $(ARCH) | tr a-z A-Z | tr - _) \
|
COMMON_CFLAGS += -D__ARCH_$(shell echo $(ARCH) | tr a-z A-Z | tr - _) \
|
||||||
|
@ -90,7 +90,7 @@ AM_CFLAGS += $(COMMON_CFLAGS) $(addprefix -I, $(AM_INCPATH))
|
||||||
AM_INTERFACE_INCPATH += $(AM_HOME)/am/include $(AM_HOME)/klib/include
|
AM_INTERFACE_INCPATH += $(AM_HOME)/am/include $(AM_HOME)/klib/include
|
||||||
AM_INTERFACE_CFLAGS +=
|
AM_INTERFACE_CFLAGS +=
|
||||||
|
|
||||||
AM_INTERFACE_LDFLAGS += -lam-$(ARCH)
|
AM_INTERFACE_LDFLAGS += -lm -lam-$(ARCH)
|
||||||
|
|
||||||
$(eval $(call ADD_LIBRARY,$(LIB_BUILDDIR)/libam-$(ARCH).a,AM_))
|
$(eval $(call ADD_LIBRARY,$(LIB_BUILDDIR)/libam-$(ARCH).a,AM_))
|
||||||
|
|
||||||
|
@ -115,7 +115,6 @@ INTERFACE_INCPATH += $(sort $(KLIB_INTERFACE_INCPATH) $(AM_INTERFACE_INCPATH))
|
||||||
# TODO: Use sort here will cause error on seperated flags, such as: -e _start
|
# TODO: Use sort here will cause error on seperated flags, such as: -e _start
|
||||||
# but without sort, duplicated flags will not be removed.
|
# but without sort, duplicated flags will not be removed.
|
||||||
INTERFACE_CFLAGS += $(addprefix -I, $(INTERFACE_INCPATH:%=$(INC_INSTALLDIR))) $(sort $(KLIB_INTERFACE_CFLAGS) $(AM_INTERFACE_CFLAGS))
|
INTERFACE_CFLAGS += $(addprefix -I, $(INTERFACE_INCPATH:%=$(INC_INSTALLDIR))) $(sort $(KLIB_INTERFACE_CFLAGS) $(AM_INTERFACE_CFLAGS))
|
||||||
INTERFACE_CXXFLAGS += $(INTERFACE_CFLAGS) $(addprefix -I, $(INTERFACE_INCPATH:%=$(INC_INSTALLDIR)))
|
|
||||||
INTERFACE_LDFLAGS += -L$(LIB_INSTALLDIR) $(sort $(KLIB_INTERFACE_LDFLAGS) $(AM_INTERFACE_LDFLAGS))
|
INTERFACE_LDFLAGS += -L$(LIB_INSTALLDIR) $(sort $(KLIB_INTERFACE_LDFLAGS) $(AM_INTERFACE_LDFLAGS))
|
||||||
|
|
||||||
EXPORT_FLAGS_FILE := $(LIB_INSTALLDIR)/make/flags-$(ARCH).mk
|
EXPORT_FLAGS_FILE := $(LIB_INSTALLDIR)/make/flags-$(ARCH).mk
|
||||||
|
@ -130,7 +129,7 @@ $(EXPORT_HELPERS): $(LIB_INSTALLDIR)/make/%: scripts/helpers/%
|
||||||
@install -dm755 $(dir $@)
|
@install -dm755 $(dir $@)
|
||||||
@install -Dm644 $< $(dir $@)
|
@install -Dm644 $< $(dir $@)
|
||||||
|
|
||||||
export INTERFACE_CFLAGS INTERFACE_CXXFLAGS INTERFACE_ASFLAGS INTERFACE_INCPATH INTERFACE_LDFLAGS
|
export INTERFACE_CFLAGS INTERFACE_INCPATH INTERFACE_LDFLAGS
|
||||||
$(EXPORT_FLAGS_FILE):
|
$(EXPORT_FLAGS_FILE):
|
||||||
@echo + INSTALL $(patsubst $(INSTALLDIR)/%,%,$@)
|
@echo + INSTALL $(patsubst $(INSTALLDIR)/%,%,$@)
|
||||||
@install -Dm644 <(printf $(EXPORT_FLAGS_TEMPLATE)) $(EXPORT_FLAGS_FILE)
|
@install -Dm644 <(printf $(EXPORT_FLAGS_TEMPLATE)) $(EXPORT_FLAGS_FILE)
|
||||||
|
|
|
@ -22,7 +22,6 @@ void halt(int code) {
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void _trm_init() {
|
void _trm_init() {
|
||||||
heap_alloc_ptr = heap.start;
|
heap_alloc_ptr = heap.start;
|
||||||
int ret = main(mainargs);
|
int ret = main(mainargs);
|
||||||
|
|
|
@ -5,7 +5,4 @@
|
||||||
_start:
|
_start:
|
||||||
mv s0, zero
|
mv s0, zero
|
||||||
la sp, _stack_pointer
|
la sp, _stack_pointer
|
||||||
|
jal _trm_init
|
||||||
lui t0, %hi(_trm_init) # Load upper 20 bits
|
|
||||||
addi t0, t0, %lo(_trm_init) # Add lower 12 bits
|
|
||||||
jalr ra, t0, 0 # Jump and link register
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ char *strcpy(char *dst, const char *src);
|
||||||
char *strncpy(char *dst, const char *src, size_t n);
|
char *strncpy(char *dst, const char *src, size_t n);
|
||||||
int strcmp(const char *s1, const char *s2);
|
int strcmp(const char *s1, const char *s2);
|
||||||
int strncmp(const char *s1, const char *s2, size_t n);
|
int strncmp(const char *s1, const char *s2, size_t n);
|
||||||
void *memchr(const void *src, int c, size_t n);
|
|
||||||
|
|
||||||
|
|
||||||
//stdlib.h
|
//stdlib.h
|
||||||
|
|
|
@ -54,31 +54,4 @@ void *malloc(size_t size) {
|
||||||
void free(void *ptr) {
|
void free(void *ptr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#define SS (sizeof(size_t))
|
|
||||||
#define ALIGN (sizeof(size_t)-1)
|
|
||||||
#define ONES ((size_t)-1/UCHAR_MAX)
|
|
||||||
#define HIGHS (ONES * (UCHAR_MAX/2+1))
|
|
||||||
#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
|
|
||||||
|
|
||||||
void *memchr(const void *src, int c, size_t n)
|
|
||||||
{
|
|
||||||
const unsigned char *s = src;
|
|
||||||
c = (unsigned char)c;
|
|
||||||
#ifdef __GNUC__
|
|
||||||
for (; ((uintptr_t)s & ALIGN) && n && *s != c; s++, n--);
|
|
||||||
if (n && *s != c) {
|
|
||||||
typedef size_t __attribute__((__may_alias__)) word;
|
|
||||||
const word *w;
|
|
||||||
size_t k = ONES * c;
|
|
||||||
for (w = (const void *)s; n>=SS && !HASZERO(*w^k); w++, n-=SS);
|
|
||||||
s = (const void *)w;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
for (; n && *s != c; s++, n--);
|
|
||||||
return n ? (void *)s : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
AM_CFLAGS += -static -fno-pic -mstrict-align -ffreestanding
|
AM_CFLAGS += -static -fno-pic -march=rv64g -mcmodel=medany -mstrict-align
|
||||||
AM_ASFLAGS += -static -fno-pic -O0
|
AM_ASFLAGS += -static -fno-pic -march=rv32g_zicsr -mcmodel=medany -O0
|
||||||
|
AM_LDFLAGS += -melf64lriscv -O2
|
||||||
INTERFACE_CFLAGS += -static -mcmodel=medany -mstrict-align -ffreestanding
|
|
||||||
INTERFACE_ASFLAGS += -static -mcmodel=medany
|
|
||||||
INTERFACE_LDFLAGS +=
|
|
||||||
|
|
||||||
# overwrite ARCH_H defined in $(AM_HOME)/Makefile
|
# overwrite ARCH_H defined in $(AM_HOME)/Makefile
|
||||||
ARCH_H := arch/riscv.h
|
ARCH_H := arch/riscv.h
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
include $(AM_HOME)/scripts/isa/riscv.mk
|
include $(AM_HOME)/scripts/isa/riscv.mk
|
||||||
include $(AM_HOME)/scripts/platform/nemu.mk
|
include $(AM_HOME)/scripts/platform/nemu.mk
|
||||||
AM_CFLAGS += -DISA_H=\"riscv/riscv.h\" -march=rv32im_zicsr -mabi=ilp32
|
AM_CFLAGS += -DISA_H=\"riscv/riscv.h\" -march=rv32im_zicsr -mabi=ilp32
|
||||||
AM_ASFLAGS += -march=rv32im_zicsr -mabi=ilp32
|
|
||||||
KLIB_CFLAGS += -march=rv32im_zicsr -mabi=ilp32
|
KLIB_CFLAGS += -march=rv32im_zicsr -mabi=ilp32
|
||||||
AM_LDFLAGS += -melf32lriscv
|
AM_LDFLAGS += -melf32lriscv
|
||||||
INTERFACE_CFLAGS += -march=rv32im_zicsr -mabi=ilp32
|
INTERFACE_CFLAGS += -march=rv32im_zicsr -mabi=ilp32
|
||||||
INTERFACE_CXXFLAGS += -march=rv32im_zicsr -mabi=ilp32
|
|
||||||
INTERFACE_ASFLAGS += -march=rv32im_zicsr -mabi=ilp32
|
|
||||||
|
|
||||||
AM_SRCS += am/src/riscv/nemu/start.S \
|
AM_SRCS += am/src/riscv/nemu/start.S \
|
||||||
am/src/riscv/nemu/cte.c \
|
am/src/riscv/nemu/cte.c \
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
"AM_CFLAGS += %s \n\
|
"AM_CFLAGS += %s \n\
|
||||||
AM_CXXFLAGS += %s \n\
|
AM_LDFLAGS += %s" \
|
||||||
AM_INCPATH += %s \n\
|
|
||||||
AM_LDFLAGS += %s \n\
|
|
||||||
AM_ASFLAGS += %s" \
|
|
||||||
"$INTERFACE_CFLAGS" \
|
"$INTERFACE_CFLAGS" \
|
||||||
"$INTERFACE_CXXFLAGS" \
|
"$INTERFACE_LDFLAGS"
|
||||||
"$INTERFACE_INCPATH" \
|
|
||||||
"$INTERFACE_LDFLAGS" \
|
|
||||||
"$INTERFACE_ASFLAGS"
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue