mescc: Support less-patched tcc/gcc: Add crti and crtn.

* lib/crt0.c[__MESC__]: Support MesCC.
* lib/crti.c: New file.
* lib/crtn.c: New file.
* build-aux/build-mes-gcc.sh: Build them.
This commit is contained in:
Jan Nieuwenhuizen 2018-06-10 16:03:18 +02:00
parent c2c3554884
commit c086f67cec
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
5 changed files with 79 additions and 0 deletions

View file

@ -64,6 +64,8 @@ C32FLAGS=${C32FLAGS-"
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/crt0
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/crt1
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/crti
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/crtn
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/libc-mini
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/libc
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes-gcc.sh lib/libgetopt

View file

@ -97,7 +97,10 @@ if [ -d "$MES_SEED" ]; then
fi
PREPROCESS=1
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/crt0
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/crt1
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/crti
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/crtn
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libc-mini
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libc
ARCHDIR=1 NOLINK=1 sh build-aux/cc-mes.sh lib/libgetopt

View file

@ -26,6 +26,8 @@
char **environ = 0;
int _main (int argc, char *argv[]);
#if __GNUC__
void
_start ()
{
@ -59,3 +61,37 @@ _start ()
:
);
}
#elif __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");
}
#endif

19
lib/crti.c Normal file
View file

@ -0,0 +1,19 @@
/* -*-comment-start: "//";comment-end:""-*-
* Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of Mes.
*
* 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.
*
* 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 Mes. If not, see <http://www.gnu.org/licenses/>.
*/

19
lib/crtn.c Normal file
View file

@ -0,0 +1,19 @@
/* -*-comment-start: "//";comment-end:""-*-
* Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of Mes.
*
* 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.
*
* 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 Mes. If not, see <http://www.gnu.org/licenses/>.
*/