[Mirmince-commits] {mirmince} branch master updated. ddb7e316691331f0de5a88ce5412718867838f22
tg at freewrt.org
tg at freewrt.org
Sat Jan 5 05:24:21 UTC 2013
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Main git repository for FreeWRT project mirmince".
The branch, master has been updated
via ddb7e316691331f0de5a88ce5412718867838f22 (commit)
via 8720c6f6872a002b8e95d755214959a6cfb496b3 (commit)
from a05a9055be8f4a345002d9ce195171cdc1cad7c6 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ddb7e316691331f0de5a88ce5412718867838f22
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sat Jan 5 05:24:21 2013 +0000
(very) rough first draft: infrastructure and the CSU
commit 8720c6f6872a002b8e95d755214959a6cfb496b3
Author: Thorsten Glaser <tg at mirbsd.org>
Date: Sat Jan 5 03:09:07 2013 +0000
ignore git+ssh://freewrt.org/scmrepos/git/mirmince/tests.git
-----------------------------------------------------------------------
Summary of changes:
.gitignore | 2 ++
BSDmakefile | 86 ++++++++++++++++++++++++++++++++++++++++++++
do-install | 51 ++++++++++++++++++++++++++
gcc-spec | 27 ++++++++++++++
gcc-wrap | 50 ++++++++++++++++++++++++++
include/mirmince/asm.h | 53 +++++++++++++++++++++++++++
include/mirmince/c.h | 33 +++++++++++++++++
include/stdlib.h | 12 +++++++
md/i386/asm.h | 7 ++++
md/i386/mincebeg_md.S | 45 +++++++++++++++++++++++
mi/mincebeg_mi.c | 38 ++++++++++++++++++++
osdep/mirbsd/Makefile.inc | 17 +++++++++
osdep/mirbsd/asm.h | 3 ++
osdep/mirbsd/c.h | 3 ++
osdep/mirbsd/mincebeg_os.S | 35 ++++++++++++++++++
15 files changed, 462 insertions(+)
create mode 100644 .gitignore
create mode 100644 BSDmakefile
create mode 100644 do-install
create mode 100644 gcc-spec
create mode 100644 gcc-wrap
create mode 100644 include/mirmince/asm.h
create mode 100644 include/mirmince/c.h
create mode 100644 include/stdlib.h
create mode 100644 md/i386/Makefile.inc
create mode 100644 md/i386/asm.h
create mode 100644 md/i386/c.h
create mode 100644 md/i386/mincebeg_md.S
create mode 100644 mi/Makefile.inc
create mode 100644 mi/mincebeg_mi.c
create mode 100644 osdep/mirbsd/Makefile.inc
create mode 100644 osdep/mirbsd/asm.h
create mode 100644 osdep/mirbsd/c.h
create mode 100644 osdep/mirbsd/mincebeg_os.S
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3d97e4a
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+obj
+tests
diff --git a/BSDmakefile b/BSDmakefile
new file mode 100644
index 0000000..be64e02
--- /dev/null
+++ b/BSDmakefile
@@ -0,0 +1,86 @@
+# Copyright © 2013
+# Thorsten Glaser <tg at mirbsd.org>
+#
+# Provided that these terms and disclaimer and all copyright notices
+# are retained or reproduced in an accompanying document, permission
+# is granted to deal in this work without restriction, including un‐
+# limited rights to use, publicly perform, distribute, sell, modify,
+# merge, give away, or sublicence.
+#
+# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
+# the utmost extent permitted by applicable law, neither express nor
+# implied; without malicious intent or gross negligence. In no event
+# may a licensor, author or contributor be held liable for indirect,
+# direct, other damage, loss, or other issues arising in any way out
+# of dealing in the work, even if advised of the possibility of such
+# damage or existence of a defect, except proven that it results out
+# of said person’s immediate fault when using the work as intended.
+#-
+# Top-level Makefile for mirₘᵢₙcⒺ (experimental)
+
+# settings (will change later)
+CC?= mgcc
+LD?= ld
+DST= /opt/mirmince
+TG_ARCH= i386
+TG_OS= mirbsd
+
+# not settings
+SHELL= /bin/mksh
+LIBCDIR= ${.CURDIR}
+TG_CC:= ${CC}
+CC:= ${DST:Q}/bin/cc
+
+all:
+
+obj:
+ mkdir -p ${.CURDIR:Q}/obj
+
+depend:
+
+clean:
+ test -d ${.CURDIR:Q}/obj/.
+ rm -f *.o *.a
+
+install:
+ ${SHELL} ${.CURDIR:Q}/do-install ${TG_CC:Q} ${DST:Q} \
+ ${TG_ARCH:Q} ${TG_OS:Q}
+
+CPPFLAGS:= -D_ALL_SOURCE
+CFLAGS:=
+AFLAGS:=
+LDFLAGS:=
+LDADD:=
+
+.PATH: ${LIBCDIR}/osdep/${TG_OS}
+.PATH: ${LIBCDIR}/md/${TG_ARCH}
+.PATH: ${LIBCDIR}/mi
+
+.include "${LIBCDIR}/mi/Makefile.inc"
+.include "${LIBCDIR}/md/${TG_ARCH}/Makefile.inc"
+.include "${LIBCDIR}/osdep/${TG_OS}/Makefile.inc"
+
+.ifdef DEBUG
+CFLAGS+= -g3
+.endif
+
+.SUFFIXES: .a .o .S .c .h
+.LIBS: .a
+
+COMPILE.S:= ${CC} -D_ASM_SOURCE ${CPPFLAGS} ${AFLAGS} -c
+COMPILE.c:= ${CC} ${CPPFLAGS} ${CFLAGS} -c
+LINK.c:= ${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS}
+
+.o:
+ ${LINK.c} -o $@ ${.IMPSRC} ${LDADD}
+.c.o:
+ ${COMPILE.c} ${CFLAGS_${.TARGET:T:R}:M*} ${.IMPSRC}
+.S.o:
+ ${COMPILE.S} ${AFLAGS_${.TARGET:T:R}:M*} ${.IMPSRC}
+
+all: mincebeg.o
+
+mincebeg.o: mincebeg_os.o mincebeg_md.o mincebeg_mi.o
+ ${LD} -r -o $@.o $>
+ #XXX the presence of environ here is only temporary
+ objcopy -x -G _mince_csu_init -G environ $@.o $@
diff --git a/do-install b/do-install
new file mode 100644
index 0000000..ff866d7
--- /dev/null
+++ b/do-install
@@ -0,0 +1,51 @@
+#!/bin/mksh
+#-
+# Copyright © 2013
+# Thorsten Glaser <tg at mirbsd.org>
+#
+# Provided that these terms and disclaimer and all copyright notices
+# are retained or reproduced in an accompanying document, permission
+# is granted to deal in this work without restriction, including un‐
+# limited rights to use, publicly perform, distribute, sell, modify,
+# merge, give away, or sublicence.
+#
+# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
+# the utmost extent permitted by applicable law, neither express nor
+# implied; without malicious intent or gross negligence. In no event
+# may a licensor, author or contributor be held liable for indirect,
+# direct, other damage, loss, or other issues arising in any way out
+# of dealing in the work, even if advised of the possibility of such
+# damage or existence of a defect, except proven that it results out
+# of said person’s immediate fault when using the work as intended.
+#-
+# For now. This will change later (more flexible, etc).
+
+cc=$1
+dst=$2
+arch=$3
+os=$4
+
+cd "$(dirname "$0")"
+rm -rf "$dst"/{bin,include,lib,libdata}
+mkdir -p "$dst"/{bin,include/mirmince/{md,osdep},lib,libdata}
+cp LICENCE "$dst"/libdata/
+while IFS= read -r line; do
+ print -r -- "${line//@@DST@@/"${dst at Q}"}"
+done <gcc-spec >"$dst"/libdata/gcc-spec
+while IFS= read -r line; do
+ line=${line//@@CC@@/"${cc at Q}"}
+ line=${line//@@MD@@/"${arch at Q}"}
+ line=${line//@@OS@@/"${os at Q}"}
+ print -r -- "${line//@@DST@@/"${dst at Q}"}"
+done <gcc-wrap >"$dst"/bin/cc
+chmod +x "$dst"/bin/cc
+find include -name \*.h -print0 | pax -rw -0 "$dst"/
+(cd md/"$arch" && find . -name \*.h -print0 | \
+ pax -rw -0 "$dst"/include/mirmince/md/)
+(cd osdep/"$os" && find . -name \*.h -print0 | \
+ pax -rw -0 "$dst"/include/mirmince/osdep/)
+for f in obj/mince{beg,end}.o obj/*.a; do
+ [[ -s $f ]] || continue
+ cp "$f" "$dst"/lib/
+done
+print "You can now use ${dst at Q}/bin/cc to compile."
diff --git a/gcc-spec b/gcc-spec
new file mode 100644
index 0000000..011cded
--- /dev/null
+++ b/gcc-spec
@@ -0,0 +1,27 @@
+*link_gcc_c_sequence:
+--start-group %L --end-group
+
+*endfile:
+
+*link:
+%{assert*} %{R*} %{rpath*} -dc -dp %{!nostdlib:%{!r*:%{!e*:-e _mince_csu_init}}} -Bstatic
+
+*lib:
+-lmince -lminse
+
+*libgcc:
+
+*startfile:
+@@DST@@/lib/mincebeg.o
+
+*multilib:
+
+*multilib_matches:
+
+*multilib_options:
+
+*link_libgcc:
+-L@@DST@@/lib
+
+*linker:
+/usr/bin/ld
diff --git a/gcc-wrap b/gcc-wrap
new file mode 100644
index 0000000..f23a72d
--- /dev/null
+++ b/gcc-wrap
@@ -0,0 +1,50 @@
+#!/bin/mksh
+#-
+# Copyright © 2013
+# Thorsten Glaser <tg at mirbsd.org>
+#
+# Provided that these terms and disclaimer and all copyright notices
+# are retained or reproduced in an accompanying document, permission
+# is granted to deal in this work without restriction, including un‐
+# limited rights to use, publicly perform, distribute, sell, modify,
+# merge, give away, or sublicence.
+#
+# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
+# the utmost extent permitted by applicable law, neither express nor
+# implied; without malicious intent or gross negligence. In no event
+# may a licensor, author or contributor be held liable for indirect,
+# direct, other damage, loss, or other issues arising in any way out
+# of dealing in the work, even if advised of the possibility of such
+# damage or existence of a defect, except proven that it results out
+# of said person’s immediate fault when using the work as intended.
+#-
+# GCC wrapper for mirₘᵢₙcⒺ (experimental)
+
+cc=@@CC@@
+dst=@@DST@@
+
+if [[ $cc != /* ]] && ! cc=$(whence -p "$cc"); then
+ print -u2 Error: could not find C compiler
+ exit 255
+fi
+
+if [[ $1 = -v ]]; then
+ v=1
+ shift
+else
+ v=0
+fi
+
+set -A cmd -- "$cc" -nostdinc -I"$dst"/include -D__mirmincE__ \
+ -D__mirmincE_arch_@@MD@@ -D__mirmincE_arch__=\"@@MD@@\" \
+ -D__mirmincE_os_@@OS@@ -D__mirmincE_os__=\"@@OS@@\" \
+ "$@"
+
+if (( v )); then
+ print -nu2 +
+ for x in "${cmd[@]}"; do
+ print -nru2 -- " ${x at Q}"
+ done
+ print -u2
+fi
+exec "${cmd[@]}"
diff --git a/include/mirmince/asm.h b/include/mirmince/asm.h
new file mode 100644
index 0000000..ee5cdf9
--- /dev/null
+++ b/include/mirmince/asm.h
@@ -0,0 +1,53 @@
+#ifndef MIRMINCE_ASM_H
+#define MIRMINCE_ASM_H
+
+#include <mirmince/md/asm.h>
+#include <mirmince/osdep/asm.h>
+
+#ifndef MIRMINCE_ASM_USCORES
+#ifdef __ELF__
+#define MIRMINCE_ASM_USCORES 0
+#else
+#define MIRMINCE_ASM_USCORES 1
+#endif
+#endif
+
+#if MIRMINCE_ASM_USCORES
+#define _C_LABEL(x) _ ## x
+#else
+#define _C_LABEL(x) x
+#endif
+
+#ifndef _FTYPE
+#ifdef __ELF__
+#define _FTYPE(x) .type x, at function
+#define _OTYPE(x) .type x, at object
+#else
+#define _FTYPE(x) /* nothing */
+#define _OTYPE(x) /* nothing */
+#endif
+#endif
+
+#ifndef _TEXT
+#define _TEXT .text
+#define _DATA .data
+#define _BSS .bss
+#ifdef __ELF__
+#define _RODATA .section .rodata
+#define _COMMENT .section .comment
+#else
+#define _RODATA .text
+#define _COMMENT .text
+#endif
+#endif
+
+#ifndef _ALIGN_TEXT
+#define _ALIGN_TEXT /* nothing */
+#endif
+
+#define ASENTRY(x) .globl x; _FTYPE(x); x:
+#define ENTRY(x) _TEXT; _ALIGN_TEXT; ASENTRY(_C_LABEL(x))
+#define TENTRY(x) ASENTRY(_C_LABEL(x))
+#define DENTRY(x) .globl _C_LABEL(x); _OTYPE(_C_LABEL(x)); _C_LABEL(x):
+
+#endif
diff --git a/include/mirmince/c.h b/include/mirmince/c.h
new file mode 100644
index 0000000..1e95211
--- /dev/null
+++ b/include/mirmince/c.h
@@ -0,0 +1,33 @@
+#ifndef MIRMINCE_C_H
+#define MIRMINCE_C_H
+
+#include <mirmince/md/c.h>
+#include <mirmince/osdep/c.h>
+
+#ifdef __cplusplus
+#define __BEGIN_DECLS extern "C" {
+#define __END_DECLS }
+#else
+#define __BEGIN_DECLS
+#define __END_DECLS
+#endif
+
+#ifdef __GNUC__
+#define mirmince_cc_cdecl __attribute__((__cdecl__))
+#define mirmince_cc_regparm(x) __attribute__((__regparm__ (x)))
+#define mirmince_dead __attribute__((__noreturn__))
+#define mirmince_printf(x) __attribute__((__printf__ x))
+#define mirmince_unused __attribute__((__unused__))
+#else
+#define mirmince_cc_cdecl /* default */
+#define mirmince_cc_regparm(x) /* not used */
+#define mirmince_dead
+#define mirmince_printf(x)
+#define mirmince_unused
+#endif
+
+#ifndef mirmince_cc_fast
+#define mirmince_cc_fast mirmince_cc_cdecl
+#endif
+
+#endif
diff --git a/include/stdlib.h b/include/stdlib.h
new file mode 100644
index 0000000..6545706
--- /dev/null
+++ b/include/stdlib.h
@@ -0,0 +1,12 @@
+#ifndef STDLIB_H
+#define STDLIB_H
+
+#ifndef MIRMINCE_C_H
+#include <mirmince/c.h>
+#endif
+
+__BEGIN_DECLS
+void exit(int status);
+__END_DECLS
+
+#endif
diff --git a/md/i386/Makefile.inc b/md/i386/Makefile.inc
new file mode 100644
index 0000000..e69de29
diff --git a/md/i386/asm.h b/md/i386/asm.h
new file mode 100644
index 0000000..9c0ecdb
--- /dev/null
+++ b/md/i386/asm.h
@@ -0,0 +1,7 @@
+#ifdef _ASM_SOURCE
+ .intel_syntax noprefix
+#endif
+
+#ifndef SMALL
+#define _ALIGN_TEXT .p2align 2,0x90
+#endif
diff --git a/md/i386/c.h b/md/i386/c.h
new file mode 100644
index 0000000..e69de29
diff --git a/md/i386/mincebeg_md.S b/md/i386/mincebeg_md.S
new file mode 100644
index 0000000..f24b5a0
--- /dev/null
+++ b/md/i386/mincebeg_md.S
@@ -0,0 +1,45 @@
+/*-
+ * Copyright © 2004, 2005, 2007, 2013
+ * Thorsten Glaser <tg at mirbsd.org>
+ *
+ * Provided that these terms and disclaimer and all copyright notices
+ * are retained or reproduced in an accompanying document, permission
+ * is granted to deal in this work without restriction, including un‐
+ * limited rights to use, publicly perform, distribute, sell, modify,
+ * merge, give away, or sublicence.
+ *
+ * This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
+ * the utmost extent permitted by applicable law, neither express nor
+ * implied; without malicious intent or gross negligence. In no event
+ * may a licensor, author or contributor be held liable for indirect,
+ * direct, other damage, loss, or other issues arising in any way out
+ * of dealing in the work, even if advised of the possibility of such
+ * damage or existence of a defect, except proven that it results out
+ * of said person’s immediate fault when using the work as intended.
+ */
+
+#include <mirmince/asm.h>
+
+ _TEXT
+ _ALIGN_TEXT
+ASENTRY(_mince_csu_init)
+
+#ifdef extra_paranoid
+ /* required by the ABI */
+ cld
+#endif
+
+#if defined(__mirmincE_os_mirbsd)
+ push ebx /* ps_strings (unused) */
+ push ecx /* obj (unused) */
+ push edx /* cleanup (unused) */
+ mov eax,[esp+12]
+ lea ecx,[esp+4*eax+20]
+ lea edx,[esp+16]
+ push ecx /* envp */
+ push edx /* argv */
+ push eax /* argc */
+#else
+#error need OS specific CSU
+#endif
+ call _mince_csu_run
diff --git a/mi/Makefile.inc b/mi/Makefile.inc
new file mode 100644
index 0000000..e69de29
diff --git a/mi/mincebeg_mi.c b/mi/mincebeg_mi.c
new file mode 100644
index 0000000..f7aa174
--- /dev/null
+++ b/mi/mincebeg_mi.c
@@ -0,0 +1,38 @@
+/*-
+ * Copyright © 2013
+ * Thorsten Glaser <tg at mirbsd.org>
+ *
+ * Provided that these terms and disclaimer and all copyright notices
+ * are retained or reproduced in an accompanying document, permission
+ * is granted to deal in this work without restriction, including un‐
+ * limited rights to use, publicly perform, distribute, sell, modify,
+ * merge, give away, or sublicence.
+ *
+ * This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
+ * the utmost extent permitted by applicable law, neither express nor
+ * implied; without malicious intent or gross negligence. In no event
+ * may a licensor, author or contributor be held liable for indirect,
+ * direct, other damage, loss, or other issues arising in any way out
+ * of dealing in the work, even if advised of the possibility of such
+ * damage or existence of a defect, except proven that it results out
+ * of said person’s immediate fault when using the work as intended.
+ */
+
+#include <stdlib.h>
+
+void _mince_csu_run(int argc, char *argv[], char *envp[])
+ /* actually more, machdep, not yet used */
+ mirmince_dead
+ mirmince_cc_cdecl;
+extern int main(int argc, char *argv[], char *envp[]);
+
+char **environ;
+
+void
+_mince_csu_run(int argc, char *argv[], char *envp[])
+{
+ /* we will want __progname later */
+ environ = envp;
+
+ exit(main(argc, argv, envp));
+}
diff --git a/osdep/mirbsd/Makefile.inc b/osdep/mirbsd/Makefile.inc
new file mode 100644
index 0000000..e1d93d4
--- /dev/null
+++ b/osdep/mirbsd/Makefile.inc
@@ -0,0 +1,17 @@
+#XXX this is gcc only right now
+
+CFLAGS+= -Os -fweb -frename-registers
+CFLAGS+= -fno-align-functions -fno-align-labels \
+ -falign-loops=4 -falign-jumps=4
+
+.if ${TG_ARCH} == "i386"
+CFLAGS+= -march=i486 -mpush-args -mpreferred-stack-boundary=2 \
+ -momit-leaf-frame-pointer
+.elif ${TG_ARCH} == "sparc"
+CFLAGS+= -mcpu=v8 -mtune=hypersparc
+.else
+.error Unknown MirBSD architecture "${TG_ARCH}"
+.endif
+
+CFLAGS+= -Wformat -Wstrict-aliasing -Wbounded
+CFLAGS+= -fwrapv -fhonour-copts
diff --git a/osdep/mirbsd/asm.h b/osdep/mirbsd/asm.h
new file mode 100644
index 0000000..154adc7
--- /dev/null
+++ b/osdep/mirbsd/asm.h
@@ -0,0 +1,3 @@
+#ifndef __ELF__
+#error we always use ELF on MirBSD
+#endif
diff --git a/osdep/mirbsd/c.h b/osdep/mirbsd/c.h
new file mode 100644
index 0000000..154adc7
--- /dev/null
+++ b/osdep/mirbsd/c.h
@@ -0,0 +1,3 @@
+#ifndef __ELF__
+#error we always use ELF on MirBSD
+#endif
diff --git a/osdep/mirbsd/mincebeg_os.S b/osdep/mirbsd/mincebeg_os.S
new file mode 100644
index 0000000..0c3d09c
--- /dev/null
+++ b/osdep/mirbsd/mincebeg_os.S
@@ -0,0 +1,35 @@
+/*-
+ * Copyright © 2003, 2004, 2005, 2013
+ * Thorsten Glaser <tg at mirbsd.org>
+ *
+ * Provided that these terms and disclaimer and all copyright notices
+ * are retained or reproduced in an accompanying document, permission
+ * is granted to deal in this work without restriction, including un‐
+ * limited rights to use, publicly perform, distribute, sell, modify,
+ * merge, give away, or sublicence.
+ *
+ * This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
+ * the utmost extent permitted by applicable law, neither express nor
+ * implied; without malicious intent or gross negligence. In no event
+ * may a licensor, author or contributor be held liable for indirect,
+ * direct, other damage, loss, or other issues arising in any way out
+ * of dealing in the work, even if advised of the possibility of such
+ * damage or existence of a defect, except proven that it results out
+ * of said person’s immediate fault when using the work as intended.
+ */
+
+#include <mirmince/asm.h>
+
+#ifndef __ELF__
+#error huh?
+#endif
+
+ .section .note.miros.ident,"a", at progbits
+ .p2align 2
+ .long 2f-1f /* name size */
+ .long 4f-3f /* desc size */
+ .long 1 /* type (OS version note) */
+1: .asciz "MirOS BSD" /* name */
+2: .p2align 2
+3: .long 0 /* desc */
+4: .p2align 2
hooks/post-receive
--
Main git repository for FreeWRT project mirmince
(FreeWRT project mirmince repository mirmince)
More information about the Mirmince-commits
mailing list