Update libc

This commit is contained in:
Alex 2022-11-07 03:37:51 +02:00
parent ff61b602a5
commit 887f67e32d
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
14 changed files with 153 additions and 2 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
*.o
*.map
*.fex
*.elf
out/

View File

@ -5,6 +5,9 @@
}
],
"settings": {
"debug.allowBreakpointsEverywhere": true
"debug.allowBreakpointsEverywhere": true,
"files.associations": {
"fex.hpp": "c"
}
}
}

View File

@ -1,6 +1,7 @@
build:
mkdir -p out
mkdir -p out/system
mkdir -p out/system/lib
make --quiet -C libc build
make --quiet -C apps build

View File

@ -1,4 +1,9 @@
build:
make --quiet -C runtime build
make --quiet -C libgcc build
make --quiet -C src build
clean:
make --quiet -C runtime clean
make --quiet -C libgcc clean
make --quiet -C src clean

0
libc/include/types.h Normal file
View File

44
libc/libgcc/Makefile Normal file
View File

@ -0,0 +1,44 @@
# Config file
include ../../../Makefile.conf
NAME=gcc
OBJECT_NAME=lib$(NAME).a
OUTPUT_DIR=../../out/system/lib/
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
AR = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)ar
NASM = /usr/bin/nasm
C_SOURCES = $(shell find ./ -type f -name '*.c')
S_SOURCES = $(shell find ./ -type f -name '*.s')
ASM_SOURCES = $(shell find ./ -type f -name '*.asm')
OBJ = ${C_SOURCES:.c=.o} ${ASM_SOURCES:.asm=.o} ${S_SOURCES:.s=.o}
INCLUDE_DIR = ../include
ifeq ($(OSARCH), amd64)
ASM_ARCH := elf64
else ifeq ($(OSARCH), i686)
ASM_ARCH := elf32
endif
CFLAGS := -fPIC -I$(INCLUDE_DIR)
build: $(OBJECT_NAME)
$(OBJECT_NAME): $(OBJ)
$(AR) rcs $(OUTPUT_DIR)$@ $(OBJ)
%.o: %.c $(HEADERS) $(HEADERS2)
$(CC) $(CFLAGS) -std=c17 -c $< -o $@
%.o: %.cpp $(HEADERS) $(HEADERS2)
$(CC) $(CFLAGS) -std=c++20 -c $< -o $@
%.o: %.asm
$(NASM) $< -f $(ASM_ARCH) -o $@
clean:

0
libc/libgcc/cxa.cpp Normal file
View File

31
libc/runtime/Makefile Normal file
View File

@ -0,0 +1,31 @@
# Config file
include ../../../Makefile.conf
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
NASM = /usr/bin/nasm
C_SOURCES = $(shell find ./ -type f -name '*.c')
S_SOURCES = $(shell find ./ -type f -name '*.s')
ASM_SOURCES = $(shell find ./ -type f -name '*.asm')
OBJ = ${C_SOURCES:.c=.o} ${ASM_SOURCES:.asm=.o} ${S_SOURCES:.s=.o}
ifeq ($(OSARCH), amd64)
ASM_ARCH := elf64
else ifeq ($(OSARCH), i686)
ASM_ARCH := elf32
endif
build: $(OBJ)
mv $^ ../../out/system/lib/
%.o: %.c
$(CC) -nostdlib -std=c17 -c $< -o $@
%.o: %.asm
$(NASM) $< -f $(ASM_ARCH) -o $@
%.bin: %.s
$(NASM) $< -f $(ASM_ARCH) -o $@
clean:

10
libc/runtime/crt0.c Normal file
View File

@ -0,0 +1,10 @@
int main(int argc, char *argv[], char *envp[]);
int _start(void *Data)
{
int mainret = main((int)0, (char **)0, (char **)0);
while (1)
;
return 0;
}
// C stuff

10
libc/runtime/crt1.c Normal file
View File

@ -0,0 +1,10 @@
int main(int argc, char *argv[], char *envp[]);
int _start(void *Data)
{
int mainret = main((int)0, (char **)0, (char **)0);
while (1)
;
return 0;
}
// C++ stuff

1
libc/runtime/crtbegin.c Normal file
View File

@ -0,0 +1 @@
// C++ constructor/destructor stuff

1
libc/runtime/crtend.c Normal file
View File

@ -0,0 +1 @@
// C++ constructor/destructor stuff

44
libc/src/Makefile Normal file
View File

@ -0,0 +1,44 @@
# Config file
include ../../../Makefile.conf
NAME=c
OBJECT_NAME=lib$(NAME).a
OUTPUT_DIR=../../out/system/lib/
CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc
AR = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)ar
NASM = /usr/bin/nasm
C_SOURCES = $(shell find ./ -type f -name '*.c')
S_SOURCES = $(shell find ./ -type f -name '*.s')
ASM_SOURCES = $(shell find ./ -type f -name '*.asm')
OBJ = ${C_SOURCES:.c=.o} ${ASM_SOURCES:.asm=.o} ${S_SOURCES:.s=.o}
INCLUDE_DIR = ../include
ifeq ($(OSARCH), amd64)
ASM_ARCH := elf64
else ifeq ($(OSARCH), i686)
ASM_ARCH := elf32
endif
CFLAGS := -fPIC -I$(INCLUDE_DIR)
build: $(OBJECT_NAME)
$(OBJECT_NAME): $(OBJ)
$(AR) rcs $(OUTPUT_DIR)$@ $(OBJ)
%.o: %.c $(HEADERS) $(HEADERS2)
$(CC) $(CFLAGS) -std=c17 -c $< -o $@
%.o: %.cpp $(HEADERS) $(HEADERS2)
$(CC) $(CFLAGS) -std=c++20 -c $< -o $@
%.o: %.asm
$(NASM) $< -f $(ASM_ARCH) -o $@
clean:
rm -f $(OBJ)

0
libc/src/main.c Normal file
View File