[TOOLCHAIN] Hosted toolchain with musl libc
This commit is contained in:
30
libc/Makefile
Normal file
30
libc/Makefile
Normal file
@@ -0,0 +1,30 @@
|
||||
ifeq ($(MITTOS64),)
|
||||
$(error Build environment is not activated. Please source activate)
|
||||
endif
|
||||
|
||||
LIBDIR := $(SYSROOT)/usr/lib
|
||||
|
||||
CRT := crt0
|
||||
CRT_OBJ := $(addprefix obj/, $(patsubst %,%.o,$(CRT)))
|
||||
|
||||
ASFLAGS := -ggdb
|
||||
|
||||
all: $(CRT_OBJ)
|
||||
|
||||
OBJ_DIRS := $(sort $(dir $(CRT_OBJ)))
|
||||
$(CRT_OBJ): | $(OBJ_DIRS)
|
||||
$(OBJ_DIRS):
|
||||
mkdir -p $@
|
||||
|
||||
obj/%.o:%.S
|
||||
$(COMPILE.S) $^ -o $@
|
||||
|
||||
$(LIBDIR)/%: obj/%
|
||||
cp $< $@
|
||||
|
||||
install: $(patsubst %,$(LIBDIR)/%.o,$(CRT))
|
||||
|
||||
clean:
|
||||
rm -rf obj/
|
||||
|
||||
.PHONY: all clean install
|
||||
25
libc/crt0.S
Normal file
25
libc/crt0.S
Normal file
@@ -0,0 +1,25 @@
|
||||
.intel_syntax noprefix
|
||||
.section .text
|
||||
.global _start
|
||||
|
||||
_start:
|
||||
movq rbp, 0
|
||||
push rbp
|
||||
push rbp
|
||||
mov rbp, rsp
|
||||
|
||||
push rsi
|
||||
push rdi
|
||||
|
||||
call _init
|
||||
|
||||
pop rdi
|
||||
pop rsi
|
||||
|
||||
call main
|
||||
|
||||
call _fini
|
||||
|
||||
jmp $
|
||||
|
||||
.size _start, . - _start
|
||||
Reference in New Issue
Block a user