Skip to content

Commit

Permalink
ARMv7 - Fix compiler and partial compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
thepowersgang committed Feb 13, 2015
1 parent 09a0283 commit 3d67e21
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 28 deletions.
8 changes: 2 additions & 6 deletions 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

Expand Down
12 changes: 7 additions & 5 deletions Externals/cross-compiler/Makefile
@@ -1,5 +1,6 @@


#
#
#
-include ../config.mk

GCC_ARCHIVE:=$(lastword $(sort $(wildcard gcc-*.tar.bz2)))
Expand All @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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-%)


Expand Up @@ -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
@@ -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 ;;
@@ -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 \
@@ -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 ;;

@@ -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\"

7 changes: 6 additions & 1 deletion Externals/cross-compiler/patches/gcc/gcc/config.gcc.patch
Expand Up @@ -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"
Expand All @@ -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*)
@@ -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"
;;
Expand All @@ -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*)

6 changes: 5 additions & 1 deletion Makefile.cfg
Expand Up @@ -2,6 +2,8 @@
# Acess2 Build Configuration
#

V ?= @

ACESSDIR := $(dir $(lastword $(MAKEFILE_LIST)))
ACESSDIR := $(shell cd $(ACESSDIR) && pwd)

Expand All @@ -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
Expand All @@ -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)
Expand Down
31 changes: 31 additions & 0 deletions 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. */
41 changes: 41 additions & 0 deletions 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
9 changes: 5 additions & 4 deletions Usermode/Libraries/ld-acess.so_src/Makefile
Expand Up @@ -33,23 +33,24 @@ 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)

# Preprocessing objects if needed
$(_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

Expand Down
6 changes: 3 additions & 3 deletions Usermode/Libraries/ld-acess.so_src/arch/armv7.S.h
Expand Up @@ -16,7 +16,7 @@

b _exit

@ Stupid GCC
// Stupid GCC
.globl __ucmpdi2
__ucmpdi2:
cmp r0, r2
Expand All @@ -32,8 +32,8 @@
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
Expand Down
4 changes: 3 additions & 1 deletion Usermode/Libraries/libc++.so_src/include_exp/typeinfo
Expand Up @@ -8,6 +8,8 @@
#ifndef _LIBCXX__TYPEINFO_
#define _LIBCXX__TYPEINFO_

#include <cstddef>

namespace std {

// Type information class
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Usermode/Libraries/libc++.so_src/typeinfo.cc
Expand Up @@ -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());

Expand Down

0 comments on commit 3d67e21

Please sign in to comment.