diff options
-rw-r--r-- | src/Makefile | 7 | ||||
-rw-r--r-- | src/lib/Makefile | 10 | ||||
-rw-r--r-- | src/lib/libc/Makefile | 18 | ||||
-rw-r--r-- | src/lib/libc/amd64/Makefile | 19 | ||||
-rw-r--r-- | src/lib/libc/amd64/crt/crt0.S | 33 | ||||
-rw-r--r-- | src/lib/libc/libc.a | bin | 0 -> 896 bytes |
6 files changed, 86 insertions, 1 deletions
diff --git a/src/Makefile b/src/Makefile index 53b2d5e..270c65f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -18,7 +18,7 @@ QEMU_FLAGS = --enable-kvm -serial stdio -cdrom $(ISO) \ -M q35 -cpu host -smp 4 -m 2G .PHONY: all -all: root user sys image +all: root user sys lib image .PHONY: sys sys: @@ -30,6 +30,11 @@ user: cd cmd/; make CC=$(CC) AS=$(AS) LD=$(LD) TARGET=$(TARGET) \ SYSROOT=$(SYSROOT) +.PHONY: lib +lib: + cd lib/; make CC=$(CC) AS=$(AS) LD=$(LD) TARGET=$(TARGET) \ + SYSROOT=$(SYSROOT) + root: mkdir -p $(SYSROOT)/ mkdir -p $(SYSROOT)/boot/ diff --git a/src/lib/Makefile b/src/lib/Makefile new file mode 100644 index 0000000..1febd2e --- /dev/null +++ b/src/lib/Makefile @@ -0,0 +1,10 @@ +LDSCRIPT=../../sys/arch/$(TARGET)/conf/user.ld + +.PHONY: all +all: + cd libc//; LDSCRIPT=$(LDSCRIPT) CC=$(CC) ASM=$(ASM) \ + LD=$(ASM) SYSROOT=$(SYSROOT) make + +.PHONY: clean +clean: + cd libc/; make clean diff --git a/src/lib/libc/Makefile b/src/lib/libc/Makefile new file mode 100644 index 0000000..3287084 --- /dev/null +++ b/src/lib/libc/Makefile @@ -0,0 +1,18 @@ +OBJ = $(shell find build/ -name "*.o") +LIBC_OUT = libc.a + +.PHONY: all +all: build target + ar rcs $(LIBC_OUT) $(OBJ) + +.PHONY: target +target: + cd $(TARGET); make CC=$(CC) LD=$(LD) AS=$(AS) + +# Create build directory +build: + mkdir -p $@ + +.PHONY: clean +clean: + rm -rf build/ diff --git a/src/lib/libc/amd64/Makefile b/src/lib/libc/amd64/Makefile new file mode 100644 index 0000000..f70def3 --- /dev/null +++ b/src/lib/libc/amd64/Makefile @@ -0,0 +1,19 @@ +.SILENT: +override PROMPT := printf "%s\t\t%s\n" + +ASMFILES = $(shell find . -name "*.S") +ASMOBJECTS = $(ASMFILES:.S=.S.o) + +.PHONY: all +all: ../build/$(OBJECTS) ../build/$(ASMOBJECTS) + +-include $(DEPS) +../build/%.o: %.c + mkdir -p $(@D) + $(CC) -c $(CFLAGS) $< -o $@ + +-include $(ASMDEPS) +../build/%.S.o: %.S + mkdir -p $(@D) + $(PROMPT) " MD.AS " $< + $(CC) -c $< -o $@ $(CFLAGS) $(MD_CFLAGS) diff --git a/src/lib/libc/amd64/crt/crt0.S b/src/lib/libc/amd64/crt/crt0.S new file mode 100644 index 0000000..71a00e9 --- /dev/null +++ b/src/lib/libc/amd64/crt/crt0.S @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Ian Marco Moffett and L5 engineers + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the project nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + .text + .globl _start +_start: + jmp . diff --git a/src/lib/libc/libc.a b/src/lib/libc/libc.a Binary files differnew file mode 100644 index 0000000..b45f3f9 --- /dev/null +++ b/src/lib/libc/libc.a |