From 27cb4fff4ed854d8be598a1157265c6de8aa035a Mon Sep 17 00:00:00 2001 From: John Hodge Date: Tue, 26 Mar 2013 22:59:29 +0800 Subject: [PATCH] AcesNative+Usermode - libacessnative "works" (for some definitions) - Uses system libc, and as such *printf goes to system stdout --- AcessNative/acesskernel_src/syscalls.c | 1 + AcessNative/ld-acess_src/exports.c | 2 +- AcessNative/ld-acess_src/request.c | 32 ++++++++++++ AcessNative/ld-acess_src/syscalls.c | 2 +- AcessNative/libacess-native.so_src/Makefile | 2 +- AcessNative/libacess-native.so_src/exports.c | 9 ++++ AcessNative/libacess-native.so_src/main.c | 50 ++++++++++++++++++- BuildConf/native/Makefile.cfg | 3 +- KernelLand/Kernel/vfs/io.c | 18 +++++-- Usermode/Applications/Makefile.cfg | 5 +- Usermode/Applications/Makefile.tpl | 14 +++--- Usermode/Applications/axwin3_src/WM/main.c | 39 +++++++++++++-- Usermode/Applications/axwin3_src/WM/video.c | 5 +- .../libaxwin3.so_src/include/internal.h | 2 +- Usermode/Libraries/Makefile.cfg | 22 ++++++-- Usermode/Libraries/Makefile.tpl | 8 +++ .../include_exp/acess/_native_syscallmod.h | 45 +++++++++++++++++ .../ld-acess.so_src/include_exp/acess/sys.h | 3 ++ Usermode/Libraries/libc.so_src/Makefile | 3 ++ .../Libraries/libc.so_src/include_exp/errno.h | 4 +- Usermode/Libraries/libc.so_src/signals.c | 2 +- Usermode/Libraries/libc.so_src/stub.c | 5 ++ Usermode/Libraries/libposix.so_src/Makefile | 2 +- 23 files changed, 246 insertions(+), 32 deletions(-) create mode 100644 Usermode/Libraries/ld-acess.so_src/include_exp/acess/_native_syscallmod.h diff --git a/AcessNative/acesskernel_src/syscalls.c b/AcessNative/acesskernel_src/syscalls.c index 44588463..f19fe69c 100644 --- a/AcessNative/acesskernel_src/syscalls.c +++ b/AcessNative/acesskernel_src/syscalls.c @@ -119,6 +119,7 @@ SYSCALL3(Syscall_Read, "iid", int, int, void *, ); SYSCALL3(Syscall_Write, "iid", int, int, const void *, if( Sizes[2] < a1 ) { + Log_Warning("Syscalls", "Write - %i < %i", Sizes[2], a1); *Errno = EINVAL; return -1; } diff --git a/AcessNative/ld-acess_src/exports.c b/AcessNative/ld-acess_src/exports.c index a5196b5f..756febaf 100644 --- a/AcessNative/ld-acess_src/exports.c +++ b/AcessNative/ld-acess_src/exports.c @@ -199,7 +199,7 @@ int acess__SysUnloadBin(void *base) } // --- Timekeeping --- -int64_t acess_SysTimestamp(void) +int64_t acess__SysTimestamp(void) { // TODO: Better impl // return now()*1000; diff --git a/AcessNative/ld-acess_src/request.c b/AcessNative/ld-acess_src/request.c index 2fa481a7..62e70e8b 100644 --- a/AcessNative/ld-acess_src/request.c +++ b/AcessNative/ld-acess_src/request.c @@ -243,6 +243,38 @@ int SendRequest(tRequestHeader *Request, int RequestSize, int ResponseSize) if( recvbytes > expbytes ) { // TODO: Warning } + + #if DEBUG + { + int i; + char *data = (char*)&Request->Params[Request->NParams]; + DEBUG_S(" Reply:"); + for( i = 0; i < Request->NParams; i ++ ) + { + switch(Request->Params[i].Type) + { + case ARG_TYPE_INT32: + DEBUG_S(" 0x%08x", *(uint32_t*)data); + data += sizeof(uint32_t); + break; + case ARG_TYPE_INT64: + DEBUG_S(" 0x%016"PRIx64"", *(uint64_t*)data); + data += sizeof(uint64_t); + break; + case ARG_TYPE_STRING: + DEBUG_S(" '%s'", (char*)data); + data += Request->Params[i].Length; + break; + case ARG_TYPE_DATA: + DEBUG_S(" %p:0x%x", (char*)data, Request->Params[i].Length); + if( !(Request->Params[i].Flags & ARG_FLAG_ZEROED) ) + data += Request->Params[i].Length; + break; + } + } + DEBUG_S("\n"); + } + #endif return recvbytes; } diff --git a/AcessNative/ld-acess_src/syscalls.c b/AcessNative/ld-acess_src/syscalls.c index c649f28f..88db8c44 100644 --- a/AcessNative/ld-acess_src/syscalls.c +++ b/AcessNative/ld-acess_src/syscalls.c @@ -249,7 +249,7 @@ uint64_t _Syscall(int SyscallID, const char *ArgTypes, ...) exit(127); } - Debug("req->NParams = %i", req->NParams); + dataPtr = (void*)&req->Params[req->NParams]; assert(req->NParams >= 2); // return assert(req->Params[0].Type == ARG_TYPE_INT64); diff --git a/AcessNative/libacess-native.so_src/Makefile b/AcessNative/libacess-native.so_src/Makefile index 0b9bc20f..0a074a62 100644 --- a/AcessNative/libacess-native.so_src/Makefile +++ b/AcessNative/libacess-native.so_src/Makefile @@ -20,7 +20,7 @@ CFLAGS += -Wall CFLAGS += -Werror CFLAGS += -g -shared -fPIC CPPFLAGS += -DARCHDIR_is_x86_64=1 -LDFLAGS += -g -shared -Wl,--no-undefined +LDFLAGS += -g -shared -Wl,--no-undefined -lc DEPFILES = $(filter %.o,$(OBJ)) DEPFILES := $(DEPFILES:%=%.dep) diff --git a/AcessNative/libacess-native.so_src/exports.c b/AcessNative/libacess-native.so_src/exports.c index b761e61a..0ab63613 100644 --- a/AcessNative/libacess-native.so_src/exports.c +++ b/AcessNative/libacess-native.so_src/exports.c @@ -1,2 +1,11 @@ #include "../ld-acess_src/exports.c" + +void *_crt0_exit_handler; + +int *libc_geterrno(void) +{ + return &acess__errno; +} + + diff --git a/AcessNative/libacess-native.so_src/main.c b/AcessNative/libacess-native.so_src/main.c index 4bf908bf..f0728643 100644 --- a/AcessNative/libacess-native.so_src/main.c +++ b/AcessNative/libacess-native.so_src/main.c @@ -1,19 +1,59 @@ /* */ #include +#include #include +#include + +extern int giSyscall_ClientID; +extern void Request_Preinit(void); +extern int acess__SysOpen(const char *Path, unsigned int flags); #ifdef __WINDOWS__ int DllMain(void) { + fprintf(stderr, "TODO: Windows libacessnative setup\n"); return 0; } #endif #ifdef __linux__ -int main(int argc, char *argv[], char **envp) +int __attribute__ ((constructor)) libacessnative_init(void); + +int libacessnative_init(void) { + Request_Preinit(); + + const char *preopens = getenv("AN_PREOPEN"); + if( preopens ) + { + while( *preopens ) + { + const char *splitter = strchr(preopens, ':'); + size_t len; + if( !splitter ) { + len = strlen(preopens); + } + else { + len = splitter - preopens; + } + char path[len+1]; + memcpy(path, preopens, len); + path[len] = 0; + int fd = acess__SysOpen(path, 6); // WRITE,READ,no EXEC + if( fd == -1 ) { + fprintf(stderr, "Unable to preopen '%s'\n", path); + } + + if( !splitter ) + break; + preopens = splitter + 1; + } + } + +// if( !getenv("ACESSNATIVE_ID") + return 0; } #endif @@ -39,3 +79,11 @@ void Warning(const char *format, ...) printf("\n"); } +void __libc_csu_fini() +{ +} + +void __libc_csu_init() +{ +} + diff --git a/BuildConf/native/Makefile.cfg b/BuildConf/native/Makefile.cfg index aa4cd00c..2bf14ccf 100644 --- a/BuildConf/native/Makefile.cfg +++ b/BuildConf/native/Makefile.cfg @@ -5,7 +5,8 @@ ARCHDIR := native -LD ?= $(CC) -print-prog-name=ld +#LD ?= $(CC) -print-prog-name=ld +LD = $(CC) AS = $(CC) -c ASSUFFIX = S diff --git a/KernelLand/Kernel/vfs/io.c b/KernelLand/Kernel/vfs/io.c index 1df34034..24aa78ba 100644 --- a/KernelLand/Kernel/vfs/io.c +++ b/KernelLand/Kernel/vfs/io.c @@ -41,7 +41,8 @@ size_t VFS_Read(int FD, size_t Length, void *Buffer) } if( !MM_GetPhysAddr(h->Node->Type->Read) ) { - Log_Error("VFS", "Node type %p(%s) read method is junk %p", h->Node->Type, h->Node, h->Node->Type->TypeName, + Log_Error("VFS", "Node type %p(%s) read method is junk %p", + h->Node->Type, h->Node, h->Node->Type->TypeName, h->Node->Type->Read); LEAVE_RET('i', -1); } @@ -98,10 +99,19 @@ size_t VFS_Write(int FD, size_t Length, const void *Buffer) h = VFS_GetHandle(FD); if(!h) return -1; - if( !(h->Mode & VFS_OPENFLAG_WRITE) ) return -1; - if( h->Node->Flags & VFS_FFLAG_DIRECTORY ) return -1; + if( !(h->Mode & VFS_OPENFLAG_WRITE) ) { + LOG("FD%i not opened for writing", FD); + return -1; + } + if( h->Node->Flags & VFS_FFLAG_DIRECTORY ) { + LOG("FD%i is a director", FD); + return -1; + } - if( !h->Node->Type || !h->Node->Type->Write ) return 0; + if( !h->Node->Type || !h->Node->Type->Write ) { + LOG("FD%i has no write method", FD); + return 0; + } if( !MM_GetPhysAddr(h->Node->Type->Write) ) { Log_Error("VFS", "Node type %p(%s) write method is junk %p", h->Node->Type, h->Node, h->Node->Type->TypeName, diff --git a/Usermode/Applications/Makefile.cfg b/Usermode/Applications/Makefile.cfg index 6b80a5e0..2dbcfc28 100644 --- a/Usermode/Applications/Makefile.cfg +++ b/Usermode/Applications/Makefile.cfg @@ -9,18 +9,19 @@ ASFLAGS = -felf CPPFLAGS = -Wall CFLAGS = $(CPPFLAGS) LDFLAGS = -L $(OUTPUTDIR)Libs -lacess-native -LIBGCC_PATH = $(ACESSDIR)/AcessNative/symbol_renames.ld +#LIBGCC_PATH = $(ACESSDIR)/AcessNative/symbol_renames.ld else ASFLAGS = -felf CPPFLAGS = -ffreestanding CFLAGS = -fno-stack-protector -fno-builtin $(CPPFLAGS) -LDFLAGS = -T $(OUTPUTDIR)Libs/acess.ld -rpath-link $(OUTPUTDIR)Libs -L $(OUTPUTDIR)Libs -I /Acess/Libs/ld-acess.so -lld-acess -lc $(OUTPUTDIR)Libs/crtbegin.o $(OUTPUTDIR)Libs/crtend.o -lposix +LDFLAGS = -T $(OUTPUTDIR)Libs/acess.ld -L $(OUTPUTDIR)Libs -I /Acess/Libs/ld-acess.so -lld-acess -lc $(OUTPUTDIR)Libs/crtbegin.o $(OUTPUTDIR)Libs/crtend.o -lposix LIBGCC_PATH = $(shell $(CC) -print-libgcc-file-name) endif CPPFLAGS += $(addprefix -I,$(wildcard $(ACESSUSERDIR)Libraries/*/include_exp/)) CPPFLAGS += -I$(ACESSUSERDIR)/include/ -DARCHDIR_is_$(ARCHDIR) +LDFLAGS += -rpath-link $(OUTPUTDIR)Libs # Extra-verbose errors! #CFLAGS += -Wall -Wextra -Wwrite-strings -Wshadow -Wswitch-default -Wswitch-enum -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wmissing-declarations -Wlogical-op -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wsync-nand -Wunused -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wno-endif-labels -Wshadow -Wunsafe-loop-optimizations -Wbad-function-cast -Wc++-compat -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-declarations -Wnormalized=nfc -Wpacked -Wpadded -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wdisabled-optimization -Woverlength-strings diff --git a/Usermode/Applications/Makefile.tpl b/Usermode/Applications/Makefile.tpl index f42e6601..472349ce 100644 --- a/Usermode/Applications/Makefile.tpl +++ b/Usermode/Applications/Makefile.tpl @@ -6,6 +6,13 @@ CFLAGS += -g LDFLAGS += -g +LDFLAGS += -Map $(_OBJPREFIX)Map.txt + +ifneq ($(lastword $(subst -, ,$(basename $(LD)))),ld) + LDFLAGS := $(subst -rpath-link ,-Wl$(comma)-rpath-link$(comma),$(LDFLAGS)) + LDFLAGS := $(subst -Map ,-Wl$(comma)-Map$(comma),$(LDFLAGS)) +endif + _BIN := $(OUTPUTDIR)$(DIR)/$(BIN) _OBJPREFIX := obj-$(ARCH)/ @@ -40,12 +47,7 @@ install: $(_BIN) $(_BIN): $(OUTPUTDIR)Libs/acess.ld $(OUTPUTDIR)Libs/crt0.o $(_LIBS) $(OBJ) @mkdir -p $(dir $(_BIN)) @echo [LD] -o $@ -#ifeq ($(ARCHDIR),native) -# $V$(LD) -g -o $@.tmp.o -r $(OBJ) $(LIBGCC_PATH) -# $V$(LD) -g $(LDFLAGS) -o $@ $@.tmp.o -Map $(_OBJPREFIX)Map.txt -#else - $V$(LD) -g $(LDFLAGS) -o $@ $(OBJ) -Map $(_OBJPREFIX)Map.txt $(LIBGCC_PATH) -#endif + $V$(LD) -g $(LDFLAGS) -o $@ $(OBJ) $(LIBGCC_PATH) $V$(DISASM) $(_BIN) > $(_OBJPREFIX)$(BIN).dsm $(OBJ): $(_OBJPREFIX)%.o: %.c diff --git a/Usermode/Applications/axwin3_src/WM/main.c b/Usermode/Applications/axwin3_src/WM/main.c index 1d833148..a9266b41 100644 --- a/Usermode/Applications/axwin3_src/WM/main.c +++ b/Usermode/Applications/axwin3_src/WM/main.c @@ -39,6 +39,8 @@ const char *gsMouseDevice = NULL; #define __INSTALL_ROOT "/Acess/Apps/AxWin/3.0" const char *gsInstallRoot = __INSTALL_ROOT; +const char *gsInterfaceApp = __INSTALL_ROOT"/AxWinUI"; + int gbNoSpawnUI = 0; // === CODE === /** @@ -76,17 +78,17 @@ int main(int argc, char *argv[]) WM_Hotkey_Register(2, keys, "Interface>TextEdit"); // Spawn interface root + if( !gbNoSpawnUI ) { int server_tid = gettid(); _SysDebug("server_tid = %i", server_tid); - static char csInterfaceApp[] = __INSTALL_ROOT"/AxWinUI"; char server_info[] = "AXWIN3_SERVER=00000"; const char *envp[] = {server_info, NULL}; - const char *argv[] = {csInterfaceApp, NULL}; + const char *argv[] = {gsInterfaceApp, NULL}; _SysDebug("server_tid = %i, &server_tid = %p", server_tid, &server_tid); sprintf(server_info, "AXWIN3_SERVER=%i", server_tid); // TODO: Does the client need FDs? - int rv = _SysSpawn(csInterfaceApp, argv, envp, 0, NULL, NULL); + int rv = _SysSpawn(gsInterfaceApp, argv, envp, 0, NULL, NULL); if( rv < 0 ) { _SysDebug("_SysSpawn chucked a sad, rv=%i, errno=%i", rv, _errno); } @@ -116,8 +118,37 @@ int main(int argc, char *argv[]) return 0; } +void PrintUsage(void) +{ + fprintf(stderr, "Arguments:\n"); + fprintf(stderr, " --no-ui : Don't spawn the UI process\n"); +} + void ParseCommandline(int argc, char **argv) { - + for( int i = 1; i < argc; i ++ ) + { + if( argv[i][0] != '-' ) { + // Error? + PrintUsage(); + exit(-1); + } + else if( argv[i][1] != '-' ) { + // Short + PrintUsage(); + exit(-1); + } + else { + // Long + if( strcmp(argv[i], "--no-ui") == 0 ) { + gbNoSpawnUI = 1; + } + else { + // Error. + PrintUsage(); + exit(-1); + } + } + } } diff --git a/Usermode/Applications/axwin3_src/WM/video.c b/Usermode/Applications/axwin3_src/WM/video.c index 1b9ffaba..a30dd377 100644 --- a/Usermode/Applications/axwin3_src/WM/video.c +++ b/Usermode/Applications/axwin3_src/WM/video.c @@ -49,9 +49,10 @@ void Video_Setup(void) giTerminalFD_Input = 0; // Check that the console is a VT // - _SysIOCtl(..., 0, NULL) returns the type, which should be 2 - if( _SysIOCtl(1, 0, NULL) != 2 ) + tmpInt = _SysIOCtl(1, 0, NULL); + if( tmpInt != 2 ) { - fprintf(stderr, "stdout is not an Acess VT, can't start"); + fprintf(stderr, "stdout is not an Acess VT, can't start (2 exp, %i got)\n", tmpInt); _SysDebug("stdout is not an Acess VT, can't start"); exit(-1); } diff --git a/Usermode/Applications/axwin3_src/libaxwin3.so_src/include/internal.h b/Usermode/Applications/axwin3_src/libaxwin3.so_src/include/internal.h index 19ee8fd0..ce00d851 100644 --- a/Usermode/Applications/axwin3_src/libaxwin3.so_src/include/internal.h +++ b/Usermode/Applications/axwin3_src/libaxwin3.so_src/include/internal.h @@ -10,7 +10,7 @@ #include -extern void _SysDebug(const char *Fmt, ...); +#include // _SysDebug struct sAxWin3_Window { diff --git a/Usermode/Libraries/Makefile.cfg b/Usermode/Libraries/Makefile.cfg index 4aafe562..a9a0eefe 100644 --- a/Usermode/Libraries/Makefile.cfg +++ b/Usermode/Libraries/Makefile.cfg @@ -5,8 +5,22 @@ MAKEDEP = $(CC) -M -ASFLAGS += -D ARCHDIR=$(ARCHDIR) -D __ASSEMBLER__=1 -CPPFLAGS := -ffreestanding -I$(ACESSDIR)/Usermode/include/ -DARCHDIR=$(ARCHDIR) -DARCHDIR_is_$(ARCHDIR)=1 +ifeq ($(ARCHDIR),native) +ASFLAGS += -D ARCHDIR=$(ARCHDIR) -D __ASSEMBLER__=1 +LDFLAGS := -lacess-native + ifeq ($(PLATFORM),windows) + else + LDFLAGS += -Wl,-init,SoMain + CFLAGS += -fPIC + endif +else +CPPFLAGS := -ffreestanding +CFLAGS := -fno-stack-protector -fPIC +LDFLAGS := -I/Acess/Libs/ld-acess.so -lld-acess `$(CC) -print-libgcc-file-name` +endif +CPPFLAGS += -I$(ACESSDIR)/Usermode/include/ -DARCHDIR=$(ARCHDIR) -DARCHDIR_is_$(ARCHDIR)=1 CPPFLAGS += $(addprefix -I,$(wildcard $(ACESSUSERDIR)Libraries/*/include_exp/)) -CFLAGS := -g -Wall -fPIC -fno-stack-protector -O3 -LDFLAGS := -g -nostdlib -shared -I/Acess/Libs/ld-acess.so -lld-acess -e SoMain -x -L$(OUTPUTDIR)Libs/ --no-undefined `$(CC) -print-libgcc-file-name` +CFLAGS += -Wall -g +LDFLAGS += -g -nostdlib -shared -eSoMain -x --no-undefined -L$(OUTPUTDIR)Libs/ + +# vim: ft=make diff --git a/Usermode/Libraries/Makefile.tpl b/Usermode/Libraries/Makefile.tpl index 77495217..652d5a26 100644 --- a/Usermode/Libraries/Makefile.tpl +++ b/Usermode/Libraries/Makefile.tpl @@ -2,6 +2,14 @@ # - Library Common Makefile # +comma=, + +ifneq ($(lastword $(subst -, ,$(basename $(LD)))),ld) + LDFLAGS := $(subst -soname ,-Wl$(comma)-soname$(comma),$(LDFLAGS)) + LDFLAGS := $(subst -Map ,-Wl$(comma)-Map$(comma),$(LDFLAGS)) + LDFLAGS := $(LDFLAGS:-x=-Wl,-x) + LDFLAGS := $(LDFLAGS:--%=-Wl,--%) +endif _BIN := $(addprefix $(OUTPUTDIR)Libs/,$(BIN)) _XBIN := $(addprefix $(OUTPUTDIR)Libs/,$(EXTRABIN)) diff --git a/Usermode/Libraries/ld-acess.so_src/include_exp/acess/_native_syscallmod.h b/Usermode/Libraries/ld-acess.so_src/include_exp/acess/_native_syscallmod.h new file mode 100644 index 00000000..c368a290 --- /dev/null +++ b/Usermode/Libraries/ld-acess.so_src/include_exp/acess/_native_syscallmod.h @@ -0,0 +1,45 @@ + +#define _exit acess__exit +#define _SysClone acess__SysClone +#define _SysKill acess__SysKill +#define _SysWaitEvent acess__SysWaitEvent +#define _SysWaitTID acess__SysWaitTID +#define gettid acess_gettid +#define getpid acess_getpid +#define getuid acess_getuid +#define getgid acess_getgid +#define setuid acess_setuid +#define setgid acess_setgid +#define _SysSetName acess__SysSetName +#define _SysGetName acess__SysGetName +#define _SysTimestamp acess__SysTimestamp +#define _SysSetPri acess__SysSetPri +#define _SysSendMessage acess__SysSendMessage +#define _SysGetMessage acess__SysGetMessage +#define _SysSpawn acess__SysSpawn +#define _SysExecVE acess__SysExecVE +#define SysLoadBin acess_SysLoadBin +#define _SysUnloadBin acess__SysUnloadBin +#define _SysSetFaultHandler acess__SysSetFaultHandler +#define _SysDebug acess__SysDebug +#define _SysGetPhys acess__SysGetPhys +#define _SysAllocate acess__SysAllocate +#define _SysSetMemFlags acess__SysSetMemFlags +#define _SysOpen acess__SysOpen +#define _SysOpenChild acess__SysOpenChild +#define _SysReopen acess__SysReopen +#define _SysClose acess__SysClose +#define _SysRead acess__SysRead +#define _SysWrite acess__SysWrite +#define _SysSeek acess__SysSeek +#define _SysTell acess__SysTell +#define _SysFInfo acess__SysFInfo +#define _SysReadDir acess__SysReadDir +#define _SysGetACL acess__SysGetACL +#define _SysChdir acess__SysChdir +#define _SysIOCtl acess__SysIOCtl +#define _SysMount acess__SysMount +#define _SysSelect acess__SysSelect +#define _SysUnlink acess__SysUnlink + +#define _errno acess__errno diff --git a/Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h b/Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h index d9d31735..21e40ae0 100644 --- a/Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h +++ b/Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h @@ -35,6 +35,9 @@ #define FILEFLAG_SYMLINK 0x20 #define CLONE_VM 0x10 +#ifdef ARCHDIR_is_native +# include "_native_syscallmod.h" +#endif // === TYPES === diff --git a/Usermode/Libraries/libc.so_src/Makefile b/Usermode/Libraries/libc.so_src/Makefile index 0fd1e5be..f95e0869 100644 --- a/Usermode/Libraries/libc.so_src/Makefile +++ b/Usermode/Libraries/libc.so_src/Makefile @@ -17,6 +17,9 @@ OBJ += arch/$(ARCHDIR).ao # signals.o DEPFILES := $(OBJ:%.o=%.d) BIN = libc.so +ifeq ($(ARCHDIR),native) + BIN = libc_acess.so +endif include ../Makefile.tpl diff --git a/Usermode/Libraries/libc.so_src/include_exp/errno.h b/Usermode/Libraries/libc.so_src/include_exp/errno.h index cbe87490..c7f5b491 100644 --- a/Usermode/Libraries/libc.so_src/include_exp/errno.h +++ b/Usermode/Libraries/libc.so_src/include_exp/errno.h @@ -3,8 +3,8 @@ // TODO: Fully implement errno.h, make sure it matches the kernel one -extern int _errno; -#define errno _errno +extern int *libc_geterrno(); +#define errno (*libc_geterrno()) #define strerror(_x) "Unimplemented" diff --git a/Usermode/Libraries/libc.so_src/signals.c b/Usermode/Libraries/libc.so_src/signals.c index f8b71d34..c33019e4 100644 --- a/Usermode/Libraries/libc.so_src/signals.c +++ b/Usermode/Libraries/libc.so_src/signals.c @@ -2,7 +2,7 @@ * AcessOS Basic C Library * signals.c */ -//#include +#include #include #include #include "lib.h" diff --git a/Usermode/Libraries/libc.so_src/stub.c b/Usermode/Libraries/libc.so_src/stub.c index 6b64fb6b..7e535a7d 100644 --- a/Usermode/Libraries/libc.so_src/stub.c +++ b/Usermode/Libraries/libc.so_src/stub.c @@ -100,6 +100,11 @@ int ErrorHandler(int Fault) return -1; } +EXPORT int *libc_geterrno() +{ + return &_errno; +} + #if USE_CPUID /** * \brief Call the CPUID opcode diff --git a/Usermode/Libraries/libposix.so_src/Makefile b/Usermode/Libraries/libposix.so_src/Makefile index 737e4d6d..628999c3 100644 --- a/Usermode/Libraries/libposix.so_src/Makefile +++ b/Usermode/Libraries/libposix.so_src/Makefile @@ -6,7 +6,7 @@ CPPFLAGS += CFLAGS += -Werror -Wextra ASFLAGS += -LDFLAGS += -soname libposix.so -Map map.txt +LDFLAGS += -soname libposix.so -Map map.txt -lc OBJ = main.o unistd.o dirent.o stat.o DEPFILES := $(OBJ:%.o=%.d) -- 2.20.1