mescc: Mes C Library: Cleanup start files.

* lib/linux/x86-mes-gcc/crt0.c: Split from lib/linux/crt0.c.
* lib/linux/x86-mes-gcc/crt1.c: Split from lib/linux/crt1.c.
* lib/linux/x86-mes-gcc/crti.c: Split from lib/linux/crti.c.
* lib/linux/x86-mes-gcc/crtn.c: Split from lib/linux/crtn.c.
* lib/linux/x86-mes/crt0.c: Split from lib/linux/crt0.c.
* lib/linux/x86-mes/crt1.c: Split from lib/linux/crt1.c.
* lib/linux/x86-mes/crti.c: Split from lib/linux/crti.c.
* lib/linux/x86-mes/crtn.c: Split from lib/linux/crtn.c.
* build-aux/build-cc.sh: Update.
* build-aux/build-cc32.sh: Update.
* build-aux/build-mes.sh: Update.
This commit is contained in:
Jan Nieuwenhuizen 2018-08-12 08:45:04 +02:00
parent fe055ba344
commit 9273a64098
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
15 changed files with 263 additions and 89 deletions

View file

@ -47,10 +47,10 @@ trace "MSNARF vector.c" ${srcdest}build-aux/mes-snarf.scm --mes src/vector.c
ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc.sh lib/libmes ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc.sh lib/libmes
sh ${srcdest}build-aux/cc.sh src/mes sh ${srcdest}build-aux/cc.sh src/mes
#ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/linux/x86_64/crt0 ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/linux/x86_64-mes-gcc/crt0
ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/linux/x86_64-mes-gcc/crt1 ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/linux/x86_64-mes-gcc/crt1
# ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/linux/x86_64/crti ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/linux/x86_64-mes-gcc/crti
# ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/linux/x86_64/crtn ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/linux/x86_64-mes-gcc/crtn
ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/libc-mini ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/libc-mini
ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/libc ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/libc
ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/libgetopt ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc64-mes.sh lib/libgetopt

View file

@ -45,10 +45,10 @@ trace "MSNARF posix.c" ${srcdest}build-aux/mes-snarf.scm --mes src/posix.c
trace "MSNARF reader.c" ${srcdest}build-aux/mes-snarf.scm --mes src/reader.c trace "MSNARF reader.c" ${srcdest}build-aux/mes-snarf.scm --mes src/reader.c
trace "MSNARF vector.c" ${srcdest}build-aux/mes-snarf.scm --mes src/vector.c trace "MSNARF vector.c" ${srcdest}build-aux/mes-snarf.scm --mes src/vector.c
ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/linux/crt0 ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/linux/x86-mes-gcc/crt0
ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/linux/crt1 ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/linux/x86-mes-gcc/crt1
ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/linux/crti ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/linux/x86-mes-gcc/crti
ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/linux/crtn ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/linux/x86-mes-gcc/crtn
ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/libc-mini ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/libc-mini
ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/libc ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/libc
ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/libgetopt ARCHDIR=1 NOLINK=1 sh ${srcdest}build-aux/cc32-mes.sh lib/libgetopt

View file

@ -114,7 +114,7 @@ if [ ! -d "$MES_SEED" ] \
fi fi
MES_ARENA=100000000 MES_ARENA=100000000
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/linux/crt0 ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/linux/x86-mes/crt1
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/libc-mini ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/libc-mini
PREPROCESS= bash ${srcdest}build-aux/cc-mes.sh lib/x86-mes/exit-42 PREPROCESS= bash ${srcdest}build-aux/cc-mes.sh lib/x86-mes/exit-42
@ -123,9 +123,9 @@ trace "TEST exit-42.out"
{ set +e; lib/x86-mes/exit-42.mes-out; r=$?; set -e; } { set +e; lib/x86-mes/exit-42.mes-out; r=$?; set -e; }
[ $r != 42 ] && echo " => $r" && exit 1 [ $r != 42 ] && echo " => $r" && exit 1
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/linux/crt1 ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/linux/x86-mes/crt0
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/linux/crti ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/linux/x86-mes/crti
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/linux/crtn ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/linux/x86-mes/crtn
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/libc ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/libc
ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/libgetopt ARCHDIR=1 NOLINK=1 bash ${srcdest}build-aux/cc-mes.sh lib/libgetopt

View file

@ -0,0 +1,60 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
// no clue what crt0.o is and why gcc-2.6.3 needs it
// instead of calling main, it seems to call either _main or ___main,
// let's try _main first
char **environ = 0;
int _main (int argc, char *argv[]);
void
_start ()
{
asm (
"mov %%ebp,%%eax\n\t"
"add $4,%%eax\n\t"
"movzbl (%%eax),%%eax\n\t"
"add $3,%%eax\n\t"
"shl $2,%%eax\n\t"
"add %%ebp,%%eax\n\t"
"mov %%eax,%0\n\t"
: "=r" (environ)
: //no inputs ""
);
asm (
"mov %ebp,%eax\n\t"
"add $8,%eax\n\t"
"push %eax\n\t"
"mov %ebp,%eax\n\t"
"add $4,%eax\n\t"
"movzbl (%eax),%eax\n\t"
"push %eax\n\t"
"call _main\n\t"
"mov %eax,%ebx\n\t"
"mov $1,%eax\n\t"
"int $0x80\n\t"
"hlt \n\t"
);
}

View file

@ -21,40 +21,6 @@
char **environ = 0; char **environ = 0;
int main (int argc, char *argv[]); int main (int argc, char *argv[]);
#if __MESC__
int
_start ()
{
asm ("mov____%ebp,%eax");
asm ("add____$i8,%eax !4");
asm ("movzbl_(%eax),%eax");
asm ("add____$i8,%eax !3");
asm ("shl____$i8,%eax !0x02");
asm ("add____%ebp,%eax");
asm ("mov____%eax,0x32 &environ");
asm ("mov____%ebp,%eax");
asm ("add____$i8,%eax !8");
asm ("push___%eax");
asm ("mov____%ebp,%eax");
asm ("add____$i8,%eax !4");
asm ("movzbl_(%eax),%eax");
asm ("push___%eax");
main ();
asm ("mov____%eax,%ebx");
asm ("mov____$i32,%eax %1");
asm ("int____$0x80");
asm ("hlt");
}
#else // !__MESC__
void void
_start () _start ()
{ {
@ -84,8 +50,6 @@ _start ()
"mov %eax,%ebx\n\t" "mov %eax,%ebx\n\t"
"mov $1,%eax\n\t" "mov $1,%eax\n\t"
"int $0x80\n\t" "int $0x80\n\t"
"hlt \n\t" "hlt \n\t"
); );
} }
#endif // !__MESC__

View file

@ -26,44 +26,6 @@
char **environ = 0; char **environ = 0;
int _main (int argc, char *argv[]); int _main (int argc, char *argv[]);
#if __GNUC__
void
_start ()
{
asm (
"mov %%ebp,%%eax\n\t"
"addl $4,%%eax\n\t"
"movzbl (%%eax),%%eax\n\t"
"addl $3,%%eax\n\t"
"shl $2,%%eax\n\t"
"add %%ebp,%%eax\n\t"
"movl %%eax,%0\n\t"
: "=environ" (environ)
: //no inputs ""
);
asm (
"mov %%ebp,%%eax\n\t"
"addl $8,%%eax\n\t"
"push %%eax\n\t"
"mov %%ebp,%%eax\n\t"
"addl $4,%%eax\n\t"
"movzbl (%%eax),%%eax\n\t"
"push %%eax\n\t"
"call _main\n\t"
"mov %%eax,%%ebx\n\t"
"mov $1,%%eax\n\t"
"int $0x80\n\t"
"hlt \n\t"
:
);
}
#elif __MESC__
int int
_start () _start ()
{ {
@ -93,5 +55,3 @@ _start ()
asm ("int____$0x80"); asm ("int____$0x80");
asm ("hlt"); asm ("hlt");
} }
#endif

52
lib/linux/x86-mes/crt1.c Normal file
View file

@ -0,0 +1,52 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
char **environ = 0;
int main (int argc, char *argv[]);
int
_start ()
{
asm ("mov____%ebp,%eax");
asm ("add____$i8,%eax !4");
asm ("movzbl_(%eax),%eax");
asm ("add____$i8,%eax !3");
asm ("shl____$i8,%eax !0x02");
asm ("add____%ebp,%eax");
asm ("mov____%eax,0x32 &environ");
asm ("mov____%ebp,%eax");
asm ("add____$i8,%eax !8");
asm ("push___%eax");
asm ("mov____%ebp,%eax");
asm ("add____$i8,%eax !4");
asm ("movzbl_(%eax),%eax");
asm ("push___%eax");
main ();
asm ("mov____%eax,%ebx");
asm ("mov____$i32,%eax %1");
asm ("int____$0x80");
asm ("hlt");
}

19
lib/linux/x86-mes/crti.c Normal file
View file

@ -0,0 +1,19 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/

19
lib/linux/x86-mes/crtn.c Normal file
View file

@ -0,0 +1,19 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/

View file

@ -0,0 +1,62 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
// no clue what crt0.o is and why gcc-2.6.3 needs it
// instead of calling main, it seems to call either _main or ___main,
// let's try _main first
char **environ = 0;
int main (int argc, char *argv[]);
// gcc x86_64 calling convention:
// rdi, rsi, rdx, rcx, r8, r9, <stack0>, <stack1>
void
_start ()
{
asm (
"movq %%rbp,%%rax\n\t"
"add $8,%%rax\n\t"
"movq (%%rax),%%rax\n\t"
"add $3,%%rax\n\t"
"shl $3,%%rax\n\t"
"add %%rbp,%%rax\n\t"
"mov %%rax,%0\n\t"
: "=r" (environ)
: //no inputs ""
);
asm (
"mov %rbp,%rax\n\t"
"add $16,%rax\n\t"
"mov %rax,%rsi\n\t"
"mov %rbp,%rax\n\t"
"add $8,%rax\n\t"
"mov (%rax),%rax\n\t"
"mov %rax,%rdi\n\t"
"call _main\n\t"
"mov %rax,%rdi\n\t"
"mov $0x3c,%rax\n\t"
"syscall \n\t"
"hlt \n\t"
);
}

View file

@ -22,7 +22,7 @@ char **environ = 0;
int main (int argc, char *argv[]); int main (int argc, char *argv[]);
// gcc x86_64 calling convention: // gcc x86_64 calling convention:
// edi, esi, edx, ecx, r8d, r9d, <stack0>, <stack1> // rdi, rsi, rdx, rcx, r8, r9, <stack0>, <stack1>
void void
_start () _start ()

View file

@ -0,0 +1,19 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/

View file

@ -0,0 +1,19 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/