diff --git a/apps/base/echo/echo.c b/apps/base/echo/echo.c index 0097afe..5231cb9 100644 --- a/apps/base/echo/echo.c +++ b/apps/base/echo/echo.c @@ -2,6 +2,12 @@ int main(int argc, char *argv[]) { + if (argc == 1) + { + printf("Usage: echo [args]\n"); + return 0; + } + for (int i = 1; i < argc; i++) printf("%s ", argv[i]); printf("\n"); diff --git a/apps/base/fsh/Makefile b/apps/base/fsh/Makefile index 3d07cf9..c54b16b 100644 --- a/apps/base/fsh/Makefile +++ b/apps/base/fsh/Makefile @@ -28,7 +28,7 @@ endif OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o) SYSROOT = --sysroot=$(WORKSPACE)out/ -FILENAME = fsh +FILENAME = sh HEADERS = $(sort $(dir $(wildcard $(WORKSPACE)out/include/*))) diff --git a/apps/system/init/Makefile b/apps/system/init/Makefile index 04b218d..b220b9d 100644 --- a/apps/system/init/Makefile +++ b/apps/system/init/Makefile @@ -39,7 +39,7 @@ CFLAGS = -I$(WORKSPACE)out/include \ WARNCFLAG = -Wall -Wextra ifneq ($(OSARCH), aarch64) -CFLAGS += -fstack-protector-all -fstack-clash-protection +# CFLAGS += -fstack-protector-all -fstack-clash-protection endif ifeq ($(DEBUG), 1) @@ -52,7 +52,7 @@ build: $(FILENAME) $(FILENAME): $(OBJ) $(info Linking $@) - $(CC) $(LDFLAGS) $(SYSROOT) $(OBJ) -lssp -o $@ + $(CC) $(LDFLAGS) $(SYSROOT) $(OBJ) -o $@ %.o: %.c $(HEADERS) $(info Compiling $<) diff --git a/apps/system/init/init.c b/apps/system/init/init.c index 2627185..2377842 100644 --- a/apps/system/init/init.c +++ b/apps/system/init/init.c @@ -35,50 +35,61 @@ void test_args(int argc, char *argv[], char *envp[]) int main(int argc, char *argv[], char *envp[]) { - freopen("/dev/tty", "w", stdout); - freopen("/dev/tty", "w", stderr); - - test_args(argc, argv, envp); - FILE *test = fopen("/Test.txt", "r"); + printf("Hello, World!\n"); + // while (1); + // test_args(argc, argv, envp); + FILE *test = fopen("/test.txt", "r"); if (test == NULL) { printf("Failed to open file\n"); - return 1; + return -0xF11e; } printf("Test.txt contents: "); char ch; - do + while (1) { ch = fgetc(test); + if (ch == EOF) + { + printf("\n"); + break; + } putchar(ch); - } while (ch != EOF); - + } fclose(test); - pid_t pid; - int status; - - pid = fork(); + pid_t pid = fork(); if (pid == 0) // Child process { + pid_t pid2 = fork(); + if (pid == 0) // Child process + { + char *shebang_args[] = {"/test.sh", NULL}; + execv(shebang_args[0], shebang_args); + } + printf("Creating shell process\n"); - char *args[] = {"/bin/sh", NULL}; + char *args[] = {"/bin/echo", "Hello, World!", NULL}; execv(args[0], args); exit(EXIT_FAILURE); } else if (pid > 0) { + printf("Waiting for child process %d to exit\n", pid); + int status; wait(&status); - if (WIFEXITED(status)) + int exited = WIFEXITED(status); + if (exited) { - printf("Child process exited with code: %d\n", WEXITSTATUS(status)); - return WEXITSTATUS(status); + int exit_code = WEXITSTATUS(status); + printf("Child process exited with code: %d\n", exit_code); + return exit_code; } else { - printf("Execution failed.\n"); + printf("Execution failed. (%d)\n", exited); exit(EXIT_FAILURE); } } diff --git a/apps/user/games/doomgeneric b/apps/user/games/doomgeneric index 1a54c16..b961b55 160000 --- a/apps/user/games/doomgeneric +++ b/apps/user/games/doomgeneric @@ -1 +1 @@ -Subproject commit 1a54c1624fc6b830a8a478b0f6601c447bbc5cc9 +Subproject commit b961b5551b5d56cc82bf8b14d43d41f859744344 diff --git a/libc/ElfInterpreter/fcts.c b/libc/ElfInterpreter/fcts.c index fed375a..bc82114 100644 --- a/libc/ElfInterpreter/fcts.c +++ b/libc/ElfInterpreter/fcts.c @@ -5,22 +5,15 @@ uintptr_t RequestPages(size_t Count) { - return syscall1(sys_RequestPages, Count); + return syscall6(sc_mmap, NULL, Count * 0x1000, + sc_PROT_READ | sc_PROT_WRITE, + sc_MAP_ANONYMOUS | sc_MAP_PRIVATE, + 0, 0); } int FreePages(uintptr_t Address, size_t Count) { - return syscall2(sys_FreePages, Address, Count); -} - -int IPC(int Command, int Type, int ID, int Flags, void *Buffer, size_t Size) -{ - return syscall6(sys_IPC, (long)Command, (long)Type, (long)ID, (long)Flags, (long)Buffer, (long)Size); -} - -uintptr_t KernelCTL(int Command, uint64_t Arg1, uint64_t Arg2, uint64_t Arg3, uint64_t Arg4) -{ - return syscall5(sys_KernelCTL, Command, Arg1, Arg2, Arg3, Arg4); + return syscall2(sc_munmap, Address, Count * 0x1000); } int abs(int i) { return i < 0 ? -i : i; } @@ -112,38 +105,38 @@ int strcmp(const char *l, const char *r) struct Elf64_Dyn ELFGetDynamicTag(char *Path, enum DynamicTags Tag) { - int fd = syscall2(sys_FileOpen, Path, (long)"r"); + int fd = syscall2(sc_open, Path, (long)"r"); if (fd < 0) - syscall1(sys_Exit, -0xF17E); + syscall1(sc_exit, -0xF17E); Elf64_Ehdr ELFHeader; - syscall3(sys_FileRead, fd, &ELFHeader, sizeof(Elf64_Ehdr)); + syscall3(sc_read, fd, &ELFHeader, sizeof(Elf64_Ehdr)); Elf64_Phdr ItrProgramHeader; for (Elf64_Half i = 0; i < ELFHeader.e_phnum; i++) { // memcpy(&ItrProgramHeader, (uint8_t *)ElfFile + ELFHeader.e_phoff + ELFHeader.e_phentsize * i, sizeof(Elf64_Phdr)); - syscall3(sys_FileSeek, fd, ELFHeader.e_phoff + ELFHeader.e_phentsize * i, SYSCALL_SEEK_SET); - syscall3(sys_FileRead, fd, &ItrProgramHeader, sizeof(Elf64_Phdr)); + syscall3(sc_lseek, fd, ELFHeader.e_phoff + ELFHeader.e_phentsize * i, sc_SEEK_SET); + syscall3(sc_read, fd, &ItrProgramHeader, sizeof(Elf64_Phdr)); if (ItrProgramHeader.p_type == PT_DYNAMIC) { struct Elf64_Dyn Dynamic; // = (struct Elf64_Dyn *)((uint8_t *)ElfFile + ItrProgramHeader.p_offset); - syscall3(sys_FileSeek, fd, ItrProgramHeader.p_offset, SYSCALL_SEEK_SET); - syscall3(sys_FileRead, fd, &Dynamic, ItrProgramHeader.p_filesz); + syscall3(sc_lseek, fd, ItrProgramHeader.p_offset, sc_SEEK_SET); + syscall3(sc_read, fd, &Dynamic, ItrProgramHeader.p_filesz); for (size_t i = 0; i < ItrProgramHeader.p_filesz / sizeof(struct Elf64_Dyn); i++) { if (Dynamic.d_tag == Tag || Dynamic.d_tag == DT_NULL) { - syscall1(sys_FileClose, fd); + syscall1(sc_close, fd); return Dynamic; } - syscall3(sys_FileSeek, fd, ItrProgramHeader.p_offset + (i + 1) * sizeof(struct Elf64_Dyn), SYSCALL_SEEK_SET); - syscall3(sys_FileRead, fd, &Dynamic, sizeof(struct Elf64_Dyn)); + syscall3(sc_lseek, fd, ItrProgramHeader.p_offset + (i + 1) * sizeof(struct Elf64_Dyn), sc_SEEK_SET); + syscall3(sc_read, fd, &Dynamic, sizeof(struct Elf64_Dyn)); } } } - syscall1(sys_FileClose, fd); + syscall1(sc_close, fd); return (struct Elf64_Dyn){0}; } @@ -168,12 +161,12 @@ char *GetELFStringTable(Elf64_Ehdr *Header) Elf64_Sym ELFLookupSymbol(char *Path, const char *Name) { - int fd = syscall2(sys_FileOpen, Path, (long)"r"); + int fd = syscall2(sc_open, Path, (long)"r"); if (fd < 0) - syscall1(sys_Exit, -0xF17E); + syscall1(sc_exit, -0xF17E); Elf64_Ehdr ELFHeader; - syscall3(sys_FileRead, fd, &ELFHeader, sizeof(Elf64_Ehdr)); + syscall3(sc_read, fd, &ELFHeader, sizeof(Elf64_Ehdr)); Elf64_Shdr SymbolTable; Elf64_Shdr StringTable; @@ -183,20 +176,20 @@ Elf64_Sym ELFLookupSymbol(char *Path, const char *Name) for (Elf64_Half i = 0; i < ELFHeader.e_shnum; i++) { Elf64_Shdr shdr; - syscall3(sys_FileSeek, fd, + syscall3(sc_lseek, fd, ELFHeader.e_shoff + ELFHeader.e_shentsize * i, - SYSCALL_SEEK_SET); - syscall3(sys_FileRead, fd, &shdr, sizeof(Elf64_Shdr)); + sc_SEEK_SET); + syscall3(sc_read, fd, &shdr, sizeof(Elf64_Shdr)); switch (shdr.sh_type) { case SHT_SYMTAB: { SymbolTable = shdr; - syscall3(sys_FileSeek, fd, + syscall3(sc_lseek, fd, ELFHeader.e_shoff + ELFHeader.e_shentsize * shdr.sh_link, - SYSCALL_SEEK_SET); - syscall3(sys_FileRead, fd, &StringTable, sizeof(Elf64_Shdr)); + sc_SEEK_SET); + syscall3(sc_read, fd, &StringTable, sizeof(Elf64_Shdr)); break; } default: @@ -208,7 +201,7 @@ Elf64_Sym ELFLookupSymbol(char *Path, const char *Name) if (SymbolTable.sh_size == 0 || StringTable.sh_size == 0) { - syscall1(sys_FileClose, fd); + syscall1(sc_close, fd); return (Elf64_Sym){0}; } @@ -216,19 +209,19 @@ Elf64_Sym ELFLookupSymbol(char *Path, const char *Name) { // Symbol = (Elf64_Sym *)((uintptr_t)Header + SymbolTable->sh_offset + (i * sizeof(Elf64_Sym))); // String = (char *)((uintptr_t)Header + StringTable->sh_offset + Symbol->st_name); - syscall3(sys_FileSeek, fd, SymbolTable.sh_offset + (i * sizeof(Elf64_Sym)), SYSCALL_SEEK_SET); - syscall3(sys_FileRead, fd, &Symbol, sizeof(Elf64_Sym)); + syscall3(sc_lseek, fd, SymbolTable.sh_offset + (i * sizeof(Elf64_Sym)), sc_SEEK_SET); + syscall3(sc_read, fd, &Symbol, sizeof(Elf64_Sym)); - syscall3(sys_FileSeek, fd, StringTable.sh_offset + Symbol.st_name, SYSCALL_SEEK_SET); - syscall3(sys_FileRead, fd, &String, sizeof(char *)); + syscall3(sc_lseek, fd, StringTable.sh_offset + Symbol.st_name, sc_SEEK_SET); + syscall3(sc_read, fd, &String, sizeof(char *)); if (strcmp(String, Name) == 0) { - syscall1(sys_FileClose, fd); + syscall1(sc_close, fd); return Symbol; } } - syscall1(sys_FileClose, fd); + syscall1(sc_close, fd); return (Elf64_Sym){0}; } diff --git a/libc/ElfInterpreter/ld.c b/libc/ElfInterpreter/ld.c index 2900be1..79f031d 100644 --- a/libc/ElfInterpreter/ld.c +++ b/libc/ElfInterpreter/ld.c @@ -102,8 +102,8 @@ void (*ELF_LAZY_RESOLVE_MAIN(struct LibsCollection *Info, long RelIndex))() Elf64_Ehdr lib_Header; Elf64_Ehdr app_Header; - int fd_lib = syscall2(sys_FileOpen, LibraryPathBuffer, "r"); - int fd_app = syscall2(sys_FileOpen, ParentPath, "r"); + int fd_lib = syscall2(sc_open, LibraryPathBuffer, "r"); + int fd_app = syscall2(sc_open, ParentPath, "r"); if (fd_lib < 0) { @@ -117,31 +117,31 @@ void (*ELF_LAZY_RESOLVE_MAIN(struct LibsCollection *Info, long RelIndex))() goto RetryNextLib; } - syscall3(sys_FileRead, fd_lib, &lib_Header, sizeof(Elf64_Ehdr)); - syscall3(sys_FileRead, fd_app, &app_Header, sizeof(Elf64_Ehdr)); + syscall3(sc_read, fd_lib, &lib_Header, sizeof(Elf64_Ehdr)); + syscall3(sc_read, fd_app, &app_Header, sizeof(Elf64_Ehdr)); Elf64_Phdr ItrProgramHeader; for (Elf64_Half i = 0; i < lib_Header.e_phnum; i++) { - syscall3(sys_FileSeek, fd_lib, + syscall3(sc_lseek, fd_lib, lib_Header.e_phoff + lib_Header.e_phentsize * i, - SYSCALL_SEEK_SET); + sc_SEEK_SET); - syscall3(sys_FileRead, fd_lib, &ItrProgramHeader, sizeof(Elf64_Phdr)); + syscall3(sc_read, fd_lib, &ItrProgramHeader, sizeof(Elf64_Phdr)); lib_BaseAddress = MIN(lib_BaseAddress, ItrProgramHeader.p_vaddr); } for (Elf64_Half i = 0; i < app_Header.e_phnum; i++) { - syscall3(sys_FileSeek, fd_app, + syscall3(sc_lseek, fd_app, app_Header.e_phoff + app_Header.e_phentsize * i, - SYSCALL_SEEK_SET); + sc_SEEK_SET); - syscall3(sys_FileRead, fd_app, &ItrProgramHeader, sizeof(Elf64_Phdr)); + syscall3(sc_read, fd_app, &ItrProgramHeader, sizeof(Elf64_Phdr)); app_BaseAddress = MIN(app_BaseAddress, ItrProgramHeader.p_vaddr); } @@ -265,7 +265,7 @@ FailEnd: Print(DbgBuff); PrintNL(" not found"); int ExitCode = 0x51801; - syscall1(sys_Exit, ExitCode); + syscall1(sc_exit, ExitCode); while (1) // Make sure we don't return ; } @@ -274,15 +274,15 @@ FailEnd: int ld_main() { /* Prevent race condition. */ - uintptr_t KCTL_ret = KernelCTL(KCTL_IS_CRITICAL, 0, 0, 0, 0); - do - { - syscall1(sys_Sleep, 250); - KCTL_ret = KernelCTL(KCTL_IS_CRITICAL, 0, 0, 0, 0); - } while (KCTL_ret == false); + // uintptr_t KCTL_ret = KernelCTL(KCTL_IS_CRITICAL, 0, 0, 0, 0); + // do + // { + // syscall1(sys_Sleep, 250); + // KCTL_ret = KernelCTL(KCTL_IS_CRITICAL, 0, 0, 0, 0); + // } while (KCTL_ret == false); - if (KCTL_ret == false) - return -1; + // if (KCTL_ret == false) + // return -1; /* Everything is ok, continue. */ return 0; @@ -306,7 +306,7 @@ int ld_load(int argc, char *argv[], char *envp[]) { PrintDbgNL("Calling entry point"); - // void *KP = syscall2(sys_FileOpen, ParentPath, (long)"r"); + // void *KP = syscall2(sc_open, ParentPath, (long)"r"); // if (KP == NULL) // { // PrintNL("Failed to open file"); @@ -314,7 +314,7 @@ int ld_load(int argc, char *argv[], char *envp[]) // } // Elf64_Ehdr ELFHeader; - // syscall3(sys_FileRead, KP, &ELFHeader, sizeof(Elf64_Ehdr)); + // syscall3(sc_read, KP, &ELFHeader, sizeof(Elf64_Ehdr)); // Elf64_Addr Entry = ELFHeader.e_entry; diff --git a/libc/src/Runtime.c b/libc/src/Runtime.c index b178064..c213f4c 100644 --- a/libc/src/Runtime.c +++ b/libc/src/Runtime.c @@ -17,7 +17,7 @@ PUBLIC void _exit(int Code) { __libc_fini_std(); __libc_fini_array(); - syscall1(sys_Exit, (long)Code); + syscall1(sc_exit, (long)Code); while (1) ; } diff --git a/libc/src/mem/LibAllocImplementation.cpp b/libc/src/mem/LibAllocImplementation.cpp index e5ae8ec..a9fe381 100644 --- a/libc/src/mem/LibAllocImplementation.cpp +++ b/libc/src/mem/LibAllocImplementation.cpp @@ -17,10 +17,14 @@ extern "C" int liballoc_unlock() extern "C" void *liballoc_alloc(size_t Pages) { - return (void *)syscall1(sys_RequestPages, Pages); + return (void *)syscall6(sc_mmap, NULL, + Pages * 0x1000, + sc_PROT_READ | sc_PROT_WRITE, + sc_MAP_ANONYMOUS | sc_MAP_PRIVATE, + -1, 0); } extern "C" int liballoc_free(void *Address, size_t Pages) { - return syscall2(sys_FreePages, (uint64_t)Address, Pages); + return syscall2(sc_munmap, (uintptr_t)Address, Pages * 0x1000); } diff --git a/libc/src/std/io/file.c b/libc/src/std/io/file.c index 1e50cb1..b8bb52a 100644 --- a/libc/src/std/io/file.c +++ b/libc/src/std/io/file.c @@ -18,7 +18,7 @@ PUBLIC FILE *freopen(const char *filename, const char *mode, FILE *stream) PUBLIC FILE *fopen(const char *filename, const char *mode) { - int fd = syscall2(sys_FileOpen, (uint64_t)filename, (uint64_t)mode); + int fd = syscall2(sc_open, (uint64_t)filename, (uint64_t)mode); if (fd < 0) return NULL; @@ -35,8 +35,8 @@ PUBLIC size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream) return 0; } - syscall3(sys_FileSeek, stream->_fileno, stream->_offset, SEEK_SET); - return syscall3(sys_FileRead, (uint64_t)stream->_fileno, (uint64_t)ptr, size * nmemb); + syscall3(sc_lseek, stream->_fileno, stream->_offset, SEEK_SET); + return syscall3(sc_read, (uint64_t)stream->_fileno, (uint64_t)ptr, size * nmemb); } PUBLIC size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) @@ -47,8 +47,8 @@ PUBLIC size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) return 0; } - syscall3(sys_FileSeek, stream->_fileno, stream->_offset, SEEK_SET); - return syscall3(sys_FileWrite, (uint64_t)stream->_fileno, (uint64_t)ptr, size * nmemb); + syscall3(sc_lseek, stream->_fileno, stream->_offset, SEEK_SET); + return syscall3(sc_write, (uint64_t)stream->_fileno, (uint64_t)ptr, size * nmemb); } PUBLIC int fclose(FILE *fp) @@ -59,7 +59,7 @@ PUBLIC int fclose(FILE *fp) return EOF; } - return syscall1(sys_FileClose, fp->_fileno); + return syscall1(sc_close, fp->_fileno); } PUBLIC off_t fseek(FILE *stream, off_t offset, int whence) @@ -70,7 +70,7 @@ PUBLIC off_t fseek(FILE *stream, off_t offset, int whence) return -1; } - off_t new_offset = syscall3(sys_FileSeek, stream->_fileno, offset, whence); + off_t new_offset = syscall3(sc_lseek, stream->_fileno, offset, whence); if (new_offset < 0) return -1; stream->_offset = new_offset; diff --git a/libc/src/std/io/put.c b/libc/src/std/io/put.c index 0f0d042..90cc8b9 100644 --- a/libc/src/std/io/put.c +++ b/libc/src/std/io/put.c @@ -13,7 +13,7 @@ PUBLIC int fputc(int c, FILE *stream) // return EOF; // } char str[2] = {c, '\0'}; - return syscall3(sys_KernelCTL, KCTL_PRINT, str, 0); + // return syscall3(sys_KernelCTL, KCTL_PRINT, str, 0); } PUBLIC int putc(int c, FILE *stream) { return fputc(c, stream); } diff --git a/libc/src/std/lib.c b/libc/src/std/lib.c index a4dafc6..9443470 100644 --- a/libc/src/std/lib.c +++ b/libc/src/std/lib.c @@ -8,7 +8,7 @@ PUBLIC void abort(void) { - syscall1(sys_Exit, -0xAB057); + syscall1(sc_exit, -0xAB057); while (1) ; } diff --git a/libc/src/std/uni/exe.c b/libc/src/std/uni/exe.c index def820d..85274ad 100644 --- a/libc/src/std/uni/exe.c +++ b/libc/src/std/uni/exe.c @@ -47,5 +47,5 @@ PUBLIC int execve(const char *pathname, char *const argv[], char *const envp[]) PUBLIC pid_t fork(void) { - return syscall0(sys_Fork); + return syscall0(sc_fork); } diff --git a/libc/src/std/uni/sleep.c b/libc/src/std/uni/sleep.c index 2a8adf5..4bb1908 100644 --- a/libc/src/std/uni/sleep.c +++ b/libc/src/std/uni/sleep.c @@ -5,10 +5,10 @@ PUBLIC unsigned int sleep(unsigned int seconds) { - return syscall1(sys_Sleep, seconds * 1000000); + // return syscall1(sys_Sleep, seconds * 1000000); } PUBLIC int usleep(useconds_t usec) { - return syscall1(sys_Sleep, usec); + // return syscall1(sys_Sleep, usec); } diff --git a/libs/Makefile b/libs/Makefile index ea389ee..5691647 100644 --- a/libs/Makefile +++ b/libs/Makefile @@ -1,8 +1,6 @@ build: # cp -r include/* ../out/include make -C libgcc build - make -C libssp build clean: make -C libgcc clean - make -C libssp clean diff --git a/libs/libssp/Makefile b/libs/libssp/Makefile deleted file mode 100644 index 3efb0b9..0000000 --- a/libs/libssp/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -# Config file -include ../../../Makefile.conf - -NAME=ssp - -ifeq ($(USERSPACE_STATIC_LIBS), 1) -OBJECT_NAME := lib$(NAME).a -else -OBJECT_NAME := lib$(NAME).so -endif - -OUTPUT_DIR=../../out/lib/ -SYSROOT = --sysroot=../../out/ - -CC = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)gcc -AS = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)as -AR = ../../../$(COMPILER_PATH)/$(COMPILER_ARCH)ar - -C_SOURCES = $(shell find ./ -type f -name '*.c') -CPP_SOURCES = $(shell find ./ -type f -name '*.cpp') -S_SOURCES = $(shell find ./ -type f -name '*.S') -OBJ = ${C_SOURCES:.c=.o} ${CPP_SOURCES:.cpp=.o} ${S_SOURCES:.S=.o} - -ifeq ($(OSARCH), amd64) -ASM_ARCH := elf64 -else ifeq ($(OSARCH), i386) -ASM_ARCH := elf32 -endif - -CFLAGS := -fvisibility=hidden -fPIC -I../include -I../../out/include - -ifeq ($(DEBUG), 1) - CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always -fverbose-asm - LDFLAGS += -ggdb3 -O0 -endif - -build: $(OBJECT_NAME) - -$(OBJECT_NAME): $(OBJ) - $(info Linking $@) -ifeq ($(USERSPACE_STATIC_LIBS), 1) - $(AR) rcs $(OUTPUT_DIR)$@ $(OBJ) -else - $(CC) -nostdlib -shared -fPIC -fPIE -Wl,-soname,$(OBJECT_NAME) $(SYSROOT) $(OBJ) -o $(OUTPUT_DIR)$@ -endif - -%.o: %.c - $(info Compiling $<) - $(CC) $(CFLAGS) -std=c17 -c $< -o $@ - -%.o: %.cpp - $(info Compiling $<) - $(CC) $(CFLAGS) -std=c++20 -c $< -o $@ - -%.o: %.S - $(info Compiling $<) - $(AS) -c $< -o $@ - -clean: - rm -f $(OBJ) diff --git a/libs/libssp/ssp.c b/libs/libssp/ssp.c deleted file mode 100644 index a046e97..0000000 --- a/libs/libssp/ssp.c +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef STACK_CHK_GUARD_VALUE -#if UINTPTR_MAX == UINT32_MAX -#define STACK_CHK_GUARD_VALUE 0xDEAD57AC -#else -#define STACK_CHK_GUARD_VALUE 0xDEAD57AC00000000 -#endif -#endif - -#ifndef PUBLIC -#define PUBLIC __attribute__((visibility("default"))) -#endif // !PUBLIC - -#ifndef PRIVATE -#define PRIVATE __attribute__((visibility("hidden"))) -#endif // !PRIVATE - -PUBLIC __UINTPTR_TYPE__ __stack_chk_guard = 0; - -static void __attribute__((constructor, no_stack_protector)) __guard_setup(void) -{ - if (__stack_chk_guard == 0) - __stack_chk_guard = STACK_CHK_GUARD_VALUE; -} - -PUBLIC __attribute__((weak, noreturn, no_stack_protector)) void __stack_chk_fail(void) -{ - const char *msg = "Stack smashing detected"; - exit(0x57AC); - __builtin_unreachable(); -} - -PUBLIC __attribute__((weak, noreturn, no_stack_protector)) void __chk_fail(void) -{ - const char *msg = "Buffer overflow detected"; - exit(0xF700); - __builtin_unreachable(); -}