From 3d67e21210fbcad7cdcbfa9c348019a191ce1798 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 13 Feb 2015 19:18:48 +0800 Subject: [PATCH] ARMv7 - Fix compiler and partial compilation --- BuildConf/armv7/Makefile.cfg | 8 +--- Externals/cross-compiler/Makefile | 12 +++--- .../patches/binutils/bfd/config.bfd.patch | 4 +- .../patches/binutils/gas/configure.tgt.patch | 3 +- .../patches/binutils/ld/Makefile.in.patch | 4 +- .../patches/binutils/ld/configure.tgt.patch | 3 +- .../binutils/ld/emulparams/acess2_arm.sh | 19 +++++++++ .../patches/gcc/gcc/config.gcc.patch | 7 +++- .../patches/gcc/libgcc/config.host.patch | 8 +++- Makefile.cfg | 6 ++- Usermode/Libraries/crt0.o_src/armv7-crti.S | 31 ++++++++++++++ Usermode/Libraries/crt0.o_src/armv7-crtn.S | 41 +++++++++++++++++++ Usermode/Libraries/ld-acess.so_src/Makefile | 9 ++-- .../Libraries/ld-acess.so_src/arch/armv7.S.h | 6 +-- .../libc++.so_src/include_exp/typeinfo | 4 +- Usermode/Libraries/libc++.so_src/typeinfo.cc | 2 +- 16 files changed, 139 insertions(+), 28 deletions(-) create mode 100644 Externals/cross-compiler/patches/binutils/ld/emulparams/acess2_arm.sh create mode 100644 Usermode/Libraries/crt0.o_src/armv7-crti.S create mode 100644 Usermode/Libraries/crt0.o_src/armv7-crtn.S diff --git a/BuildConf/armv7/Makefile.cfg b/BuildConf/armv7/Makefile.cfg index a2e4cc5b..3180234a 100644 --- a/BuildConf/armv7/Makefile.cfg +++ b/BuildConf/armv7/Makefile.cfg @@ -1,13 +1,9 @@ +TRIPLET = arm-pc-acess2 ARM_CPUNAME = gerneric-armv7 -CC = arm-eabi-gcc -mcpu=$(ARM_CPUNAME) -AS = arm-eabi-gcc -mcpu=$(ARM_CPUNAME) -c -CXX = arm-eabi-g++ -mcpu=$(ARM_CPUNAME) -LD = arm-eabi-ld -OBJDUMP = arm-eabi-objdump +#AS = $(TRIPLET)-gcc -mcpu=$(ARM_CPUNAME) -c DISASM := $(OBJDUMP) -d -S ARCHDIR = armv7 -STRIP = arm-eabi-strip ASSUFFIX = S diff --git a/Externals/cross-compiler/Makefile b/Externals/cross-compiler/Makefile index dbb6ad3f..b3a489d0 100644 --- a/Externals/cross-compiler/Makefile +++ b/Externals/cross-compiler/Makefile @@ -1,5 +1,6 @@ - - +# +# +# -include ../config.mk GCC_ARCHIVE:=$(lastword $(sort $(wildcard gcc-*.tar.bz2))) @@ -16,7 +17,7 @@ ifeq ($(BINUTILS_ARCHIVE),) $(error No archive found) endif -BINUTILS_CHANGES := config.sub bfd/config.bfd gas/configure.tgt ld/configure.tgt ld/emulparams/acess2_i386.sh ld/emulparams/acess2_amd64.sh ld/Makefile.in +BINUTILS_CHANGES := config.sub bfd/config.bfd gas/configure.tgt ld/configure.tgt ld/emulparams/acess2_i386.sh ld/emulparams/acess2_amd64.sh ld/emulparams/acess2_arm.sh ld/Makefile.in GCC_CHANGES := config.sub gcc/config.gcc gcc/config/acess2.h libgcc/config.host gcc/config/acess2.opt # libstdc++-v3/crossconfig.m4 config/override.m4 @@ -25,8 +26,8 @@ GCC_TARGETS := gcc target-libgcc # target-libstdc++-v3 PREFIX := $(OUTDIR)-BUILD -BDIR_GCC := build-$(ARCH)/gcc -BDIR_BINUTILS := build-$(ARCH)/binutils +BDIR_GCC := build-$(ARCH)/gcc/ +BDIR_BINUTILS := build-$(ARCH)/binutils/ .PHONY: all clean binutils gcc include @@ -83,6 +84,7 @@ $(BDIR_GCC)/Makefile: Makefile $(addprefix $(GCC_DIR)/,$(GCC_CHANGES)) $(GCC_DIR $(PREFIX)/bin/$(TARGET)-gcc: $(BDIR_GCC)/Makefile @PATH=$(PREFIX)/bin:$$PATH make -C $(BDIR_GCC) $(GCC_TARGETS:%=all-%) -j $(PARLEVEL) + @PATH=$(PREFIX)/bin:$$PATH make -C $(BDIR_GCC)libstdc++-v3/ all-target-libsupc++ -j $(PARLEVEL) @PATH=$(PREFIX)/bin:$$PATH make -C $(BDIR_GCC) $(GCC_TARGETS:%=install-%) diff --git a/Externals/cross-compiler/patches/binutils/bfd/config.bfd.patch b/Externals/cross-compiler/patches/binutils/bfd/config.bfd.patch index 6b616424..0c018310 100644 --- a/Externals/cross-compiler/patches/binutils/bfd/config.bfd.patch +++ b/Externals/cross-compiler/patches/binutils/bfd/config.bfd.patch @@ -12,7 +12,7 @@ + want64=true + ;; + arm-*-acess2) -+ targ_defvec=bfd_elf32_arm_vec -+ targ_selvecs="bfd_elf32_arm_vec" ++ targ_defvec=bfd_elf32_littlearm_vec ++ targ_selvecs="bfd_elf32_bigarm_vec" + ;; # END OF targmatch.h diff --git a/Externals/cross-compiler/patches/binutils/gas/configure.tgt.patch b/Externals/cross-compiler/patches/binutils/gas/configure.tgt.patch index a024c080..6148df19 100644 --- a/Externals/cross-compiler/patches/binutils/gas/configure.tgt.patch +++ b/Externals/cross-compiler/patches/binutils/gas/configure.tgt.patch @@ -1,6 +1,7 @@ --- gas/configure.tgt 2011-07-29 00:00:00.000000 +0000 +++ gas/configure.tgt 2013-03-01 10:45:00.000000 +0800 -@@ -173,2 +173,3 @@ +@@ -173,2 +173,4 @@ i386-sequent-bsd*) fmt=aout em=dynix ;; + i386-*-acess2*) fmt=elf ;; ++ arm-*-acess2*) fmt=elf ;; i386-*-beospe*) fmt=coff em=pe ;; diff --git a/Externals/cross-compiler/patches/binutils/ld/Makefile.in.patch b/Externals/cross-compiler/patches/binutils/ld/Makefile.in.patch index 76439619..becadff7 100644 --- a/Externals/cross-compiler/patches/binutils/ld/Makefile.in.patch +++ b/Externals/cross-compiler/patches/binutils/ld/Makefile.in.patch @@ -1,9 +1,11 @@ --- ld/Makefile.in +++ ld/Makefile.in -@@ -2627,2 +2627,6 @@ +@@ -2627,2 +2627,8 @@ ${GENSCRIPTS} elf32xtensa "$(tdir_elf32xtensa)" +eacess2_i386.c: $(srcdir)/emulparams/acess2_i386.sh $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} acess2_i386 "$(tdir_acess2_i386)" +eacess2_amd64.c: $(srcdir)/emulparams/acess2_amd64.sh $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} + ${GENSCRIPTS} acess2_amd64 "$(tdir_acess2_amd64)" ++eacess2_arm.c: $(srcdir)/emulparams/acess2_arm.sh $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} ++ ${GENSCRIPTS} acess2_arm "$(tdir_acess2_arm)" eelf_i386.c: $(srcdir)/emulparams/elf_i386.sh \ diff --git a/Externals/cross-compiler/patches/binutils/ld/configure.tgt.patch b/Externals/cross-compiler/patches/binutils/ld/configure.tgt.patch index cc3dc88b..1d5a4853 100644 --- a/Externals/cross-compiler/patches/binutils/ld/configure.tgt.patch +++ b/Externals/cross-compiler/patches/binutils/ld/configure.tgt.patch @@ -1,7 +1,8 @@ --- ld/configure.tgt +++ ld/configure.tgt -@@ -167,1 +167,3 @@ +@@ -167,1 +167,4 @@ i[3-7]86-*-nto-qnx*) targ_emul=i386nto ;; +i[3-7]86-*-acess2*) targ_emul=acess2_i386 ;; +x86_64-*-acess2*) targ_emul=acess2_amd64 ;; ++arm-*-acess2*) targ_emul=acess2_arm ;; diff --git a/Externals/cross-compiler/patches/binutils/ld/emulparams/acess2_arm.sh b/Externals/cross-compiler/patches/binutils/ld/emulparams/acess2_arm.sh new file mode 100644 index 00000000..87ef5df0 --- /dev/null +++ b/Externals/cross-compiler/patches/binutils/ld/emulparams/acess2_arm.sh @@ -0,0 +1,19 @@ +SCRIPT_NAME=elf +OUTPUT_FORMAT="elf32-littlearm" +BIG_OUTPUT_FORMAT="elf32-bigarm" +LITTLE_OUTPUT_FORMAT="elf32-littlearm" +TEXT_START_ADDR=0x8000 +MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" +COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" +TEMPLATE_NAME=elf32 + +ARCH=arm +MACHINE= +GENERATE_SHLIB_SCRIPT=yes +GENERATE_PIE_SCRIPT=yes + +NO_SMALL_DATA=yes +SEPARATE_GOTPLT=12 + +ELF_INTERPRETER_NAME=\"/Acess/Libs/ld-acess.so\" + diff --git a/Externals/cross-compiler/patches/gcc/gcc/config.gcc.patch b/Externals/cross-compiler/patches/gcc/gcc/config.gcc.patch index 9c7087ab..c6f085ec 100644 --- a/Externals/cross-compiler/patches/gcc/gcc/config.gcc.patch +++ b/Externals/cross-compiler/patches/gcc/gcc/config.gcc.patch @@ -14,7 +14,7 @@ + ;; *-*-darwin*) -@@ -1192,2 +1196,12 @@ +@@ -1192,2 +1196,17 @@ ;; +i[3-7]86-*-acess2*) + tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h i386/i386elf.h newlib-stdint.h acess2.h" @@ -25,5 +25,10 @@ + tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h acess2.h" + tmake_file="i386/t-i386elf i386/t-crtstuff t-svr4" + use_fixproto=yes ++ ;; ++arm-*-acess2*) ++ tm_file="dbxelf.h elfos.h arm/unknown-elf.h arm/elf.h arm/bpabi.h newlib-stdint.h acess2.h arm/aout.h arm/arm.h" ++ tmake_file="arm/t-arm arm/t-arm-elf arm/t-bpabi" ++ use_fixproto=yes + ;; i[34567]86-*-elf*) diff --git a/Externals/cross-compiler/patches/gcc/libgcc/config.host.patch b/Externals/cross-compiler/patches/gcc/libgcc/config.host.patch index e250c603..52725e33 100644 --- a/Externals/cross-compiler/patches/gcc/libgcc/config.host.patch +++ b/Externals/cross-compiler/patches/gcc/libgcc/config.host.patch @@ -1,6 +1,6 @@ --- libgcc/config.host +++ libgcc/config.host -@@ -523,4 +523,12 @@ +@@ -523,4 +523,18 @@ x86_64-*-elf*) tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic" ;; @@ -11,6 +11,12 @@ +x86_64-*-acess2*) + extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o crtendT.o" + tmake_file="$tmake_file i386/t-crtstuff t-crtstuff-pic t-libgcc-pic" ++ ;; ++arm-*-acess2*) ++ extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o crtendT.o" ++ tmake_file="${tmake_file} arm/t-arm arm/t-elf t-fixedpoint-gnu-prefix arm/t-bpabi t-softfp-sfdf t-softfp-excl arm/t-softfp t-softfp" ++ tm_file="$tm_file arm/bpabi-lib.h" ++ unwind_header=config/arm/unwind-arm.h + ;; i[34567]86-*-freebsd*) diff --git a/Makefile.cfg b/Makefile.cfg index 1eedf8ec..d12710cf 100644 --- a/Makefile.cfg +++ b/Makefile.cfg @@ -2,6 +2,8 @@ # Acess2 Build Configuration # +V ?= @ + ACESSDIR := $(dir $(lastword $(MAKEFILE_LIST))) ACESSDIR := $(shell cd $(ACESSDIR) && pwd) @@ -17,7 +19,6 @@ xMKDIR := mmd -D s # Default build programs #CC := gcc #LD := ld -AS := nasm DISASM := objdump -d -S RM := @rm -f STRIP := strip @@ -42,6 +43,9 @@ CC = $(COMPILERDIR)bin/$(TRIPLET)-gcc CXX = $(COMPILERDIR)bin/$(TRIPLET)-g++ LD = $(COMPILERDIR)bin/$(TRIPLET)-ld OBJDUMP = $(COMPILERDIR)bin/$(TRIPLET)-objdump + ifeq ($(AS),as) + AS = $(COMPILERDIR)bin/$(TRIPLET)-gcc -c + endif endif ifneq ($(ARCH),host) diff --git a/Usermode/Libraries/crt0.o_src/armv7-crti.S b/Usermode/Libraries/crt0.o_src/armv7-crti.S new file mode 100644 index 00000000..310cd6ab --- /dev/null +++ b/Usermode/Libraries/crt0.o_src/armv7-crti.S @@ -0,0 +1,31 @@ +.section .init +.global _init +.type _init, function +_init: +#ifdef __thumb__ + .thumb + + push {r3, r4, r5, r6, r7, lr} +#else + .arm + mov ip, sp + stmdb sp!, {r3, r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc} + sub fp, ip, #4 +#endif + /* gcc will nicely put the contents of crtbegin.o's .init section here. */ + +.section .fini +.global _fini +.type _fini, function +_fini: +#ifdef __thumb__ + .thumb + + push {r3, r4, r5, r6, r7, lr} +#else + .arm + mov ip, sp + stmdb sp!, {r3, r4, r5, r6, r7, r8, r9, sl, fp, ip, lr, pc} + sub fp, ip, #4 +#endif + /* gcc will nicely put the contents of crtbegin.o's .fini section here. */ diff --git a/Usermode/Libraries/crt0.o_src/armv7-crtn.S b/Usermode/Libraries/crt0.o_src/armv7-crtn.S new file mode 100644 index 00000000..1c3e1113 --- /dev/null +++ b/Usermode/Libraries/crt0.o_src/armv7-crtn.S @@ -0,0 +1,41 @@ +.section .init + /* gcc will nicely put the contents of crtend.o's .init section here. */ +#ifdef __thumb__ + .thumb + + pop {r3, r4, r5, r6, r7} + pop {r3} + mov lr, r3 +#else + .arm + + sub sp, fp, #40 + ldmfd sp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, lr} +#endif + +#if defined __THUMB_INTERWORK__ || defined __thumb__ + bx lr +#else + mov pc, lr +#endif + +.section .fini + /* gcc will nicely put the contents of crtend.o's .fini section here. */ +#ifdef __thumb__ + .thumb + + pop {r3, r4, r5, r6, r7} + pop {r3} + mov lr, r3 +#else + .arm + + sub sp, fp, #40 + ldmfd sp, {r4, r5, r6, r7, r8, r9, sl, fp, sp, lr} +#endif + +#if defined __THUMB_INTERWORK__ || defined __thumb__ + bx lr +#else + mov pc, lr +#endif diff --git a/Usermode/Libraries/ld-acess.so_src/Makefile b/Usermode/Libraries/ld-acess.so_src/Makefile index 78aac4bd..7ee8a960 100644 --- a/Usermode/Libraries/ld-acess.so_src/Makefile +++ b/Usermode/Libraries/ld-acess.so_src/Makefile @@ -33,15 +33,16 @@ include ../Makefile.tpl # create libld-acess.so $(_XBIN): $(_OBJPREFIX)_stublib.o @echo [LD] -o -shared libld-acess.so - $(LD) -shared -o $@ $< + $V$(LD) -shared -o $@ $< # @$(LD) $(LDFLAGS) -o $@ $(OBJ) # Override .ao to look in the object prefix for the source -$(_OBJPREFIX)arch/$(ARCHDIR).ao_: $(_OBJPREFIX)arch/$(ARCHDIR).$(ASSUFFIX) +$(_OBJPREFIX)arch/$(ARCHDIR).ao_: $(_OBJPREFIX)arch/$(ARCHDIR).$(ASSUFFIX) Makefile @echo [AS] -o $@ @mkdir -p $(dir $@) - @$(AS) $(ASFLAGS) -o $@ $< + #$V$(AS) $(ASFLAGS) -o $@ $< + $V$(CC) -c $(ASFLAGS) -o $@ $< #.PRECIOUS: $(OBJ:%.ao=%.asm) @@ -49,7 +50,7 @@ $(_OBJPREFIX)arch/$(ARCHDIR).ao_: $(_OBJPREFIX)arch/$(ARCHDIR).$(ASSUFFIX) $(_OBJPREFIX)arch/$(ARCHDIR).$(ASSUFFIX): arch/$(ARCHDIR).$(ASSUFFIX).h arch/syscalls.s.h @echo [CPP] -o $@ @mkdir -p $(dir $@) - @$(CPP) $(CPPFLAGS) -P -D__ASSEMBLER__ $< -o $@ + $V$(CPP) $(CPPFLAGS) -P -D__ASSEMBLER__ $< -o $@ $(_OBJPREFIX)arch/$(ARCHDIR).$(ASSUFFIX): $(ACESSDIR)/KernelLand/Kernel/include/syscalls.h diff --git a/Usermode/Libraries/ld-acess.so_src/arch/armv7.S.h b/Usermode/Libraries/ld-acess.so_src/arch/armv7.S.h index 351c8414..7e604f1d 100644 --- a/Usermode/Libraries/ld-acess.so_src/arch/armv7.S.h +++ b/Usermode/Libraries/ld-acess.so_src/arch/armv7.S.h @@ -16,7 +16,7 @@ _start: b _exit -@ Stupid GCC +// Stupid GCC .globl __ucmpdi2 __ucmpdi2: cmp r0, r2 @@ -32,8 +32,8 @@ __ucmpdi2: mov r0, #1 mov pc, lr -@ Well, can't blame it -@ - Clear the instruction cache +//@ Well, can't blame it +// - Clear the instruction cache .globl __clear_cache __clear_cache: svc #0x1001 diff --git a/Usermode/Libraries/libc++.so_src/include_exp/typeinfo b/Usermode/Libraries/libc++.so_src/include_exp/typeinfo index fd823db1..c8b037ce 100644 --- a/Usermode/Libraries/libc++.so_src/include_exp/typeinfo +++ b/Usermode/Libraries/libc++.so_src/include_exp/typeinfo @@ -8,6 +8,8 @@ #ifndef _LIBCXX__TYPEINFO_ #define _LIBCXX__TYPEINFO_ +#include + namespace std { // Type information class @@ -21,7 +23,7 @@ public: const char* name() const; // acess - bool __is_child(const type_info &, unsigned long&) const; + bool __is_child(const type_info &, size_t&) const; private: type_info (const type_info& rhs); type_info& operator= (const type_info& rhs); diff --git a/Usermode/Libraries/libc++.so_src/typeinfo.cc b/Usermode/Libraries/libc++.so_src/typeinfo.cc index 31907ee1..99bfedc5 100644 --- a/Usermode/Libraries/libc++.so_src/typeinfo.cc +++ b/Usermode/Libraries/libc++.so_src/typeinfo.cc @@ -71,7 +71,7 @@ bool type_info::is_subclass() const } // Acess-defined -bool type_info::__is_child(const type_info &poss_child, unsigned long &offset) const +bool type_info::__is_child(const type_info &poss_child, size_t &offset) const { _SysDebug("typeids = this:%s , poss_child:%s", typeid(*this).name(), typeid(poss_child).name()); -- 2.20.1