diff options
author | Ian Moffett <ian@osmora.org> | 2025-09-17 17:03:51 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-09-17 17:03:51 -0400 |
commit | a1e193f571e167c3784976843a45b077324d41c4 (patch) | |
tree | 71e5e197b3937d39319b9871d096d3d654b64eaa /src/lib/libc | |
parent | addd41a407519d99c50f59ef5ce1d2412486b2cd (diff) |
lib: Add initial libc stub
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/lib/libc')
-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 |
4 files changed, 70 insertions, 0 deletions
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 |