Fix ARCH=native compiling
authorJohn Hodge <[email protected]>
Fri, 17 Oct 2014 10:18:20 +0000 (18:18 +0800)
committerJohn Hodge <[email protected]>
Fri, 17 Oct 2014 10:18:20 +0000 (18:18 +0800)
20 files changed:
AcessNative/ld-acess_src/exports.c
AcessNative/libacess-native.so_src/exports.c
Makefile
Makefile.cfg
Usermode/Applications/Makefile.cfg
Usermode/Applications/Makefile.tpl
Usermode/Libraries/Makefile.tpl
Usermode/Libraries/crt0.o_src/Makefile
Usermode/Libraries/crt0.o_src/native-crti.S [new file with mode: 0644]
Usermode/Libraries/crt0.o_src/native-crtn.S [new file with mode: 0644]
Usermode/Libraries/ld-acess.so_src/include_exp/acess/_native_syscallmod.h
Usermode/Libraries/ld-acess.so_src/include_exp/acess/sys.h
Usermode/Libraries/libaxwin4.so_src/Makefile
Usermode/Libraries/libc++.so_src/Makefile
Usermode/Libraries/libc++.so_src/gxx_personality.cc
Usermode/Libraries/libc++.so_src/typeinfo.cc
Usermode/Libraries/libc.so_src/Makefile
Usermode/Libraries/libc.so_src/heap.c
Usermode/Libraries/libc.so_src/heap_native.c [new file with mode: 0644]
Usermode/Libraries/libposix.so_src/mktemp.c

index a898b5a..10dc7bd 100644 (file)
@@ -95,6 +95,10 @@ size_t acess__SysWrite(int FD, const void *Src, size_t Bytes) {
        SYSTRACE("_SysWrite(0x%x, 0x%x, %p\"%.*s\")", FD, Bytes, Src, Bytes, (char*)Src);
        return _Syscall(SYS_WRITE, ">i >i >d", FD, Bytes, Bytes, Src);
 }
+uint64_t acess__SysTruncate(int fd, uint64_t size) {
+       TODO();
+       return 0;
+}
 
 int acess__SysSeek(int FD, int64_t Ofs, int Dir)
 {
@@ -156,6 +160,26 @@ int acess__SysUnlink(const char *pathname)
        TODO();
        return 0;
 }
+void* acess__SysMMap(void *addr, size_t length, unsigned int _flags, int fd, uint64_t offset)
+{
+       TODO();
+       return NULL;
+}
+int acess__SysMUnMap(void *addr, size_t length)
+{
+       TODO();
+       return 0;
+}
+uint64_t acess__SysMarshalFD(int FD)
+{
+       TODO();
+       return 0;
+}
+int acess__SysUnMarshalFD(uint64_t Handle)
+{
+       TODO();
+       return -1;
+}
 
 int acess__SysOpenChild(int fd, char *name, int flags) {
        SYSTRACE("_SysOpenChild(0x%x, '%s', 0x%x)", fd, name, flags);
@@ -489,6 +513,7 @@ const tSym  caBuiltinSymbols[] = {
        DEFSYM(_SysAllocate),
        DEFSYM(_SysSetMemFlags),
        DEFSYM(_SysDebug),
+       {"_ZN4_sys5debugEPKcz", &acess__SysDebug},
        DEFSYM(_SysSetFaultHandler),
        DEFSYM(_SysWaitEvent),
        
index 2f960c4..0f71f21 100644 (file)
@@ -10,6 +10,8 @@ int *libc_geterrno(void)
        return &acess__errno;
 }
 
+void _ZN4_sys5debugEPKcz(const char *fmt, ...) __attribute__((alias("acess__SysDebug")));
+
 #undef acess__SysSpawn
 
 int acess__SysSpawn(const char *binary, const char **argv, const char **envp, int nfd, int fds[], struct s_sys_spawninfo *info)
index 5992b27..64b757e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -125,8 +125,12 @@ install-Kernel: $(CC)
 install-Filesystem: $(CC)
        @$(SUBMAKE) install -C Usermode/Filesystem
 
+ifeq ($(ARCHDIR),native)
+.PHONY: $(CC)
+else
 $(CC):
        @echo ---
        @echo $(CC) does not exist, recompiling
        @echo ---
        make -C Externals/cross-compiler/
+endif
index 29f1346..1eedf8e 100644 (file)
@@ -37,10 +37,12 @@ ifeq ($(ARCHDIR),)
 endif
 
 # Default compilers
+ifneq ($(ARCHDIR),native)
 CC  = $(COMPILERDIR)bin/$(TRIPLET)-gcc
 CXX = $(COMPILERDIR)bin/$(TRIPLET)-g++
 LD  = $(COMPILERDIR)bin/$(TRIPLET)-ld
 OBJDUMP = $(COMPILERDIR)bin/$(TRIPLET)-objdump
+endif
 
 ifneq ($(ARCH),host)
  ifneq ($(ARCHDIR),$(ARCH))
index 7261145..f87736c 100644 (file)
@@ -28,3 +28,5 @@ CFLAGS   += -Wall
 #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
 
 DIR = Bin
+
+# vim: ft=make
index 3313913..6ce97c4 100644 (file)
@@ -19,6 +19,10 @@ LDFLAGS := $(subst -Map ,-Wl$(comma)-Map$(comma),$(LDFLAGS))
 _LIBS := $(filter -l%,$(LIBS))
 _LIBS := $(patsubst -l%,$(OUTPUTDIR)Libs/lib%.so,$(_LIBS))
 
+ifeq ($(ARCHDIR),native)
+ LDFLAGS := -L$(OUTPUTDIR)Libs/ $(subst -lc++ ,-lc++_acess ,$(LDFLAGS))
+ LIBS := $(subst -lc++ ,-lc++_acess ,$(LIBS))
+endif
 ifeq ($(VERBOSE),)
 V := @
 else
index 8b27121..5e241f2 100644 (file)
@@ -24,6 +24,14 @@ LDFLAGS := $(LDFLAGS:--%=-Wl,--%)
 _LIBS := $(filter -l%,$(LDFLAGS))
 _LIBS := $(patsubst -l%,$(OUTPUTDIR)Libs/lib%.so,$(_LIBS))
 
+ifeq ($(ARCHDIR),native)
+ LIBS := $(patsubst -lc,-lc_acess,$(LIBS))
+ LIBS := $(patsubst -lc++,-lc++_acess,$(LIBS))
+ ifneq ($(BIN),libc_acess.so)
+  LIBS += -lc_acess
+ endif
+endif
+
 OBJ := $(addprefix $(_OBJPREFIX),$(OBJ))
 
 UTESTS := $(patsubst TEST_%.c,%,$(wildcard TEST_*.c))
index 9d84b92..29bdb0e 100644 (file)
@@ -31,15 +31,3 @@ $(OUTPUTDIR)Libs/%.o: $(ARCHDIR)-%.S
        @mkdir -p $(dir $@)
        $(CC) $(CFLAGS) -c $< -o $@
 
-#$(OUTPUTDIR)Libs/crt0.o: obj-$(ARCH)/crt0_asm.o obj-$(ARCH)/crt0_c.o
-#      @mkdir -p $(dir $@)
-#      $(LD) -r -o $@ $?
-
-#obj-$(ARCH)/crt0_asm.o: crt0.$(ARCHDIR).$(ASSUFFIX)
-#      @mkdir -p $(dir $@)
-#      $(AS) $(ASFLAGS) $< -o $@
-
-#obj-$(ARCH)/crt0_c.o: crt0.c
-#      @mkdir -p $(dir $@)
-#      $(CC) -c $< -o $@
-
diff --git a/Usermode/Libraries/crt0.o_src/native-crti.S b/Usermode/Libraries/crt0.o_src/native-crti.S
new file mode 100644 (file)
index 0000000..01c8127
--- /dev/null
@@ -0,0 +1,11 @@
+.section .init
+.global _init
+.type _init, @function
+_init:
+       /* gcc will nicely put the contents of crtbegin.o's .init section here. */
+
+.section .fini
+.global _fini
+.type _fini, @function
+_fini:
+       /* gcc will nicely put the contents of crtbegin.o's .fini section here. */
diff --git a/Usermode/Libraries/crt0.o_src/native-crtn.S b/Usermode/Libraries/crt0.o_src/native-crtn.S
new file mode 100644 (file)
index 0000000..636743c
--- /dev/null
@@ -0,0 +1,5 @@
+.section .init
+       /* gcc will nicely put the contents of crtend.o's .init section here. */
+
+.section .fini
+       /* gcc will nicely put the contents of crtend.o's .fini section here. */
index 9da4e43..0b38690 100644 (file)
@@ -34,6 +34,7 @@
 #define _SysFDFlags    acess__SysFDFlags
 #define _SysClose      acess__SysClose
 #define _SysRead       acess__SysRead
+#define _SysTruncate   acess__SysTruncate
 #define _SysWrite      acess__SysWrite
 #define _SysSeek       acess__SysSeek
 #define _SysTell       acess__SysTell
@@ -46,5 +47,9 @@
 #define _SysSelect     acess__SysSelect
 #define _SysMkDir      acess__SysMkDir
 #define _SysUnlink     acess__SysUnlink
+#define _SysMMap       acess__SysMMap
+#define _SysMUnMap     acess__SysMUnMap
+#define _SysMarshalFD  acess__SysMarshalFD
+#define _SysUnMarshalFD        acess__SysUnMarshalFD
 
 #define _errno acess__errno
index 0643ba4..4e0f145 100644 (file)
@@ -115,7 +115,12 @@ extern int _SysSelect(int nfds, fd_set *read, fd_set *write, fd_set *err, int64_
 extern int     _SysMkDir(const char *dirname);
 extern int     _SysUnlink(const char *pathname);
 extern void*   _SysMMap(void *addr, size_t length, unsigned int _flags, int fd, uint64_t offset);
-#define _SysMMap(addr,length,flags,prot,fd,offset)     _SysMMap(addr,length,(flags|(prot<<16)), fd, offset)
+#ifdef _SysMMap
+# undef _SysMMap
+# define _SysMMap(addr,length,flags,prot,fd,offset)    acess__SysMMap(addr,length,(flags|(prot<<16)), fd, offset)
+#else
+# define _SysMMap(addr,length,flags,prot,fd,offset)    _SysMMap(addr,length,(flags|(prot<<16)), fd, offset)
+#endif
 extern int     _SysMUnMap(void *addr, size_t length);
 extern uint64_t        _SysMarshalFD(int FD);
 extern int     _SysUnMarshalFD(uint64_t Handle);
index c279a04..c530c55 100644 (file)
@@ -9,7 +9,8 @@ CPPFLAGS += -I$(AXWIN4DIR)Common/include/
 CFLAGS   += -Wextra
 CXXFLAGS +=
 ASFLAGS  +=
-LDFLAGS  += -soname libaxwin4.so -Map map.txt -lc -lc++
+LDFLAGS  += -soname libaxwin4.so -Map map.txt
+LIBS  += -lc -lc++
 
 OBJ  = main.o ipc.o ipc_acessipcpipe.o
 OBJ += wm.o window_drawing.o
index ef0372d..7253837 100644 (file)
@@ -16,6 +16,10 @@ OBJ  = misc.o new.o guard.o cxxabi.o typeinfo.o
 OBJ += string.o mutex.o\r
 OBJ += exceptions.o exception_handling.o system_error.o\r
 OBJ += gxx_personality.o\r
+ifeq ($(ARCHDIR),native)\r
+# - Include libgcc_eh (separate in linux), and the linux libc (space avoids hack in Makefile.tpl)\r
+LIBS += -lgcc_eh -l c\r
+endif\r
 DEPFILES := $(OBJ:%.o=%.d)\r
 BIN = libc++.so\r
 ifeq ($(ARCHDIR),native)\r
index f065e89..e675388 100644 (file)
@@ -416,6 +416,7 @@ static uint64_t _get_base(uint8_t encoding, _Unwind_Context *context)
        default:
                ::_SysDebug("_get_base: Unknown encoding relativity 0x%x", (encoding & DW_EH_PE_relmask));
                ::abort();
+               for(;;);
        }
 }
 static uint64_t _read_encoded(const void *&ptr, _Unwind_Context *context, int encoding)
index e860f58..31907ee 100644 (file)
@@ -100,6 +100,7 @@ bool type_info::__is_child(const type_info &poss_child, unsigned long &offset) c
                // Multiple inheritance
                _SysDebug("TODO: type_info::__is_child - Multiple inheritance");
                abort();
+               for(;;);
        }
        else {
                // Oops!
@@ -107,6 +108,7 @@ bool type_info::__is_child(const type_info &poss_child, unsigned long &offset) c
                        typeid(poss_child).name()
                        );
                abort();
+               for(;;);
        }
 }
 
index 22849e0..4dc43e1 100644 (file)
@@ -21,7 +21,7 @@ OBJ += arch/$(ARCHDIR).ao
 DEPFILES := $(OBJ:%.o=%.d)\r
 BIN = libc.so\r
 ifeq ($(ARCHDIR),native)\r
- OBJ := $(filter-out heap.o,$(OBJ))\r
+ OBJ := $(filter-out heap.o,$(OBJ)) heap_native.o\r
  #LDFLAGS += -l c\r
  BIN = libc_acess.so\r
 endif\r
index d65fc33..71e3d6d 100644 (file)
@@ -231,7 +231,8 @@ EXPORT void free(void *mem)
        }\r
 }\r
 \r
-bool _libc_free(void *mem)\r
+// Exported for libc++\r
+EXPORT bool _libc_free(void *mem)\r
 {\r
        heap_head       *head = (heap_head*)mem - 1;\r
 \r
diff --git a/Usermode/Libraries/libc.so_src/heap_native.c b/Usermode/Libraries/libc.so_src/heap_native.c
new file mode 100644 (file)
index 0000000..0f4d9b3
--- /dev/null
@@ -0,0 +1,8 @@
+#include <stdlib.h>
+#include <stdbool.h>
+
+bool _libc_free(void *addr)
+{
+       free(addr);
+       return true;
+}
index 863b925..2cc5f2a 100644 (file)
@@ -7,6 +7,7 @@
  */
 #include <unistd.h>    // mktemp
 #include <stdlib.h>    // mkstemp
+#include <stdio.h>
 #include <string.h>    // str*
 #include <errno.h>
 
@@ -25,7 +26,7 @@ int mkstemp(char *template)
        
        for( int i = 0; i < 1000000; i ++ )
        {
-               sprintf(template+tpl_len-6, "%06d", i);
+               snprintf(template+tpl_len-6, 6+1, "%06d", i);
                int fd = open(template, O_EXCL|O_CREAT, 0600);
                if(fd == -1)    continue ;
        

UCC git Repository :: git.ucc.asn.au