From: John Hodge Date: Fri, 17 Oct 2014 10:18:20 +0000 (+0800) Subject: Fix ARCH=native compiling X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=94b8d7686d1da4e5338288f60910e6d8f68b5787;p=tpg%2Facess2.git Fix ARCH=native compiling --- diff --git a/AcessNative/ld-acess_src/exports.c b/AcessNative/ld-acess_src/exports.c index a898b5a3..10dc7bde 100644 --- a/AcessNative/ld-acess_src/exports.c +++ b/AcessNative/ld-acess_src/exports.c @@ -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), diff --git a/AcessNative/libacess-native.so_src/exports.c b/AcessNative/libacess-native.so_src/exports.c index 2f960c4f..0f71f212 100644 --- a/AcessNative/libacess-native.so_src/exports.c +++ b/AcessNative/libacess-native.so_src/exports.c @@ -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) diff --git a/Makefile b/Makefile index 5992b27b..64b757e4 100644 --- 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 diff --git a/Makefile.cfg b/Makefile.cfg index 29f13466..1eedf8ec 100644 --- a/Makefile.cfg +++ b/Makefile.cfg @@ -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)) diff --git a/Usermode/Applications/Makefile.cfg b/Usermode/Applications/Makefile.cfg index 72611452..f87736c9 100644 --- a/Usermode/Applications/Makefile.cfg +++ b/Usermode/Applications/Makefile.cfg @@ -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 diff --git a/Usermode/Applications/Makefile.tpl b/Usermode/Applications/Makefile.tpl index 33139132..6ce97c45 100644 --- a/Usermode/Applications/Makefile.tpl +++ b/Usermode/Applications/Makefile.tpl @@ -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 diff --git a/Usermode/Libraries/Makefile.tpl b/Usermode/Libraries/Makefile.tpl index 8b271212..5e241f23 100644 --- a/Usermode/Libraries/Makefile.tpl +++ b/Usermode/Libraries/Makefile.tpl @@ -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)) diff --git a/Usermode/Libraries/crt0.o_src/Makefile b/Usermode/Libraries/crt0.o_src/Makefile index 9d84b923..29bdb0ee 100644 --- a/Usermode/Libraries/crt0.o_src/Makefile +++ b/Usermode/Libraries/crt0.o_src/Makefile @@ -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 index 00000000..01c8127f --- /dev/null +++ b/Usermode/Libraries/crt0.o_src/native-crti.S @@ -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 index 00000000..636743c2 --- /dev/null +++ b/Usermode/Libraries/crt0.o_src/native-crtn.S @@ -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. */ 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 index 9da4e433..0b386904 100644 --- 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 @@ -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 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 0643ba46..4e0f1452 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 @@ -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); diff --git a/Usermode/Libraries/libaxwin4.so_src/Makefile b/Usermode/Libraries/libaxwin4.so_src/Makefile index c279a047..c530c558 100644 --- a/Usermode/Libraries/libaxwin4.so_src/Makefile +++ b/Usermode/Libraries/libaxwin4.so_src/Makefile @@ -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 diff --git a/Usermode/Libraries/libc++.so_src/Makefile b/Usermode/Libraries/libc++.so_src/Makefile index ef0372db..72538379 100644 --- a/Usermode/Libraries/libc++.so_src/Makefile +++ b/Usermode/Libraries/libc++.so_src/Makefile @@ -16,6 +16,10 @@ OBJ = misc.o new.o guard.o cxxabi.o typeinfo.o OBJ += string.o mutex.o OBJ += exceptions.o exception_handling.o system_error.o OBJ += gxx_personality.o +ifeq ($(ARCHDIR),native) +# - Include libgcc_eh (separate in linux), and the linux libc (space avoids hack in Makefile.tpl) +LIBS += -lgcc_eh -l c +endif DEPFILES := $(OBJ:%.o=%.d) BIN = libc++.so ifeq ($(ARCHDIR),native) diff --git a/Usermode/Libraries/libc++.so_src/gxx_personality.cc b/Usermode/Libraries/libc++.so_src/gxx_personality.cc index f065e899..e6753889 100644 --- a/Usermode/Libraries/libc++.so_src/gxx_personality.cc +++ b/Usermode/Libraries/libc++.so_src/gxx_personality.cc @@ -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) diff --git a/Usermode/Libraries/libc++.so_src/typeinfo.cc b/Usermode/Libraries/libc++.so_src/typeinfo.cc index e860f586..31907ee1 100644 --- a/Usermode/Libraries/libc++.so_src/typeinfo.cc +++ b/Usermode/Libraries/libc++.so_src/typeinfo.cc @@ -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(;;); } } diff --git a/Usermode/Libraries/libc.so_src/Makefile b/Usermode/Libraries/libc.so_src/Makefile index 22849e0e..4dc43e1c 100644 --- a/Usermode/Libraries/libc.so_src/Makefile +++ b/Usermode/Libraries/libc.so_src/Makefile @@ -21,7 +21,7 @@ OBJ += arch/$(ARCHDIR).ao DEPFILES := $(OBJ:%.o=%.d) BIN = libc.so ifeq ($(ARCHDIR),native) - OBJ := $(filter-out heap.o,$(OBJ)) + OBJ := $(filter-out heap.o,$(OBJ)) heap_native.o #LDFLAGS += -l c BIN = libc_acess.so endif diff --git a/Usermode/Libraries/libc.so_src/heap.c b/Usermode/Libraries/libc.so_src/heap.c index d65fc33f..71e3d6dc 100644 --- a/Usermode/Libraries/libc.so_src/heap.c +++ b/Usermode/Libraries/libc.so_src/heap.c @@ -231,7 +231,8 @@ EXPORT void free(void *mem) } } -bool _libc_free(void *mem) +// Exported for libc++ +EXPORT bool _libc_free(void *mem) { heap_head *head = (heap_head*)mem - 1; diff --git a/Usermode/Libraries/libc.so_src/heap_native.c b/Usermode/Libraries/libc.so_src/heap_native.c new file mode 100644 index 00000000..0f4d9b3b --- /dev/null +++ b/Usermode/Libraries/libc.so_src/heap_native.c @@ -0,0 +1,8 @@ +#include +#include + +bool _libc_free(void *addr) +{ + free(addr); + return true; +} diff --git a/Usermode/Libraries/libposix.so_src/mktemp.c b/Usermode/Libraries/libposix.so_src/mktemp.c index 863b9256..2cc5f2ad 100644 --- a/Usermode/Libraries/libposix.so_src/mktemp.c +++ b/Usermode/Libraries/libposix.so_src/mktemp.c @@ -7,6 +7,7 @@ */ #include // mktemp #include // mkstemp +#include #include // str* #include @@ -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 ;