mirror of
https://github.com/fosslinux/live-bootstrap.git
synced 2026-03-13 06:45:24 +01:00
Add mes and mescc-tools-extra
mescc-tools-extra contains two important tools: - cp - chmod mes first builds itself from a mes 0.21 seed as used by guix, and then builds a mes 0.22 and then mes 0.22 using that created mes 0.22. It does /not/ use bootstrap.sh as we don't have a proper shell at this point, it has been manually adapted for kaem.
This commit is contained in:
parent
2706e07556
commit
649d7b68dc
1029 changed files with 120985 additions and 18 deletions
32
sysa/mes-0.22/lib/linux/_getcwd.c
Normal file
32
sysa/mes-0.22/lib/linux/_getcwd.c
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib-mini.h>
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
char *
|
||||
_getcwd (char *buffer, size_t size)
|
||||
{
|
||||
int r = _sys_call2 (SYS_getcwd, (long) buffer, (long) size);
|
||||
if (r >= 0)
|
||||
return buffer;
|
||||
return 0;
|
||||
}
|
||||
37
sysa/mes-0.22/lib/linux/_open3.c
Normal file
37
sysa/mes-0.22/lib/linux/_open3.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <mes/lib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int
|
||||
_open3 (char const *file_name, int flags, int mask)
|
||||
{
|
||||
int r = _sys_call3 (SYS_open, (long) file_name, (int) flags, (int) mask);
|
||||
__ungetc_init ();
|
||||
if (r > 2)
|
||||
{
|
||||
__ungetc_clear (r);
|
||||
__buffered_read_clear (r);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
30
sysa/mes-0.22/lib/linux/_read.c
Normal file
30
sysa/mes-0.22/lib/linux/_read.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <mes/lib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
ssize_t
|
||||
_read (int filedes, void *buffer, size_t size)
|
||||
{
|
||||
return _sys_call3 (SYS_read, (int) filedes, (long) buffer, (long) size);
|
||||
}
|
||||
28
sysa/mes-0.22/lib/linux/access.c
Normal file
28
sysa/mes-0.22/lib/linux/access.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
int
|
||||
access (char const *file_name, int how)
|
||||
{
|
||||
return _sys_call2 (SYS_access, (long) file_name, (int) how);
|
||||
}
|
||||
28
sysa/mes-0.22/lib/linux/brk.c
Normal file
28
sysa/mes-0.22/lib/linux/brk.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
long
|
||||
brk (void *addr)
|
||||
{
|
||||
return _sys_call1 (SYS_brk, (long) addr);
|
||||
}
|
||||
28
sysa/mes-0.22/lib/linux/chdir.c
Normal file
28
sysa/mes-0.22/lib/linux/chdir.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
int
|
||||
chdir (char const *file_name)
|
||||
{
|
||||
return _sys_call1 (SYS_chdir, (long) file_name);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/chmod.c
Normal file
29
sysa/mes-0.22/lib/linux/chmod.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int
|
||||
chmod (char const *file_name, mode_t mask)
|
||||
{
|
||||
return _sys_call2 (SYS_chmod, (long) file_name, (long) mask);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/clock_gettime.c
Normal file
29
sysa/mes-0.22/lib/linux/clock_gettime.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <time.h>
|
||||
|
||||
int
|
||||
clock_gettime (clockid_t clk_id, struct timespec *tp)
|
||||
{
|
||||
return _sys_call2 (SYS_clock_gettime, (long) clk_id, (long) tp);
|
||||
}
|
||||
31
sysa/mes-0.22/lib/linux/close.c
Normal file
31
sysa/mes-0.22/lib/linux/close.c
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <mes/lib.h>
|
||||
|
||||
int
|
||||
close (int filedes)
|
||||
{
|
||||
__ungetc_clear (filedes);
|
||||
__buffered_read_clear (filedes);
|
||||
return _sys_call1 (SYS_close, (int) filedes);
|
||||
}
|
||||
28
sysa/mes-0.22/lib/linux/dup.c
Normal file
28
sysa/mes-0.22/lib/linux/dup.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
int
|
||||
dup (int old)
|
||||
{
|
||||
return _sys_call1 (SYS_dup, (int) old);
|
||||
}
|
||||
28
sysa/mes-0.22/lib/linux/dup2.c
Normal file
28
sysa/mes-0.22/lib/linux/dup2.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
int
|
||||
dup2 (int old, int new)
|
||||
{
|
||||
return _sys_call2 (SYS_dup2, (int) old, (int) new);
|
||||
}
|
||||
28
sysa/mes-0.22/lib/linux/execve.c
Normal file
28
sysa/mes-0.22/lib/linux/execve.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
int
|
||||
execve (char const *file_name, char *const argv[], char *const env[])
|
||||
{
|
||||
return _sys_call3 (SYS_execve, (long) file_name, (long) argv, (long) env);
|
||||
}
|
||||
34
sysa/mes-0.22/lib/linux/fcntl.c
Normal file
34
sysa/mes-0.22/lib/linux/fcntl.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
fcntl (int filedes, int command, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, command);
|
||||
int data = va_arg (ap, int);
|
||||
int r = _sys_call3 (SYS_fcntl, (int) filedes, (int) command, (int) data);
|
||||
va_end (ap);
|
||||
return r;
|
||||
}
|
||||
28
sysa/mes-0.22/lib/linux/fork.c
Normal file
28
sysa/mes-0.22/lib/linux/fork.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
int
|
||||
fork ()
|
||||
{
|
||||
return _sys_call (SYS_fork);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/fstat.c
Normal file
29
sysa/mes-0.22/lib/linux/fstat.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int
|
||||
fstat (int filedes, struct stat *statbuf)
|
||||
{
|
||||
return _sys_call2 (SYS_fstat, (int) filedes, (long) statbuf);
|
||||
}
|
||||
28
sysa/mes-0.22/lib/linux/fsync.c
Normal file
28
sysa/mes-0.22/lib/linux/fsync.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
int
|
||||
fsync (int filedes)
|
||||
{
|
||||
return _sys_call1 (SYS_fsync, (int) filedes);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/getdents.c
Normal file
29
sysa/mes-0.22/lib/linux/getdents.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
int
|
||||
getdents (int filedes, char *buffer, size_t nbytes)
|
||||
{
|
||||
return _sys_call3 (SYS_getdents, (int) filedes, (long) buffer, (long) nbytes);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/getegid.c
Normal file
29
sysa/mes-0.22/lib/linux/getegid.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
gid_t
|
||||
getegid ()
|
||||
{
|
||||
return _sys_call (SYS_getegid);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/geteuid.c
Normal file
29
sysa/mes-0.22/lib/linux/geteuid.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
uid_t
|
||||
geteuid ()
|
||||
{
|
||||
return _sys_call (SYS_geteuid);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/getgid.c
Normal file
29
sysa/mes-0.22/lib/linux/getgid.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
gid_t
|
||||
getgid ()
|
||||
{
|
||||
return _sys_call (SYS_getgid);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/getpid.c
Normal file
29
sysa/mes-0.22/lib/linux/getpid.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
pid_t
|
||||
getpid ()
|
||||
{
|
||||
return _sys_call (SYS_getpid);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/getppid.c
Normal file
29
sysa/mes-0.22/lib/linux/getppid.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
pid_t
|
||||
getppid ()
|
||||
{
|
||||
return _sys_call (SYS_getppid);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/getrusage.c
Normal file
29
sysa/mes-0.22/lib/linux/getrusage.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
int
|
||||
getrusage (int processes, struct rusage *rusage)
|
||||
{
|
||||
return _sys_call2 (SYS_getrusage, (int) processes, (long) rusage);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/gettimeofday.c
Normal file
29
sysa/mes-0.22/lib/linux/gettimeofday.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
int
|
||||
gettimeofday (struct timeval *tv, struct timezone *tz)
|
||||
{
|
||||
return _sys_call2 (SYS_gettimeofday, (long) tv, (long) tz);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/getuid.c
Normal file
29
sysa/mes-0.22/lib/linux/getuid.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
uid_t
|
||||
getuid ()
|
||||
{
|
||||
return _sys_call (SYS_getuid);
|
||||
}
|
||||
42
sysa/mes-0.22/lib/linux/ioctl.c
Normal file
42
sysa/mes-0.22/lib/linux/ioctl.c
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
int
|
||||
ioctl (int filedes, unsigned long command, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, command);
|
||||
int data = va_arg (ap, int);
|
||||
int r = _sys_call3 (SYS_ioctl, (int) filedes, (long) command, (int) data);
|
||||
va_end (ap);
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
ioctl3 (int filedes, unsigned long command, long data)
|
||||
{
|
||||
int r = _sys_call3 (SYS_ioctl, filedes, command, data);
|
||||
return r;
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/kill.c
Normal file
29
sysa/mes-0.22/lib/linux/kill.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
kill (pid_t pid, int signum)
|
||||
{
|
||||
return _sys_call2 (SYS_kill, (long) pid, (long) signum);
|
||||
}
|
||||
28
sysa/mes-0.22/lib/linux/link.c
Normal file
28
sysa/mes-0.22/lib/linux/link.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
int
|
||||
link (char const *old_name, char const *new_name)
|
||||
{
|
||||
return _sys_call2 (SYS_link, (long) old_name, (long) new_name);
|
||||
}
|
||||
46
sysa/mes-0.22/lib/linux/lseek.c
Normal file
46
sysa/mes-0.22/lib/linux/lseek.c
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if !__MESC__ /* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same. */
|
||||
off_t
|
||||
_lseek (int filedes, off_t offset, int whence)
|
||||
{
|
||||
return _sys_call3 (SYS_lseek, (int) filedes, (long) offset, (int) whence);
|
||||
}
|
||||
#endif
|
||||
|
||||
off_t
|
||||
lseek (int filedes, off_t offset, int whence)
|
||||
{
|
||||
#if !__MESC__ /* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same. */
|
||||
if (_lseek (filedes, 0, SEEK_CUR) == -1)
|
||||
return -1;
|
||||
#endif
|
||||
size_t skip = __buffered_read_clear (filedes);
|
||||
if (whence == SEEK_CUR)
|
||||
offset -= skip;
|
||||
return _sys_call3 (SYS_lseek, (int) filedes, (long) offset, (int) whence);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/lstat.c
Normal file
29
sysa/mes-0.22/lib/linux/lstat.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int
|
||||
lstat (char const *file_name, struct stat *statbuf)
|
||||
{
|
||||
return _sys_call2 (SYS_lstat, (long) file_name, (long) statbuf);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/mkdir.c
Normal file
29
sysa/mes-0.22/lib/linux/mkdir.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int
|
||||
mkdir (char const *file_name, mode_t mode)
|
||||
{
|
||||
return _sys_call2 (SYS_mkdir, (long) file_name, (long) mode);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/mknod.c
Normal file
29
sysa/mes-0.22/lib/linux/mknod.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int
|
||||
mknod (char const *file_name, mode_t mode, dev_t dev)
|
||||
{
|
||||
return _sys_call3 (SYS_mknod, (long) file_name, (long) mode, (long) dev);
|
||||
}
|
||||
30
sysa/mes-0.22/lib/linux/nanosleep.c
Normal file
30
sysa/mes-0.22/lib/linux/nanosleep.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
int
|
||||
nanosleep (struct timespec const *requested_time, struct timespec const *remaining)
|
||||
{
|
||||
return _sys_call2 (SYS_nanosleep, (long) requested_time, (long) remaining);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/pipe.c
Normal file
29
sysa/mes-0.22/lib/linux/pipe.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
pipe (int filedes[2])
|
||||
{
|
||||
return _sys_call1 (SYS_pipe, (long) filedes);
|
||||
}
|
||||
50
sysa/mes-0.22/lib/linux/read.c
Normal file
50
sysa/mes-0.22/lib/linux/read.c
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <mes/lib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
ssize_t
|
||||
read (int filedes, void *buffer, size_t size)
|
||||
{
|
||||
ssize_t bytes = _sys_call3 (SYS_read, (int) filedes, (long) buffer, (long) size);
|
||||
if (__mes_debug () > 4)
|
||||
{
|
||||
if (bytes == 1)
|
||||
{
|
||||
eputs ("read fd=");
|
||||
eputs (itoa ((int) filedes));
|
||||
eputs (" c=");
|
||||
eputc (*(char *) buffer);
|
||||
eputs ("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
eputs ("read fd=");
|
||||
eputs (itoa ((int) filedes));
|
||||
eputs (" bytes=");
|
||||
eputs (itoa (bytes));
|
||||
eputs ("\n");
|
||||
}
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/readlink.c
Normal file
29
sysa/mes-0.22/lib/linux/readlink.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
ssize_t
|
||||
readlink (char const *file_name, char *buffer, size_t size)
|
||||
{
|
||||
return _sys_call3 (SYS_readlink, (long) file_name, (long) buffer, (long) size);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/rename.c
Normal file
29
sysa/mes-0.22/lib/linux/rename.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
rename (char const *old_name, char const *new_name)
|
||||
{
|
||||
return _sys_call2 (SYS_rename, (long) old_name, (long) new_name);
|
||||
}
|
||||
28
sysa/mes-0.22/lib/linux/rmdir.c
Normal file
28
sysa/mes-0.22/lib/linux/rmdir.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
int
|
||||
rmdir (char const *file_name)
|
||||
{
|
||||
return _sys_call1 (SYS_rmdir, (long) file_name);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/setgid.c
Normal file
29
sysa/mes-0.22/lib/linux/setgid.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
setgid (gid_t newgid)
|
||||
{
|
||||
return _sys_call1 (SYS_setgid, (long) newgid);
|
||||
}
|
||||
30
sysa/mes-0.22/lib/linux/settimer.c
Normal file
30
sysa/mes-0.22/lib/linux/settimer.c
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
setitimer (int which, struct itimerval const *new, struct itimerval *old)
|
||||
{
|
||||
return _sys_call3 (SYS_setitimer, (long) which, (long) new, (long) old);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/setuid.c
Normal file
29
sysa/mes-0.22/lib/linux/setuid.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
setuid (uid_t newuid)
|
||||
{
|
||||
return _sys_call1 (SYS_setuid, (long) newuid);
|
||||
}
|
||||
72
sysa/mes-0.22/lib/linux/signal.c
Normal file
72
sysa/mes-0.22/lib/linux/signal.c
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
||||
#if __i386__
|
||||
#else
|
||||
void
|
||||
_restorer_for_siginfo (void)
|
||||
{
|
||||
_sys_call (SYS_rt_sigreturn);
|
||||
}
|
||||
#endif
|
||||
|
||||
sighandler_t
|
||||
signal (int signum, sighandler_t action)
|
||||
{
|
||||
#if __i386__
|
||||
return _sys_call2 (SYS_signal, signum, action);
|
||||
#else
|
||||
static struct sigaction setup_action = { 0 };
|
||||
static struct sigaction old = { 0 };
|
||||
unsigned short bitindex;
|
||||
unsigned short itembitcount;
|
||||
|
||||
setup_action.sa_handler = action;
|
||||
/* The sa_restorer is not used. Reason:
|
||||
* The kernel uses its own restorer anyway by pretending we gave one on
|
||||
our side (no, really).
|
||||
glibc still has a custom restorer because they want to be able to
|
||||
backtrace. gdb has a second part that detects a specific instruction
|
||||
sequence and then fixes up the backtrace. Since we don't use that
|
||||
specific instruction sequence and also the non-siginfo restorer
|
||||
is complicated (pops foreign item off the stack--so needs inline
|
||||
assembly) and we don't support great debuggability in other places,
|
||||
I've decided to take the easy way out for now. */
|
||||
/*setup_action.sa_restorer = _restorer_for_siginfo;*/
|
||||
bitindex = signum - 1;
|
||||
itembitcount = 8 * sizeof(setup_action.sa_mask.items[0]);
|
||||
setup_action.sa_mask.items[bitindex / itembitcount] = 1UL << (bitindex % itembitcount);
|
||||
old.sa_handler = SIG_DFL;
|
||||
setup_action.sa_flags = SA_RESTART;
|
||||
#if __x86_64__
|
||||
/* Tell kernel that we use a restorer, on penalty of segfault. */
|
||||
setup_action.sa_flags |= SA_RESTORER;
|
||||
#endif
|
||||
int r = _sys_call4 (SYS_rt_sigaction, signum, (long)&setup_action, (long)&old, sizeof (sigset_t));
|
||||
if (r)
|
||||
return 0;
|
||||
return old.sa_handler;
|
||||
#endif
|
||||
}
|
||||
34
sysa/mes-0.22/lib/linux/sigprogmask.c
Normal file
34
sysa/mes-0.22/lib/linux/sigprogmask.c
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
sigprocmask (int how, sigset_t const *set, sigset_t * oldset)
|
||||
{
|
||||
#if __i386__
|
||||
return _sys_call3 (SYS_sigprocmask, (long) how, (long) set, (long) oldset);
|
||||
#else
|
||||
return _sys_call3 (SYS_rt_sigprocmask, (long) how, (long) set, (long) oldset);
|
||||
#endif
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/stat.c
Normal file
29
sysa/mes-0.22/lib/linux/stat.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
int
|
||||
stat (char const *file_name, struct stat *statbuf)
|
||||
{
|
||||
return _sys_call2 (SYS_stat, (long) file_name, (long) statbuf);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/symlink.c
Normal file
29
sysa/mes-0.22/lib/linux/symlink.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
symlink (char const *old_name, char const *new_name)
|
||||
{
|
||||
return _sys_call2 (SYS_symlink, (long) old_name, (long) new_name);
|
||||
}
|
||||
29
sysa/mes-0.22/lib/linux/time.c
Normal file
29
sysa/mes-0.22/lib/linux/time.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <time.h>
|
||||
|
||||
time_t
|
||||
time (time_t * result)
|
||||
{
|
||||
return _sys_call1 (SYS_time, (long) result);
|
||||
}
|
||||
28
sysa/mes-0.22/lib/linux/unlink.c
Normal file
28
sysa/mes-0.22/lib/linux/unlink.c
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
int
|
||||
unlink (char const *file_name)
|
||||
{
|
||||
return _sys_call1 (SYS_unlink, (long) file_name);
|
||||
}
|
||||
35
sysa/mes-0.22/lib/linux/waitpid.c
Normal file
35
sysa/mes-0.22/lib/linux/waitpid.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
pid_t
|
||||
waitpid (pid_t pid, int *status_ptr, int options)
|
||||
{
|
||||
#if __i386__
|
||||
return _sys_call3 (SYS_waitpid, (long) pid, (long) status_ptr, (int) options);
|
||||
#elif __x86_64__
|
||||
return _sys_call4 (SYS_wait4, (long) pid, (long) status_ptr, (int) options, 0);
|
||||
#else
|
||||
#error arch not supported
|
||||
#endif
|
||||
}
|
||||
61
sysa/mes-0.22/lib/linux/x86-mes-gcc/crt0.c
Normal file
61
sysa/mes-0.22/lib/linux/x86-mes-gcc/crt0.c
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* -*-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
|
||||
|
||||
#include <mes/lib-mini.h>
|
||||
int _main (int argc, char *argv[]);
|
||||
|
||||
// *INDENT-OFF*
|
||||
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"
|
||||
);
|
||||
}
|
||||
77
sysa/mes-0.22/lib/linux/x86-mes-gcc/crt1.c
Normal file
77
sysa/mes-0.22/lib/linux/x86-mes-gcc/crt1.c
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib-mini.h>
|
||||
//int main (int argc, char *argv[], char *envp[]);
|
||||
|
||||
// *INDENT-OFF*
|
||||
void
|
||||
_start ()
|
||||
{
|
||||
asm (
|
||||
"mov $0,%%eax\n\t"
|
||||
"mov %%eax,%0\n"
|
||||
: "=r" (__stdin)
|
||||
: //no inputs ""
|
||||
);
|
||||
|
||||
asm (
|
||||
"mov $1,%%eax\n\t"
|
||||
"mov %%eax,%0\n"
|
||||
: "=r" (__stdout)
|
||||
: //no inputs ""
|
||||
);
|
||||
|
||||
asm (
|
||||
"mov $2,%%eax\n\t"
|
||||
"mov %%eax,%0\n"
|
||||
: "=r" (__stderr)
|
||||
: //no inputs ""
|
||||
);
|
||||
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"
|
||||
"push %%eax\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"
|
||||
);
|
||||
}
|
||||
19
sysa/mes-0.22/lib/linux/x86-mes-gcc/crti.c
Normal file
19
sysa/mes-0.22/lib/linux/x86-mes-gcc/crti.c
Normal 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
sysa/mes-0.22/lib/linux/x86-mes-gcc/crtn.c
Normal file
19
sysa/mes-0.22/lib/linux/x86-mes-gcc/crtn.c
Normal 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/>.
|
||||
*/
|
||||
46
sysa/mes-0.22/lib/linux/x86-mes-gcc/exit-42.S
Normal file
46
sysa/mes-0.22/lib/linux/x86-mes-gcc/exit-42.S
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019 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/>.
|
||||
*/
|
||||
|
||||
/** Commentary: */
|
||||
|
||||
/* Using gdb, esp. GUD in GNU Emacs is recommended
|
||||
M-x gdb-display-disassembly-buffer
|
||||
M-x gdb-display-io-buffer
|
||||
set disassemble-next-line on
|
||||
break _start
|
||||
run
|
||||
info registers
|
||||
si
|
||||
p/x $eax
|
||||
RET
|
||||
...
|
||||
*/
|
||||
|
||||
/** Code: */
|
||||
|
||||
SYS_exit = 1 /* Linux syscall: exit. */
|
||||
.globl _start /* Magic linker symbol: --entry-address. */
|
||||
|
||||
.text /* Program text. */
|
||||
_start:
|
||||
mov $SYS_exit,%eax /* System call function: exit, in %eax. */
|
||||
mov $42,%ebx /* First parameter: exit status, in %ebx. */
|
||||
int $0x80 /* Call system. */
|
||||
hlt /* Should not be reached. */
|
||||
58
sysa/mes-0.22/lib/linux/x86-mes-gcc/hello-mes.S
Normal file
58
sysa/mes-0.22/lib/linux/x86-mes-gcc/hello-mes.S
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019 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/>.
|
||||
*/
|
||||
|
||||
/** Commentary: */
|
||||
|
||||
/* Using gdb, esp. GUD in GNU Emacs is recommended
|
||||
M-x gdb-display-disassembly-buffer
|
||||
M-x gdb-display-io-buffer
|
||||
set disassemble-next-line on
|
||||
break _start
|
||||
run
|
||||
info registers
|
||||
si
|
||||
p/x $eax
|
||||
RET
|
||||
...
|
||||
*/
|
||||
|
||||
/** Code: */
|
||||
|
||||
SYS_exit = 1 /* Linux syscalls. */
|
||||
SYS_write = 4
|
||||
stdout = 1 /* File discriptor */
|
||||
.globl _start /* Magic linker symbol: --entry-address. */
|
||||
|
||||
.text /* Program text. */
|
||||
_start:
|
||||
mov $SYS_write,%eax /* System call function: write, in %eax. */
|
||||
mov $stdout,%ebx /* 1st parameter: file descriptor, in %ebx. */
|
||||
mov $hello,%ecx /* 2nd parameter: address, in %ecx. */
|
||||
mov $(bye-hello),%edx /* 3rd parameter: byte count %edx. */
|
||||
int $0x80 /* Call system. */
|
||||
|
||||
mov $SYS_exit,%eax /* System call function: exit, in %eax. */
|
||||
mov $0,%ebx /* 1st parameter: exit status, in %ebx. */
|
||||
int $0x80 /* Call system. */
|
||||
hlt /* Should not be reached. */
|
||||
|
||||
.data
|
||||
hello: .ascii "Hello, GNU Mes!\n"
|
||||
bye: .byte 0
|
||||
58
sysa/mes-0.22/lib/linux/x86-mes-gcc/mini.c
Normal file
58
sysa/mes-0.22/lib/linux/x86-mes-gcc/mini.c
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2019 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/>.
|
||||
*/
|
||||
|
||||
#include "mes/lib-mini.h"
|
||||
|
||||
#define SYS_exit "0x01"
|
||||
#define SYS_write "0x04"
|
||||
|
||||
// *INDENT-OFF*
|
||||
void
|
||||
_exit (int code)
|
||||
{
|
||||
asm (
|
||||
"mov $"SYS_exit",%%eax\n\t"
|
||||
"mov %0,%%ebx\n\t"
|
||||
"int $0x80\n\t"
|
||||
: // no outputs "=" (r)
|
||||
: "rm" (code)
|
||||
: "eax", "ebx"
|
||||
);
|
||||
// not reached
|
||||
_exit (0);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
_write (int filedes, void const *buffer, size_t size)
|
||||
{
|
||||
long r;
|
||||
asm (
|
||||
"mov $"SYS_write",%%eax\n\t"
|
||||
"mov %1,%%ebx\n\t"
|
||||
"mov %2,%%ecx\n\t"
|
||||
"mov %3,%%edx\n\t"
|
||||
"int $0x80\n\t"
|
||||
"mov %%eax,%0\n\t"
|
||||
: "=r" (r)
|
||||
: "rm" (filedes), "rm" (buffer), "rm" (size)
|
||||
: "eax", "ebx", "ecx", "edx"
|
||||
);
|
||||
return r;
|
||||
}
|
||||
143
sysa/mes-0.22/lib/linux/x86-mes-gcc/syscall.c
Normal file
143
sysa/mes-0.22/lib/linux/x86-mes-gcc/syscall.c
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,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/>.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <linux/x86/syscall.h>
|
||||
|
||||
// *INDENT-OFF*
|
||||
long
|
||||
_sys_call (long sys_call)
|
||||
{
|
||||
long r;
|
||||
asm (
|
||||
"mov %1,%%eax\n\t"
|
||||
"int $0x80\n\t"
|
||||
"mov %%eax,%0\n\t"
|
||||
: "=r" (r)
|
||||
: "rm" (sys_call)
|
||||
: "eax"
|
||||
);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call1 (long sys_call, long one)
|
||||
{
|
||||
long r;
|
||||
asm (
|
||||
"mov %1,%%eax\n\t"
|
||||
"mov %2,%%ebx\n\t"
|
||||
"int $0x80\n\t"
|
||||
"mov %%eax,%0\n\t"
|
||||
: "=r" (r)
|
||||
: "rm" (sys_call), "rm" (one)
|
||||
: "eax", "ebx"
|
||||
);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call2 (long sys_call, long one, long two)
|
||||
{
|
||||
long r;
|
||||
asm (
|
||||
"mov %1,%%eax\n\t"
|
||||
"mov %2,%%ebx\n\t"
|
||||
"mov %3,%%ecx\n\t"
|
||||
"int $0x80\n\t"
|
||||
"mov %%eax,%0\n\t"
|
||||
: "=r" (r)
|
||||
: "rm" (sys_call), "rm" (one), "rm" (two)
|
||||
: "eax", "ebx", "ecx"
|
||||
);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call3 (long sys_call, long one, long two, long three)
|
||||
{
|
||||
long r;
|
||||
asm (
|
||||
"mov %2,%%ebx\n\t"
|
||||
"mov %3,%%ecx\n\t"
|
||||
"mov %4,%%edx\n\t"
|
||||
"mov %1,%%eax\n\t"
|
||||
"int $0x80\n\t"
|
||||
"mov %%eax,%0\n\t"
|
||||
: "=r" (r)
|
||||
: "rm" (sys_call), "rm" (one), "rm" (two), "rm" (three)
|
||||
: "eax", "ebx", "ecx", "edx"
|
||||
);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call4 (long sys_call, long one, long two, long three, long four)
|
||||
{
|
||||
long r;
|
||||
asm (
|
||||
"mov %2,%%ebx\n\t"
|
||||
"mov %3,%%ecx\n\t"
|
||||
"mov %4,%%edx\n\t"
|
||||
"mov %5,%%esi\n\t"
|
||||
"mov %1,%%eax\n\t"
|
||||
"int $0x80\n\t"
|
||||
"mov %%eax,%0\n\t"
|
||||
: "=r" (r)
|
||||
: "rm" (sys_call), "rm" (one), "rm" (two), "rm" (three), "rm" (four)
|
||||
: "eax", "ebx", "ecx", "edx", "esi"
|
||||
);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
63
sysa/mes-0.22/lib/linux/x86-mes-mescc/crt1.c
Normal file
63
sysa/mes-0.22/lib/linux/x86-mes-mescc/crt1.c
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/* -*-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/>.
|
||||
*/
|
||||
|
||||
#include "mes/lib-mini.h"
|
||||
|
||||
int main (int argc, char *argv[], char *envp[]);
|
||||
|
||||
int
|
||||
_start ()
|
||||
{
|
||||
asm ("mov____$i8,%eax !0");
|
||||
asm ("mov____%eax,0x32 &__stdin");
|
||||
|
||||
asm ("mov____$i8,%eax !1");
|
||||
asm ("mov____%eax,0x32 &__stdout");
|
||||
|
||||
asm ("mov____$i8,%eax !2");
|
||||
asm ("mov____%eax,0x32 &__stderr");
|
||||
|
||||
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 ("push___%eax");
|
||||
|
||||
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");
|
||||
}
|
||||
28
sysa/mes-0.22/lib/linux/x86-mes-mescc/exit-42.S
Normal file
28
sysa/mes-0.22/lib/linux/x86-mes-mescc/exit-42.S
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright © 2019 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/>.
|
||||
|
||||
DEFINE sys_exit 01
|
||||
|
||||
:main
|
||||
mov____$i8,%eax !42
|
||||
mov____%eax,%ebx
|
||||
mov____$i8,%eax sys_exit
|
||||
int____$0x80
|
||||
|
||||
:ELF_data
|
||||
:HEX2_data
|
||||
40
sysa/mes-0.22/lib/linux/x86-mes-mescc/hello-mes.S
Normal file
40
sysa/mes-0.22/lib/linux/x86-mes-mescc/hello-mes.S
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright © 2019 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/>.
|
||||
|
||||
DEFINE sys_exit 01
|
||||
DEFINE sys_write 04
|
||||
|
||||
:main
|
||||
mov____$i8,%eax !end_hello_message>hello_message
|
||||
mov____%eax,%ecx
|
||||
mov____$i8,%eax !0
|
||||
mov____%eax,%ebx
|
||||
mov____$i8,%eax sys_write
|
||||
int____$0x80
|
||||
|
||||
mov____$i8,%eax !0
|
||||
mov____%eax,%ebx
|
||||
mov____$i8,%eax sys_exit
|
||||
int____$0x80
|
||||
|
||||
:ELF_data
|
||||
:hello_message
|
||||
"Hello, GNU Mes!
|
||||
"
|
||||
:end_hello_message
|
||||
:HEX2_data
|
||||
37
sysa/mes-0.22/lib/linux/x86-mes-mescc/mini.c
Normal file
37
sysa/mes-0.22/lib/linux/x86-mes-mescc/mini.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017 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/>.
|
||||
*/
|
||||
|
||||
void
|
||||
_exit ()
|
||||
{
|
||||
asm ("mov____$i32,%eax SYS_exit");
|
||||
asm ("mov____0x8(%ebp),%ebx !8");
|
||||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
void
|
||||
_write ()
|
||||
{
|
||||
asm ("mov____$i32,%eax SYS_write");
|
||||
asm ("mov____0x8(%ebp),%ebx !8");
|
||||
asm ("mov____0x8(%ebp),%ecx !12");
|
||||
asm ("mov____0x8(%ebp),%edx !16");
|
||||
asm ("int____$0x80");
|
||||
}
|
||||
137
sysa/mes-0.22/lib/linux/x86-mes-mescc/syscall.c
Normal file
137
sysa/mes-0.22/lib/linux/x86-mes-mescc/syscall.c
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,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/>.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <linux/x86/syscall.h>
|
||||
|
||||
int
|
||||
__sys_call (int sys_call)
|
||||
{
|
||||
asm ("mov____0x8(%ebp),%eax !8");
|
||||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
int
|
||||
__sys_call1 (int sys_call, int one)
|
||||
{
|
||||
asm ("mov____0x8(%ebp),%eax !8");
|
||||
asm ("mov____0x8(%ebp),%ebx !12");
|
||||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
int
|
||||
__sys_call2 (int sys_call, int one, int two)
|
||||
{
|
||||
asm ("mov____0x8(%ebp),%eax !8");
|
||||
asm ("mov____0x8(%ebp),%ebx !12");
|
||||
asm ("mov____0x8(%ebp),%ecx !16");
|
||||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
int
|
||||
__sys_call3 (int sys_call, int one, int two, int three)
|
||||
{
|
||||
asm ("mov____0x8(%ebp),%eax !8");
|
||||
asm ("mov____0x8(%ebp),%ebx !12");
|
||||
asm ("mov____0x8(%ebp),%ecx !16");
|
||||
asm ("mov____0x8(%ebp),%edx !20");
|
||||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
int
|
||||
__sys_call4 (int sys_call, int one, int two, int three, int four)
|
||||
{
|
||||
asm ("mov____0x8(%ebp),%eax !8");
|
||||
asm ("mov____0x8(%ebp),%ebx !12");
|
||||
asm ("mov____0x8(%ebp),%ecx !16");
|
||||
asm ("mov____0x8(%ebp),%edx !20");
|
||||
asm ("mov____0x8(%ebp),%esi !24");
|
||||
asm ("int____$0x80");
|
||||
}
|
||||
|
||||
int
|
||||
_sys_call (int sys_call)
|
||||
{
|
||||
int r = __sys_call (sys_call);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
_sys_call1 (int sys_call, int one)
|
||||
{
|
||||
int r = __sys_call1 (sys_call, one);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
_sys_call2 (int sys_call, int one, int two)
|
||||
{
|
||||
int r = __sys_call2 (sys_call, one, two);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
_sys_call3 (int sys_call, int one, int two, int three)
|
||||
{
|
||||
int r = __sys_call3 (sys_call, one, two, three);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
_sys_call4 (int sys_call, int one, int two, int three, int four)
|
||||
{
|
||||
int r = __sys_call4 (sys_call, one, two, three, four);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
34
sysa/mes-0.22/lib/linux/x86-mes/elf32-0exit-42.hex2
Normal file
34
sysa/mes-0.22/lib/linux/x86-mes/elf32-0exit-42.hex2
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright © 2017,2019 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/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
# elf32-exit-42.hex2: `exit 42' for i686-linux written in hex2 assembly,
|
||||
# for usage with elf32-0header.hex2. This produces a 112-byte binary
|
||||
# (70 hex). Inspiration was taken from GNU Gcc output of exit-42.S.
|
||||
|
||||
### Code:
|
||||
|
||||
# @60
|
||||
:ELF_text
|
||||
b8 01 00 00 00 # mov $1, %eax
|
||||
bb 2a 00 00 00 # mov $42, %ebx
|
||||
cd 80 # int $0x80
|
||||
f4 # hlt
|
||||
00 00 00 # align to @70
|
||||
:ELF_end
|
||||
85
sysa/mes-0.22/lib/linux/x86-mes/elf32-0header.hex2
Normal file
85
sysa/mes-0.22/lib/linux/x86-mes/elf32-0header.hex2
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
### Copyright (C) 2016 Jeremiah Orians
|
||||
### Copyright (C) 2017,2019 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/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
# elf32-0header.hex2: Simplest 32 bit elf header in hex2. Only a text
|
||||
# segment, no data segment, no symbol tables.
|
||||
|
||||
# stage0's hex2 format for x86
|
||||
# !<label> 1 byte relative
|
||||
# $<label> 2 byte address
|
||||
# @<label> 2 byte relative
|
||||
# &<label> 4 byte address
|
||||
# %<label> 4 byte relative
|
||||
# local_<label> function-local
|
||||
# string_<index> string #<index>
|
||||
|
||||
### Code:
|
||||
|
||||
:ELF_base
|
||||
7F 45 4C 46 # e_ident[EI_MAG0-3] ELF's magic number
|
||||
|
||||
01 # e_ident[EI_CLASS] Indicating 32 bit
|
||||
01 # e_ident[EI_DATA] Indicating little endianness
|
||||
01 # e_ident[EI_VERSION] Indicating original elf
|
||||
|
||||
00 # e_ident[EI_OSABI] Set at 0 because none cares
|
||||
00 # e_ident[EI_ABIVERSION] See above
|
||||
|
||||
00 00 00 00 00 00 00 # e_ident[EI_PAD]
|
||||
|
||||
02 00 # e_type Indicating Executable
|
||||
03 00 # e_machine Indicating 32bit x86
|
||||
01 00 00 00 # e_version Indicating original elf
|
||||
|
||||
&ELF_text # e_entry Address of the entry point
|
||||
%ELF_program_headers>ELF_base # e_phoff Address of program header table
|
||||
00 00 00 00 # e_shoff Address of section header table
|
||||
|
||||
00 00 00 00 # e_flags
|
||||
|
||||
34 00 # e_ehsize Indicating our 52 Byte header
|
||||
|
||||
20 00 # e_phentsize size of a program header table
|
||||
01 00 # e_phnum number of entries in program table
|
||||
|
||||
00 00 # e_shentsize size of a section header table
|
||||
00 00 # e_shnum number of entries in section table
|
||||
|
||||
00 00 # e_shstrndx index of the section names
|
||||
|
||||
# @34
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @40
|
||||
:ELF_program_headers
|
||||
:ELF_program_header__text
|
||||
01 00 00 00 # ph_type: PT-LOAD = 1
|
||||
00 00 00 00 # ph_offset
|
||||
&ELF_base # ph_vaddr
|
||||
&ELF_base # ph_physaddr
|
||||
%ELF_end>ELF_base # ph_filesz
|
||||
%ELF_end>ELF_base # ph_memsz
|
||||
07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
|
||||
01 00 00 00 # ph_align
|
||||
|
||||
# @60
|
||||
:ELF_text
|
||||
53
sysa/mes-0.22/lib/linux/x86-mes/elf32-0hello-mes.hex2
Normal file
53
sysa/mes-0.22/lib/linux/x86-mes/elf32-0hello-mes.hex2
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright © 2017,2019 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/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
# elf32-0hello-mes.hex2: `Hello, GNU Mes!' for i686-linux written in
|
||||
# hex2 assembly, for usage with elf32-0header.hex2. This produces a
|
||||
# 160-byte binary (a0 hex). Inspiration was taken from GNU Gcc output
|
||||
# of hello-mes.S.
|
||||
|
||||
### Code:
|
||||
|
||||
# @60
|
||||
:ELF_text
|
||||
|
||||
# print <hello>
|
||||
b8 04 00 00 00 # mov $4,%eax
|
||||
bb 00 00 00 00 # mov $1,%ebx
|
||||
b9 &hello # mov $hello,%ecx
|
||||
ba %bye>hello # mov $(bye-hello),%edx
|
||||
cd 80 # int $0x80
|
||||
|
||||
# exit 0
|
||||
b8 01 00 00 00 # mov $1,%eax
|
||||
bb 00 00 00 00 # mov $0,%ebx
|
||||
cd 80 # int $0x80
|
||||
f4 # hlt
|
||||
|
||||
00 00 00 00 00 00 00 00 00 00 # align to @90
|
||||
00 00 00
|
||||
|
||||
# @90
|
||||
:ELF_data
|
||||
:hello
|
||||
48 65 6c 6c 6f 2c 20 47 # Hello, G
|
||||
4e 55 20 4d 65 73 21 0a # NU Mes!\n
|
||||
:bye
|
||||
:ELF_end
|
||||
50
sysa/mes-0.22/lib/linux/x86-mes/elf32-body-exit-42.hex2
Normal file
50
sysa/mes-0.22/lib/linux/x86-mes/elf32-body-exit-42.hex2
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright © 2017,2019 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/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
# elf32-body-exit-42.hex2: `exit 42' for i686-linux written in hex2
|
||||
# assembly, for usage with generic elf32-header.hex2 and
|
||||
# elf32-footer-single-main.hex.
|
||||
|
||||
# This ELF binary contains a symbol table, which means that objdump and
|
||||
# gdb can be used to inspect and debug.
|
||||
|
||||
### Code:
|
||||
|
||||
# @200
|
||||
:ELF_text
|
||||
:_start
|
||||
e8 %main # call +11 <main>
|
||||
00 00 00
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @210
|
||||
:main
|
||||
bb 2a 00 00 00 # mov $42,%ebx
|
||||
b8 01 00 00 00 # mov $0x1,%eax
|
||||
cd 80 # int $0x80
|
||||
f4 # hlt
|
||||
|
||||
00 00 00 # align
|
||||
|
||||
# @220
|
||||
:ELF_data
|
||||
65 78 69 74 34 32 20 64 61 74 61 20 68 65 72 65 # exit42 data here"
|
||||
00
|
||||
63
sysa/mes-0.22/lib/linux/x86-mes/elf32-body-hello-mes.hex2
Normal file
63
sysa/mes-0.22/lib/linux/x86-mes/elf32-body-hello-mes.hex2
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright © 2017,2019 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/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
# elf32-body-hello-mes.hex2: `Hello, GNU Mes!' for i686-linux written in
|
||||
# hex2 assembly, for usage with generic elf32-header.hex2 and
|
||||
# elf32-footer-single-main.hex.
|
||||
|
||||
# This ELF binary contains a symbol table which means that objdump and
|
||||
# gdb can be used to inspect and debug.
|
||||
|
||||
### Code:
|
||||
|
||||
# @200
|
||||
:ELF_text
|
||||
:_start
|
||||
e8 %main # call +11 <main>
|
||||
00 00 00
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @210
|
||||
:main
|
||||
# print <hello>
|
||||
b8 04 00 00 00 # mov $4, %eax
|
||||
bb 00 00 00 00 # mov $1, %ebx
|
||||
b9 &hello # mov $hello,%ecx
|
||||
ba %bye>hello # mov $(bye-hello),%edx
|
||||
cd 80 # int $0x80
|
||||
|
||||
# exit 0
|
||||
b8 01 00 00 00 # mov $0x1,%eax
|
||||
bb 00 00 00 00 # mov $0,%ebx
|
||||
cd 80 # int $0x80
|
||||
f4 # hlt
|
||||
|
||||
00 00 00 00 00 00 00 00 00 00 # align to @240
|
||||
00 00 00
|
||||
|
||||
# @240
|
||||
:ELF_data
|
||||
:hello
|
||||
48 65 6c 6c 6f 2c 20 47 # Hello, G
|
||||
4e 55 20 4d 65 73 21 0a # NU Mes!\n
|
||||
|
||||
:bye
|
||||
00
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
### This file is part of stage0.
|
||||
###
|
||||
### stage0 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.
|
||||
###
|
||||
### stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
### stage0's hex2 format for x86
|
||||
### !<label> 1 byte relative
|
||||
### $<label> 2 byte address
|
||||
### @<label> 2 byte relative
|
||||
### &<label> 4 byte address
|
||||
### %<label> 4 byte relative
|
||||
### local_<label> function-local
|
||||
### string_<index> string #<index>
|
||||
|
||||
### elf32-footer-single-main.hex2: 32 bit elf footer in hex2 for single main
|
||||
|
||||
# @230
|
||||
|
||||
:ELF_str
|
||||
00 # 0
|
||||
:ELF_str__start
|
||||
5f 73 74 61 72 74 00 # _start
|
||||
:ELF_str__main
|
||||
6d 61 69 6e 00 # main
|
||||
|
||||
00 00 00
|
||||
|
||||
# @240
|
||||
:ELF_sym
|
||||
00 00 00 00 # st-name
|
||||
00 00 00 00 # st-offset: &_start - BaseAddress
|
||||
00 00 00 00 # st-len : &main - _start
|
||||
00 # st-info = stt-func= 2
|
||||
00 # st-other
|
||||
01 00 # st-shndx: 1
|
||||
|
||||
# _start
|
||||
%ELF_str__start>ELF_str # st-name
|
||||
&_start
|
||||
10 00 00 00 # st-len : &main - _start
|
||||
02 # st-info = stt-func= 2
|
||||
00 # st-other
|
||||
01 00 # st-shndx: 1
|
||||
|
||||
# main
|
||||
%ELF_str__main>ELF_str # st-name
|
||||
&main
|
||||
10 00 00 00 # st-len : &ELF_data - main
|
||||
02 # st-info = stt-func= 2
|
||||
00 # st-other
|
||||
01 00 # st-shndx: 1
|
||||
|
||||
:ELF_end
|
||||
225
sysa/mes-0.22/lib/linux/x86-mes/elf32-header.hex2
Normal file
225
sysa/mes-0.22/lib/linux/x86-mes/elf32-header.hex2
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
### Copyright (C) 2016 Jeremiah Orians
|
||||
### Copyright (C) 2017,2019 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/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
# elf32-header.hex2: 32 bit elf header in hex2, with text segment, data
|
||||
# segment and symbol tables.
|
||||
|
||||
# stage0's hex2 format for x86
|
||||
# !<label> 1 byte relative
|
||||
# $<label> 2 byte address
|
||||
# @<label> 2 byte relative
|
||||
# &<label> 4 byte address
|
||||
# %<label> 4 byte relative
|
||||
# local_<label> function-local
|
||||
# string_<index> string #<index>
|
||||
|
||||
### Code:
|
||||
|
||||
:ELF_base
|
||||
7F 45 4C 46 # e_ident[EI_MAG0-3] ELF's magic number
|
||||
|
||||
01 # e_ident[EI_CLASS] Indicating 32 bit
|
||||
01 # e_ident[EI_DATA] Indicating little endianness
|
||||
01 # e_ident[EI_VERSION] Indicating original elf
|
||||
|
||||
00 # e_ident[EI_OSABI] Set at 0 because none cares
|
||||
00 # e_ident[EI_ABIVERSION] See above
|
||||
|
||||
00 00 00 00 00 00 00 # e_ident[EI_PAD]
|
||||
|
||||
02 00 # e_type Indicating Executable
|
||||
03 00 # e_machine Indicating 32bit x86
|
||||
01 00 00 00 # e_version Indicating original elf
|
||||
|
||||
&ELF_text # e_entry Address of the entry point
|
||||
%ELF_program_headers>ELF_base # e_phoff Address of program header table
|
||||
%ELF_section_headers>ELF_base # e_shoff Address of section header table
|
||||
|
||||
00 00 00 00 # e_flags
|
||||
|
||||
34 00 # e_ehsize Indicating our 52 Byte header
|
||||
|
||||
20 00 # e_phentsize size of a program header table
|
||||
01 00 # e_phnum number of entries in program table
|
||||
|
||||
28 00 # e_shentsize size of a section header table
|
||||
07 00 # e_shnum number of entries in section table
|
||||
|
||||
04 00 # e_shstrndx index of the section names
|
||||
|
||||
# @34
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @40
|
||||
:ELF_program_headers
|
||||
:ELF_program_header__text
|
||||
01 00 00 00 # ph_type: PT-LOAD = 1
|
||||
00 00 00 00 # ph_offset
|
||||
&ELF_base # ph_vaddr
|
||||
&ELF_base # ph_physaddr
|
||||
%ELF_end>ELF_base # ph_filesz
|
||||
%ELF_end>ELF_base # ph_memsz
|
||||
07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
|
||||
01 00 00 00 # ph_align
|
||||
|
||||
# @60
|
||||
#:ELF_program_header__data # NOT USED
|
||||
# FIXME: linux 4.17 does not allow this overlap
|
||||
# Uhuuh, elf segment at 0000000001000000
|
||||
# requested but the memory is mapped already
|
||||
01 00 00 00 # ph_type: PT-LOAD = 1
|
||||
00 00 00 00 # ph_offset
|
||||
&ELF_base # ph_vaddr
|
||||
&ELF_base # ph_physaddr
|
||||
%ELF_end>ELF_base # ph_filesz
|
||||
%ELF_end>ELF_base # ph_memsz
|
||||
07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
|
||||
01 00 00 00 # ph_align
|
||||
|
||||
# @80
|
||||
:ELF_comment
|
||||
4d 45 53 00 # MES
|
||||
00 00 00 00 # align
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
4d 45 53 00 # MES
|
||||
00 00 00 00 # align
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @a0
|
||||
:ELF_shstr
|
||||
00
|
||||
:ELF_shstr__text
|
||||
2e 74 65 78 74 00 # .text
|
||||
:ELF_shstr__data
|
||||
2e 64 61 74 61 00 # .data
|
||||
:ELF_shstr__comment
|
||||
2e 63 6f 6d 6d 65 6e 74 00 # .comment
|
||||
:ELF_shstr__shstr
|
||||
2e 73 68 73 74 72 74 61 62 00 # .shstrtab
|
||||
:ELF_shstr__sym
|
||||
2e 73 79 6d 74 61 62 00 # .symtab
|
||||
:ELF_shstr__str
|
||||
2e 73 74 72 74 61 62 00 # .strtab
|
||||
|
||||
# @d0
|
||||
|
||||
:ELF_section_headers
|
||||
00 00 00 00 # sh_name
|
||||
00 00 00 00 # sh_type
|
||||
00 00 00 00 # sh_flags
|
||||
00 00 00 00 # sh_addr
|
||||
00 00 00 00 # sh_offset
|
||||
00 00 00 00 # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 # sh_1?
|
||||
00 00 00 00 # sh_entsize
|
||||
|
||||
## FIXME: M0 for calculations?
|
||||
:ELF_section_header_text
|
||||
%ELF_shstr__text>ELF_shstr # sh_name
|
||||
01 00 00 00 # sh_type = SHT_PROGBITS = 1
|
||||
06 00 00 00 # sh_flags = SHF-ALLOC|SHF-EXEC =2 | 4 = 6
|
||||
&ELF_text # sh_addr
|
||||
%ELF_text>ELF_base # sh_offset
|
||||
%ELF_data>ELF_text # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 # sh_1?
|
||||
00 00 00 00 # sh_entsize
|
||||
|
||||
:ELF_section_header_data
|
||||
%ELF_shstr__data>ELF_shstr # sh_name
|
||||
01 00 00 00 # sh_type = SHT_PROGBITS = 1
|
||||
03 00 00 00 # sh_flags = SHF-WRITE|SHF-ALLOC = 1 | 2 = 3
|
||||
&ELF_data # sh_addr
|
||||
%ELF_data>ELF_base # sh_offset
|
||||
%ELF_sym>ELF_data # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 # sh_1?
|
||||
00 00 00 00 # sh_entsize
|
||||
|
||||
:ELF_section_header_comment
|
||||
%ELF_shstr__comment>ELF_shstr # sh_name
|
||||
01 00 00 00 # sh_type = SHT_PROGBITS = 1
|
||||
00 00 00 00 # sh_flags
|
||||
&ELF_comment # sh_addr
|
||||
%ELF_comment>ELF_base # sh_offset
|
||||
%ELF_shstr>ELF_comment # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 # sh_1?
|
||||
00 00 00 00 # sh_entsize
|
||||
|
||||
:ELF_section_header_shstr
|
||||
%ELF_shstr__shstr>ELF_shstr # sh_name
|
||||
03 00 00 00 # sh_type: str-sht-strtab
|
||||
00 00 00 00 # sh_flags
|
||||
&ELF_shstr # sh_addr
|
||||
%ELF_shstr>ELF_base # sh_offset
|
||||
%ELF_section_headers>ELF_shstr # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 # sh_1?
|
||||
00 00 00 00 # sh_entsize
|
||||
|
||||
:ELF_section_header_sym
|
||||
%ELF_shstr__sym>ELF_shstr # sh_name
|
||||
02 00 00 00 # sh_type: str-sht-symtab
|
||||
00 00 00 00 # sh_flags
|
||||
&ELF_sym # sh_addr
|
||||
%ELF_sym>ELF_base # sh_offset
|
||||
%ELF_end>ELF_sym # sh_length
|
||||
06 00 00 00 # sh_link:6
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 # sh_1?
|
||||
10 00 00 00 # sh_entsize
|
||||
|
||||
:ELF_section_header_str
|
||||
%ELF_shstr__str>ELF_shstr # sh_name
|
||||
03 00 00 00 # sh_type: str-sht-strtab
|
||||
00 00 00 00 # sh_flags
|
||||
&ELF_str # sh_addr
|
||||
%ELF_str>ELF_base # sh_offset
|
||||
%ELF_sym>ELF_str # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 # sh_1?
|
||||
00 00 00 00 # sh_entsize
|
||||
|
||||
# @1e8
|
||||
00 00 00 00 # align
|
||||
00 00 00 00
|
||||
|
||||
# @1f0
|
||||
|
||||
00 00 00 00 # align
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @200
|
||||
:ELF_text
|
||||
63
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/crt0.c
Normal file
63
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/crt0.c
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
/* -*-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
|
||||
|
||||
#include <mes/lib-mini.h>
|
||||
int main (int argc, char *argv[]);
|
||||
|
||||
// gcc x86_64 calling convention:
|
||||
// rdi, rsi, rdx, rcx, r8, r9, <stack0>, <stack1>
|
||||
|
||||
// *INDENT-OFF*
|
||||
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"
|
||||
);
|
||||
}
|
||||
79
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/crt1.c
Normal file
79
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/crt1.c
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/* -*-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/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib-mini.h>
|
||||
// int main (int argc, char *argv[]);
|
||||
|
||||
// gcc x86_64 calling convention:
|
||||
// rdi, rsi, rdx, rcx, r8, r9, <stack0>, <stack1>
|
||||
|
||||
// *INDENT-OFF*
|
||||
void
|
||||
_start ()
|
||||
{
|
||||
asm (
|
||||
"mov $0,%%eax\n\t"
|
||||
"mov %%eax,%0\n"
|
||||
: "=r" (__stdin)
|
||||
: //no inputs ""
|
||||
);
|
||||
|
||||
asm (
|
||||
"mov $1,%%eax\n\t"
|
||||
"mov %%eax,%0\n"
|
||||
: "=r" (__stdout)
|
||||
: //no inputs ""
|
||||
);
|
||||
|
||||
asm (
|
||||
"mov $2,%%eax\n\t"
|
||||
"mov %%eax,%0\n"
|
||||
: "=r" (__stderr)
|
||||
: //no inputs ""
|
||||
);
|
||||
asm (
|
||||
"mov %%rbp,%%rax\n\t"
|
||||
"add $8,%%rax\n\t"
|
||||
"mov (%%rax),%%rax\n\t"
|
||||
"add $3,%%rax\n\t"
|
||||
"shl $3,%%rax\n\t"
|
||||
"add %%rbp,%%rax\n\t"
|
||||
"mov %%rax,%0\n\t"
|
||||
"mov %%rax,%%rdx\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"
|
||||
);
|
||||
}
|
||||
19
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/crti.c
Normal file
19
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/crti.c
Normal 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
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/crtn.c
Normal file
19
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/crtn.c
Normal 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/>.
|
||||
*/
|
||||
46
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/exit-42.S
Normal file
46
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/exit-42.S
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019 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/>.
|
||||
*/
|
||||
|
||||
/** Commentary: */
|
||||
|
||||
/* Using gdb, esp. GUD in GNU Emacs is recommended
|
||||
M-x gdb-display-disassembly-buffer
|
||||
M-x gdb-display-io-buffer
|
||||
set disassemble-next-line on
|
||||
break _start
|
||||
run
|
||||
info registers
|
||||
si
|
||||
p/x $rax
|
||||
RET
|
||||
...
|
||||
*/
|
||||
|
||||
/** Code: */
|
||||
|
||||
SYS_exit = 0x3c /* Linux syscall: exit. */
|
||||
.globl _start /* Magic linker symbol: --entry-address. */
|
||||
|
||||
.text /* Program text. */
|
||||
_start:
|
||||
movabs $SYS_exit,%rax /* System call function: exit, in %rax. */
|
||||
movabs $42,%rdi /* First parameter: exit status, in %rdi. */
|
||||
syscall /* Call system. */
|
||||
hlt /* Should not be reached. */
|
||||
58
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/hello-mes.S
Normal file
58
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/hello-mes.S
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2019 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/>.
|
||||
*/
|
||||
|
||||
/** Commentary: */
|
||||
|
||||
/* Using gdb, esp. GUD in GNU Emacs is recommended
|
||||
M-x gdb-display-disassembly-buffer
|
||||
M-x gdb-display-io-buffer
|
||||
set disassemble-next-line on
|
||||
break _start
|
||||
run
|
||||
info registers
|
||||
si
|
||||
p/x $rax
|
||||
RET
|
||||
...
|
||||
*/
|
||||
|
||||
/** Code: */
|
||||
|
||||
SYS_exit = 0x3c /* Linux syscalls. */
|
||||
SYS_write = 0x01
|
||||
stdout = 1 /* File discriptor */
|
||||
.globl _start /* Magic linker symbol: --entry-address. */
|
||||
|
||||
.text /* Program text. */
|
||||
_start:
|
||||
movabs $SYS_write,%rax /* System call function: write, in %rax. */
|
||||
movabs $stdout,%rdi /* 1st parameter: file descriptor, in %rdi. */
|
||||
movabs $hello,%rsi /* 2nd parameter: address, in %rsi. */
|
||||
movabs $(bye-hello),%rdx /* 3rd parameter: byte count %rdx. */
|
||||
syscall /* Call system. */
|
||||
|
||||
movabs $SYS_exit,%rax /* System call function: exit, in %rax. */
|
||||
movabs $0,%rdi /* 1st parameter: exit status, in %rdi. */
|
||||
syscall /* Call system. */
|
||||
hlt /* Should not be reached. */
|
||||
|
||||
.data
|
||||
hello: .ascii "Hello, GNU Mes!\n"
|
||||
bye: .byte 0
|
||||
57
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/mini.c
Normal file
57
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/mini.c
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,2017,2018,2019 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/>.
|
||||
*/
|
||||
|
||||
#include "mes/lib-mini.h"
|
||||
|
||||
#define SYS_exit "0x3c"
|
||||
#define SYS_write "0x01"
|
||||
|
||||
// *INDENT-OFF*
|
||||
void
|
||||
_exit (int code)
|
||||
{
|
||||
asm (
|
||||
"mov $"SYS_exit",%%rax\n\t"
|
||||
"mov %0,%%rdi\n\t"
|
||||
"syscall \n\t"
|
||||
: // no outputs "=" (r)
|
||||
: "rm" (code)
|
||||
);
|
||||
// not reached
|
||||
_exit (0);
|
||||
}
|
||||
|
||||
ssize_t
|
||||
_write (int filedes, void const *buffer, size_t size)
|
||||
{
|
||||
long r;
|
||||
asm (
|
||||
"mov $"SYS_write",%%rax\n\t"
|
||||
"mov %1,%%rdi\n\t"
|
||||
"mov %2,%%rsi\n\t"
|
||||
"mov %3,%%rdx\n\t"
|
||||
"syscall \n\t"
|
||||
"mov %%rax,%0\n\t"
|
||||
: "=r" (r)
|
||||
: "rm" (filedes), "rm" (buffer), "rm" (size)
|
||||
: "rax", "rdi", "rsi", "rdx"
|
||||
);
|
||||
return r;
|
||||
}
|
||||
152
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/syscall.c
Normal file
152
sysa/mes-0.22/lib/linux/x86_64-mes-gcc/syscall.c
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,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/>.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <linux/x86_64/syscall.h>
|
||||
|
||||
// HMM, merge this with x86-mes-gcc/mes.c, doing something like
|
||||
// #define R0 eax
|
||||
// #define R1 ebx
|
||||
//
|
||||
// #define R0 rax
|
||||
// #define R1 rdi
|
||||
|
||||
// *INDENT-OFF*
|
||||
long
|
||||
_sys_call (long sys_call)
|
||||
{
|
||||
long r;
|
||||
asm (
|
||||
"mov %1,%%rax\n\t"
|
||||
"syscall \n\t"
|
||||
"mov %%rax,%0\n\t"
|
||||
: "=r" (r)
|
||||
: "rm" (sys_call)
|
||||
: "rax"
|
||||
);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call1 (long sys_call, long one)
|
||||
{
|
||||
long r;
|
||||
asm (
|
||||
"mov %1,%%rax\n\t"
|
||||
"mov %2,%%rdi\n\t"
|
||||
"syscall \n\t"
|
||||
"mov %%rax,%0\n\t"
|
||||
: "=r" (r)
|
||||
: "rm" (sys_call), "rm" (one)
|
||||
: "rax", "rdi"
|
||||
);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call2 (long sys_call, long one, long two)
|
||||
{
|
||||
long r;
|
||||
asm (
|
||||
"mov %1,%%rax\n\t"
|
||||
"mov %2,%%rdi\n\t"
|
||||
"mov %3,%%rsi\n\t"
|
||||
"syscall \n\t"
|
||||
"mov %%rax,%0\n\t"
|
||||
: "=r" (r)
|
||||
: "rm" (sys_call), "rm" (one), "rm" (two)
|
||||
: "rax", "rdi", "rsi"
|
||||
);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call3 (long sys_call, long one, long two, long three)
|
||||
{
|
||||
long r;
|
||||
asm (
|
||||
"mov %2,%%rdi\n\t"
|
||||
"mov %3,%%rsi\n\t"
|
||||
"mov %4,%%rdx\n\t"
|
||||
"mov %1,%%rax\n\t"
|
||||
"syscall \n\t"
|
||||
"mov %%rax,%0\n\t"
|
||||
: "=r" (r)
|
||||
: "rm" (sys_call), "rm" (one), "rm" (two), "rm" (three)
|
||||
: "rax", "rdi", "rsi", "rdx"
|
||||
);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call4 (long sys_call, long one, long two, long three, long four)
|
||||
{
|
||||
long r;
|
||||
asm (
|
||||
"mov %2,%%rdi\n\t"
|
||||
"mov %3,%%rsi\n\t"
|
||||
"mov %4,%%rdx\n\t"
|
||||
"mov %5,%%r10\n\t"
|
||||
"mov %1,%%rax\n\t"
|
||||
// );
|
||||
// asm (
|
||||
"syscall \n\t"
|
||||
"mov %%rax,%0\n\t"
|
||||
: "=r" (r)
|
||||
: "rm" (sys_call), "rm" (one), "rm" (two), "rm" (three), "rm" (four)
|
||||
: "rax", "rdi", "rsi", "rdx", "r10"
|
||||
);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
79
sysa/mes-0.22/lib/linux/x86_64-mes-mescc/crt1.c
Normal file
79
sysa/mes-0.22/lib/linux/x86_64-mes-mescc/crt1.c
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/* -*-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/>.
|
||||
*/
|
||||
|
||||
#include "mes/lib-mini.h"
|
||||
int main (int argc, char *argv[], char *envp[]);
|
||||
|
||||
int
|
||||
_start ()
|
||||
{
|
||||
asm ("mov____$i8,%rax !0");
|
||||
asm ("movl___%eax,0x32 &__stdin");
|
||||
|
||||
asm ("mov____$i8,%rax !1");
|
||||
asm ("movl___%eax,0x32 &__stdout");
|
||||
|
||||
asm ("mov____$i8,%rax !2");
|
||||
asm ("movl___%eax,0x32 &__stderr");
|
||||
|
||||
#if 0 //MES_CCAMD64
|
||||
asm ("add____$i32,%rbp %0x80"); // FIXME: corresponds to x86_64/as.scm function-preamble-fu
|
||||
#endif
|
||||
asm ("mov____%rbp,%rax");
|
||||
asm ("add____$i8,%rax !8");
|
||||
|
||||
asm ("mov____(%rax),%rax");
|
||||
asm ("add____$i8,%rax !0x03");
|
||||
|
||||
asm ("shl____$i8,%rax !0x03");
|
||||
asm ("add____%rbp,%rax");
|
||||
|
||||
// FIXME: 64-bit addresses...
|
||||
asm ("mov____%rax,0x32 &environ");
|
||||
#if 0 //MES_CCAMD64
|
||||
asm ("mov____%rax,%rdx"); // amd
|
||||
#else
|
||||
asm ("push___%rax"); // bootstrap
|
||||
#endif
|
||||
|
||||
asm ("mov____%rbp,%rax");
|
||||
asm ("add____$i8,%rax !16");
|
||||
#if 0 //MES_CCAMD64
|
||||
asm ("mov____%rax,%rsi"); // amd
|
||||
#else
|
||||
asm ("push___%rax"); // bootstrap
|
||||
#endif
|
||||
|
||||
asm ("mov____%rbp,%rax");
|
||||
asm ("add____$i8,%rax !8");
|
||||
asm ("mov____(%rax),%rax");
|
||||
#if 0 //MES_CCAMD64
|
||||
asm ("mov____%rax,%rdi"); // amd
|
||||
#else
|
||||
asm ("push___%rax"); // bootstrap
|
||||
#endif
|
||||
|
||||
main ();
|
||||
|
||||
asm ("mov____%rax,%rdi");
|
||||
asm ("mov____$i32,%rax %0x3c");
|
||||
asm ("syscall");
|
||||
asm ("hlt");
|
||||
}
|
||||
28
sysa/mes-0.22/lib/linux/x86_64-mes-mescc/exit-42.S
Normal file
28
sysa/mes-0.22/lib/linux/x86_64-mes-mescc/exit-42.S
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright © 2019 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/>.
|
||||
|
||||
DEFINE sys_exit 0x3c
|
||||
|
||||
:main
|
||||
mov____$i8,%eax !42
|
||||
mov____%rax,%rbx
|
||||
mov____$i8,%eax sys_exit
|
||||
syscall
|
||||
|
||||
:ELF_data
|
||||
:HEX2_data
|
||||
40
sysa/mes-0.22/lib/linux/x86_64-mes-mescc/hello-mes.S
Normal file
40
sysa/mes-0.22/lib/linux/x86_64-mes-mescc/hello-mes.S
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright © 2019 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/>.
|
||||
|
||||
DEFINE sys_exit 0x3c
|
||||
DEFINE sys_write 0x01
|
||||
|
||||
:main
|
||||
mov____$i8,%eax !end_hello_message>hello_message
|
||||
mov____%rax,%rcx
|
||||
mov____$i8,%eax !0
|
||||
mov____%rax,%rbx
|
||||
mov____$i8,%eax sys_write
|
||||
syscall
|
||||
|
||||
mov____$i8,%eax !0
|
||||
mov____%rax,%rbx
|
||||
mov____$i8,%eax sys_exit
|
||||
syscall
|
||||
|
||||
:ELF_data
|
||||
:hello_message
|
||||
"Hello, GNU Mes!
|
||||
"
|
||||
:end_hello_message
|
||||
:HEX2_data
|
||||
45
sysa/mes-0.22/lib/linux/x86_64-mes-mescc/mini.c
Normal file
45
sysa/mes-0.22/lib/linux/x86_64-mes-mescc/mini.c
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/* -*-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/>.
|
||||
*/
|
||||
|
||||
#include "mes/lib-mini.h"
|
||||
|
||||
void
|
||||
_exit (int status)
|
||||
{
|
||||
#if 1 // !MES_CCAMD64
|
||||
asm ("mov____0x8(%rbp),%rdi !0x10");
|
||||
#endif
|
||||
|
||||
asm ("mov____$i32,%rax SYS_exit");
|
||||
asm ("syscall");
|
||||
}
|
||||
|
||||
void
|
||||
_write (int filedes, void const *buffer, size_t size)
|
||||
{
|
||||
#if 1 // !MES_CCAMD64
|
||||
asm ("mov____0x8(%rbp),%rdi !0x10");
|
||||
asm ("mov____0x8(%rbp),%rsi !0x18");
|
||||
asm ("mov____0x8(%rbp),%rdx !0x20");
|
||||
#endif
|
||||
|
||||
asm ("mov____$i32,%rax SYS_write");
|
||||
asm ("syscall");
|
||||
}
|
||||
123
sysa/mes-0.22/lib/linux/x86_64-mes-mescc/syscall.c
Normal file
123
sysa/mes-0.22/lib/linux/x86_64-mes-mescc/syscall.c
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2016,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/>.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <linux/x86_64/syscall.h>
|
||||
|
||||
long
|
||||
//__sys_call (long one, long two, long three, long four)
|
||||
__sys_call (long sys_call, long one, long two, long three, long four)
|
||||
{
|
||||
#if 1 // !MES_CCAMD64
|
||||
// asm ("mov____0x8(%rbp),%rdi !0x10");
|
||||
// asm ("mov____0x8(%rbp),%rsi !0x18");
|
||||
// asm ("mov____0x8(%rbp),%rdx !0x20");
|
||||
// asm ("mov____0x8(%rbp),%rdx !0x28");
|
||||
// asm ("mov____0x8(%rbp),%r10 !0x30");
|
||||
|
||||
asm ("mov____0x8(%rbp),%rax !0x10");
|
||||
asm ("mov____0x8(%rbp),%rdi !0x18");
|
||||
asm ("mov____0x8(%rbp),%rsi !0x20");
|
||||
asm ("mov____0x8(%rbp),%rdx !0x28");
|
||||
asm ("mov____0x8(%rbp),%r10 !0x30");
|
||||
#endif
|
||||
|
||||
asm ("syscall");
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call (long sys_call)
|
||||
{
|
||||
// long rax = sys_call;
|
||||
// long r = __sys_call ();
|
||||
long r = __sys_call (sys_call);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call1 (long sys_call, long one)
|
||||
{
|
||||
// long rax = sys_call;
|
||||
// long r = __sys_call (one);
|
||||
long r = __sys_call (sys_call, one);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call2 (long sys_call, long one, long two)
|
||||
{
|
||||
// long rax = sys_call;
|
||||
// long r = __sys_call (one, two);
|
||||
long r = __sys_call (sys_call, one, two);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call3 (long sys_call, long one, long two, long three)
|
||||
{
|
||||
// long rax = sys_call;
|
||||
// long r = __sys_call (one, two, three);
|
||||
long r = __sys_call (sys_call, one, two, three);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
long
|
||||
_sys_call4 (long sys_call, long one, long two, long three, long four)
|
||||
{
|
||||
// long rax = sys_call;
|
||||
// long r = __sys_call (one, two, three, four);
|
||||
long r = __sys_call (sys_call, one, two, three, four);
|
||||
if (r < 0)
|
||||
{
|
||||
errno = -r;
|
||||
r = -1;
|
||||
}
|
||||
else
|
||||
errno = 0;
|
||||
return r;
|
||||
}
|
||||
36
sysa/mes-0.22/lib/linux/x86_64-mes/elf64-0exit-42.hex2
Normal file
36
sysa/mes-0.22/lib/linux/x86_64-mes/elf64-0exit-42.hex2
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright © 2017,2019 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/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
# elf64-exit-42.hex2: `exit 42' for x86_64-linux written in hex2
|
||||
# assembly, for usage with elf64-0header.hex2. This produces a 160-byte
|
||||
# binary (a0 hex). Inspiration was taken from GNU Gcc output of
|
||||
# exit-42.S.
|
||||
|
||||
### Code:
|
||||
|
||||
# @80
|
||||
:ELF_text
|
||||
48 b8 3c 00 00 00 00 00 00 00 # movabs $0x3c,%rax
|
||||
48 bf 2a 00 00 00 00 00 00 00 # movabs $42,%rdi
|
||||
0f 05 # syscall
|
||||
f4 # hlt
|
||||
|
||||
00 00 00 00 00 00 00 00 00 # align to @a0
|
||||
:ELF_end
|
||||
83
sysa/mes-0.22/lib/linux/x86_64-mes/elf64-0header.hex2
Normal file
83
sysa/mes-0.22/lib/linux/x86_64-mes/elf64-0header.hex2
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
### Copyright (C) 2016 Jeremiah Orians
|
||||
### Copyright (C) 2017,2019 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/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
# elf64-0header.hex2: Simplest 64 bit elf header in hex2. Only a text
|
||||
# segment, no data segment, no symbol tables.
|
||||
|
||||
# stage0's hex2 format for x86_64
|
||||
# !<label> 1 byte relative
|
||||
# $<label> 2 byte address
|
||||
# @<label> 2 byte relative
|
||||
# &<label> 4 byte address
|
||||
# %<label> 4 byte relative
|
||||
# local_<label> function-local
|
||||
# string_<index> string #<index>
|
||||
|
||||
### Code:
|
||||
|
||||
:ELF_base
|
||||
7F 45 4C 46 # e_ident[EI_MAG0-3] ELF's magic number
|
||||
|
||||
02 # e_ident[EI_CLASS] Indicating 64 bit
|
||||
01 # e_ident[EI_DATA] Indicating little endianness
|
||||
01 # e_ident[EI_VERSION] Indicating original elf
|
||||
|
||||
00 # e_ident[EI_OSABI] Set at 0 because none cares
|
||||
00 # e_ident[EI_ABIVERSION] See above
|
||||
|
||||
00 00 00 00 00 00 00 # e_ident[EI_PAD]
|
||||
|
||||
02 00 # e_type Indicating Executable
|
||||
3E 00 # e_machine Indicating AMD64
|
||||
01 00 00 00 # e_version Indicating original elf
|
||||
|
||||
&ELF_text 00 00 00 00 # e_entry Address of the entry point
|
||||
%ELF_program_headers>ELF_base # e_phoff Address of program header table
|
||||
00 00 00 00
|
||||
|
||||
00 00 00 00 00 00 00 00 # e_shoff Address of section header table
|
||||
|
||||
00 00 00 00 # e_flags
|
||||
|
||||
40 00 # e_ehsize Indicating our 64 Byte header
|
||||
|
||||
38 00 # e_phentsize size of a program header table
|
||||
01 00 # e_phnum number of entries in program table
|
||||
|
||||
00 00 # e_shentsize size of a section header table
|
||||
00 00 # e_shnum number of entries in section table
|
||||
|
||||
00 00 # e_shstrndx index of the section names
|
||||
|
||||
# @40
|
||||
:ELF_program_headers
|
||||
:ELF_program_header__text
|
||||
01 00 00 00 # ph_type: PT-LOAD = 1
|
||||
07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
|
||||
00 00 00 00 00 00 00 00 # p_offset
|
||||
&ELF_base 00 00 00 00 # ph_vaddr
|
||||
&ELF_base 00 00 00 00 # ph_physaddr
|
||||
%ELF_end>ELF_base 00 00 00 00 # ph_filesz
|
||||
%ELF_end>ELF_base 00 00 00 00 # ph_memsz
|
||||
01 00 00 00 00 00 00 00 # ph_align
|
||||
|
||||
00 00 00 00 00 00 00 00 # align to @80
|
||||
# @80
|
||||
:ELF_text
|
||||
52
sysa/mes-0.22/lib/linux/x86_64-mes/elf64-0hello-mes.hex2
Normal file
52
sysa/mes-0.22/lib/linux/x86_64-mes/elf64-0hello-mes.hex2
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright © 2017,2018,2019 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/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
# elf64-hello-mes.hex2: `Hello, GNU Mes!' for x86_64-linux written in
|
||||
# hex2 assembly, for usage with elf64-0header.hex2. This produces a
|
||||
# 224-byte binary (e0 hex). Inspiration was taken from GNU Gcc output
|
||||
# of hello-mes.S.
|
||||
|
||||
### Code:
|
||||
|
||||
# @80
|
||||
:ELF_text
|
||||
# print <hello>
|
||||
48 b8 01 00 00 00 00 00 00 00 # movabs $1,%rax
|
||||
48 bf 01 00 00 00 00 00 00 00 # movabs $1,%rdi
|
||||
48 be &hello 00 00 00 00 # movabs $<hello>,%rsi
|
||||
48 ba %bye>hello 00 00 00 00 # mov $(bye-hello),%rdx
|
||||
0f 05 # syscall
|
||||
|
||||
# exit 0
|
||||
48 b8 3c 00 00 00 00 00 00 00 # movabs $0x3c,%rax
|
||||
48 bf 00 00 00 00 00 00 00 00 # movabs $0,%rdi
|
||||
0f 05 # syscall
|
||||
f4 # hlt
|
||||
|
||||
00 00 00 00 00 00 00 00 00 # align to @d0
|
||||
00 00 00 00 00 00
|
||||
|
||||
# @d0
|
||||
:ELF_data
|
||||
:hello
|
||||
48 65 6c 6c 6f 2c 20 47 # Hello, G
|
||||
4e 55 20 4d 65 73 21 0a # NU Mes!\n
|
||||
:bye
|
||||
:ELF_end
|
||||
51
sysa/mes-0.22/lib/linux/x86_64-mes/elf64-body-exit-42.hex2
Normal file
51
sysa/mes-0.22/lib/linux/x86_64-mes/elf64-body-exit-42.hex2
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright © 2017,2018,2019 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/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
# elf64-body-exit-42.hex2: `exit 42' for x86_64-linux written in hex2
|
||||
# assembly, for usage with generic elf64-header.hex2 and
|
||||
# elf64-footer-single-main.hex.
|
||||
|
||||
# This ELF binary contains a symbol table, which means that objdump and
|
||||
# gdb can be used to inspect and debug.
|
||||
|
||||
### Code:
|
||||
|
||||
# @300
|
||||
:ELF_text
|
||||
:_start
|
||||
# exit(42)
|
||||
e8 %main # call +11 <main>
|
||||
00 00 00
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @310
|
||||
:main
|
||||
48 b8 3c 00 00 00 00 00 00 00 # movabs $0x3c,%rax
|
||||
48 bf 2a 00 00 00 00 00 00 00 # movabs $42,%rdi
|
||||
0f 05 # syscall
|
||||
f4 # hlt
|
||||
|
||||
00 00 00 00 00 00 00 00 00 # align to 330
|
||||
|
||||
# @330
|
||||
:ELF_data
|
||||
65 78 69 74 34 32 20 64 61 74 61 20 68 65 72 65 # exit42 data here"
|
||||
00
|
||||
63
sysa/mes-0.22/lib/linux/x86_64-mes/elf64-body-hello-mes.hex2
Normal file
63
sysa/mes-0.22/lib/linux/x86_64-mes/elf64-body-hello-mes.hex2
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
### GNU Mes --- Maxwell Equations of Software
|
||||
### Copyright © 2017,2018,2019 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/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
# elf64-body-hello-mes.hex2: `Hello, GNU Mes!' for x86_64-linux written
|
||||
# in hex2 assembly, for usage with generic elf64-header.hex2 and
|
||||
# elf64-footer-single-main.hex.
|
||||
|
||||
# This ELF binary contains a symbol table which means that objdump and
|
||||
# gdb can be used to inspect and debug.
|
||||
|
||||
### Code:
|
||||
|
||||
# @300
|
||||
:ELF_text
|
||||
:_start
|
||||
# exit(42)
|
||||
e8 %main # call +11 <main>
|
||||
00 00 00
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @310
|
||||
:main
|
||||
# print <hello>
|
||||
48 b8 01 00 00 00 00 00 00 00 # movabs $1,%rax
|
||||
48 bf 01 00 00 00 00 00 00 00 # movabs $1,%rdi
|
||||
48 be &hello 00 00 00 00 # movabs $<hello>,%rsi
|
||||
48 ba %bye>hello 00 00 00 00 # mov $(bye-hello),%rdx
|
||||
0f 05 # syscall
|
||||
|
||||
# exit 0
|
||||
48 b8 3c 00 00 00 00 00 00 00 # movabs $0x3c,%rax
|
||||
48 bf 00 00 00 00 00 00 00 00 # movabs $0,%rdi
|
||||
0f 05 # syscall
|
||||
f4 # hlt
|
||||
|
||||
00 00 00 00 00 00 00 00 00 # align to @360
|
||||
00 00 00 00 00 00
|
||||
|
||||
# @360
|
||||
:ELF_data
|
||||
:hello
|
||||
48 65 6c 6c 6f 2c 20 47 # Hello, G
|
||||
4e 55 20 4d 65 73 21 0a # NU Mes!\n
|
||||
:bye
|
||||
:ELF_end
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
### Copyright (C) 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
### This file is part of stage0.
|
||||
###
|
||||
### stage0 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.
|
||||
###
|
||||
### stage0 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 stage0. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
### stage0's hex2 format for x86_64
|
||||
### !<label> 1 byte relative
|
||||
### $<label> 2 byte address
|
||||
### @<label> 2 byte relative
|
||||
### &<label> 4 byte address
|
||||
### %<label> 4 byte relative
|
||||
### local_<label> function-local
|
||||
### string_<index> string #<index>
|
||||
|
||||
# @230
|
||||
|
||||
:ELF_str
|
||||
00 # 0
|
||||
:ELF_str__start
|
||||
5f 73 74 61 72 74 00 # _start
|
||||
:ELF_str__main
|
||||
6d 61 69 6e 00 # main
|
||||
|
||||
00 00 00
|
||||
|
||||
# @370
|
||||
:ELF_sym
|
||||
00 00 00 00 # st-name
|
||||
00 # st-info = stt-func= 2
|
||||
00 # st-other
|
||||
01 00 # st-shndx: 1
|
||||
00 00 00 00 00 00 00 00 # st-offset: &_start - BaseAddress
|
||||
00 00 00 00 00 00 00 00 # st-len : &main - _start
|
||||
|
||||
# _start
|
||||
%ELF_str__start>ELF_str # st-name
|
||||
02 # st-info = stt-func= 2
|
||||
00 # st-other
|
||||
01 00 # st-shndx: 1
|
||||
&_start 00 00 00 00
|
||||
10 00 00 00 00 00 00 00 # st-len : &main - _start
|
||||
|
||||
# main
|
||||
%ELF_str__main>ELF_str # st-name
|
||||
02 # st-info = stt-func= 2
|
||||
00 # st-other
|
||||
01 00 # st-shndx: 1
|
||||
&main 00 00 00 00
|
||||
10 00 00 00 00 00 00 00 # st-len : &ELF_data - main
|
||||
|
||||
:ELF_end
|
||||
240
sysa/mes-0.22/lib/linux/x86_64-mes/elf64-header.hex2
Normal file
240
sysa/mes-0.22/lib/linux/x86_64-mes/elf64-header.hex2
Normal file
|
|
@ -0,0 +1,240 @@
|
|||
### Copyright (C) 2016 Jeremiah Orians
|
||||
### Copyright (C) 2017,2019 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/>.
|
||||
|
||||
### Commentary:
|
||||
|
||||
# elf64-header.hex2: 64 bit elf header in hex2, with text segment, data
|
||||
# segment and symbol tables.
|
||||
|
||||
# stage0's hex2 format for x86_64
|
||||
# !<label> 1 byte relative
|
||||
# $<label> 2 byte address
|
||||
# @<label> 2 byte relative
|
||||
# &<label> 4 byte address
|
||||
# %<label> 4 byte relative
|
||||
# local_<label> function-local
|
||||
# string_<index> string #<index>
|
||||
|
||||
### Code:
|
||||
|
||||
:ELF_base
|
||||
7F 45 4c 46 # e_ident[EI_MAG0-3] ELF's magic number
|
||||
|
||||
02 # e_ident[EI_CLASS] Indicating 64 bit
|
||||
01 # e_ident[EI_DATA] Indicating little endianness
|
||||
01 # e_ident[EI_VERSION] Indicating original elf
|
||||
|
||||
00 # e_ident[EI_OSABI] Set at 0 because none cares
|
||||
00 # e_ident[EI_ABIVERSION] See above
|
||||
|
||||
00 00 00 00 00 00 00 # e_ident[EI_PAD]
|
||||
|
||||
# 0x10
|
||||
02 00 # e_type Indicating Executable
|
||||
3e 00 # e_machine Indicating AMD64
|
||||
01 00 00 00 # e_version Indicating original elf
|
||||
|
||||
# 0x18
|
||||
&ELF_text 00 00 00 00 # e_entry Address of the entry point
|
||||
%ELF_program_headers>ELF_base # e_phoff Address of program header table
|
||||
00 00 00 00
|
||||
|
||||
%ELF_section_headers>ELF_base # e_shoff Address of section header table
|
||||
00 00 00 00
|
||||
|
||||
00 00 00 00 # e_flags
|
||||
|
||||
40 00 # e_ehsize Indicating our 64 Byte header
|
||||
|
||||
38 00 # e_phentsize size of a program header table
|
||||
01 00 # e_phnum number of entries in program table
|
||||
|
||||
40 00 # e_shentsize size of a section header table
|
||||
07 00 # e_shnum number of entries in section table
|
||||
|
||||
04 00 # e_shstrndx index of the section names
|
||||
|
||||
# @40
|
||||
:ELF_program_headers
|
||||
:ELF_program_header__text
|
||||
01 00 00 00 # ph_type: PT-LOAD = 1
|
||||
07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
|
||||
00 00 00 00 00 00 00 00 # p_offset
|
||||
&ELF_base 00 00 00 00 # ph_vaddr
|
||||
&ELF_base 00 00 00 00 # ph_physaddr
|
||||
%ELF_end>ELF_base 00 00 00 00 # ph_filesz
|
||||
%ELF_end>ELF_base 00 00 00 00 # ph_memsz
|
||||
01 00 00 00 00 00 00 00 # ph_align
|
||||
|
||||
|
||||
# @60
|
||||
#:ELF_program_header__data # NOT USED
|
||||
# FIXME: linux 4.17 does not allow this overlap
|
||||
# Uhuuh, elf segment at 0000000001000000
|
||||
# requested but the memory is mapped already
|
||||
01 00 00 00 # ph_type: PT-LOAD = 1
|
||||
07 00 00 00 # ph_flags: PF-X|PF-W|PF-R = 7
|
||||
00 00 00 00 00 00 00 00 # ph_offset
|
||||
&ELF_base 00 00 00 00 # ph_vaddr
|
||||
&ELF_base 00 00 00 00 # ph_physaddr
|
||||
%ELF_end>ELF_base 00 00 00 00 # ph_filesz
|
||||
%ELF_end>ELF_base 00 00 00 00 # ph_memsz
|
||||
01 00 00 00 00 00 00 00 # ph_align
|
||||
|
||||
# @b0
|
||||
:ELF_comment
|
||||
4d 45 53 00 # MES
|
||||
00 00 00 00 # align
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @c0
|
||||
4d 45 53 00 # MES
|
||||
00 00 00 00 # align
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @d0
|
||||
:ELF_shstr
|
||||
00
|
||||
:ELF_shstr__text
|
||||
2e 74 65 78 74 00 # .text
|
||||
:ELF_shstr__data
|
||||
2e 64 61 74 61 00 # .data
|
||||
:ELF_shstr__comment
|
||||
2e 63 6f 6d 6d 65 6e 74 00 # .comment
|
||||
:ELF_shstr__shstr
|
||||
2e 73 68 73 74 72 74 61 62 00 # .shstrtab
|
||||
:ELF_shstr__sym
|
||||
2e 73 79 6d 74 61 62 00 # .symtab
|
||||
:ELF_shstr__str
|
||||
2e 73 74 72 74 61 62 00 # .strtab
|
||||
|
||||
# @100
|
||||
|
||||
:ELF_section_headers
|
||||
00 00 00 00 # sh_name
|
||||
00 00 00 00 # sh_type
|
||||
00 00 00 00 00 00 00 00 # sh_flags
|
||||
00 00 00 00 00 00 00 00 # sh_addr
|
||||
00 00 00 00 00 00 00 00 # sh_offset
|
||||
00 00 00 00 00 00 00 00 # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
00 00 00 00 00 00 00 00 # sh_1?
|
||||
00 00 00 00 00 00 00 00 # sh_entsize
|
||||
|
||||
## FIXME: M0 for calculations?
|
||||
:ELF_section_header_text
|
||||
%ELF_shstr__text>ELF_shstr # sh_name
|
||||
01 00 00 00 # sh_type = SHT_PROGBITS = 1
|
||||
06 00 00 00 00 00 00 00 # sh_flags = SHF-ALLOC|SHF-EXEC =2 | 4 = 6
|
||||
&ELF_text 00 00 00 00 # sh_addr
|
||||
%ELF_text>ELF_base 00 00 00 00 # sh_offset
|
||||
%ELF_data>ELF_text 00 00 00 00 # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 00 00 00 00 # sh_1?
|
||||
00 00 00 00 00 00 00 00 # sh_entsize
|
||||
|
||||
:ELF_section_header_data
|
||||
%ELF_shstr__data>ELF_shstr # sh_name
|
||||
01 00 00 00 # sh_type = SHT_PROGBITS = 1
|
||||
03 00 00 00 00 00 00 00 # sh_flags = SHF-WRITE|SHF-ALLOC = 1 | 2 = 3
|
||||
&ELF_data 00 00 00 00 # sh_addr
|
||||
%ELF_data>ELF_base 00 00 00 00 # sh_offset
|
||||
%ELF_sym>ELF_data 00 00 00 00 # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 00 00 00 00 # sh_1?
|
||||
00 00 00 00 00 00 00 00 # sh_entsize
|
||||
|
||||
:ELF_section_header_comment
|
||||
%ELF_shstr__comment>ELF_shstr # sh_name
|
||||
01 00 00 00 # sh_type = SHT_PROGBITS = 1
|
||||
00 00 00 00 00 00 00 00 # sh_flags
|
||||
&ELF_comment 00 00 00 00 # sh_addr
|
||||
%ELF_comment>ELF_base 00 00 00 00 # sh_offset
|
||||
%ELF_shstr>ELF_comment 00 00 00 00 # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 00 00 00 00 # sh_1?
|
||||
00 00 00 00 00 00 00 00 # sh_entsize
|
||||
|
||||
:ELF_section_header_shstr
|
||||
%ELF_shstr__shstr>ELF_shstr # sh_name
|
||||
03 00 00 00 # sh_type: str-sht-strtab
|
||||
00 00 00 00 00 00 00 00 # sh_flags
|
||||
&ELF_shstr 00 00 00 00 # sh_addr
|
||||
%ELF_shstr>ELF_base 00 00 00 00 # sh_offset
|
||||
%ELF_section_headers>ELF_shstr 00 00 00 00 # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 00 00 00 00 # sh_1?
|
||||
00 00 00 00 00 00 00 00 # sh_entsize
|
||||
|
||||
:ELF_section_header_sym
|
||||
%ELF_shstr__sym>ELF_shstr # sh_name
|
||||
02 00 00 00 # sh_type: str-sht-symtab
|
||||
00 00 00 00 00 00 00 00 # sh_flags
|
||||
&ELF_sym 00 00 00 00 # sh_addr
|
||||
%ELF_sym>ELF_base 00 00 00 00 # sh_offset
|
||||
%ELF_end>ELF_sym 00 00 00 00 # sh_length
|
||||
06 00 00 00 # sh_link:6
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 00 00 00 00 # sh_1?
|
||||
18 00 00 00 00 00 00 00 # sh_entsize
|
||||
|
||||
:ELF_section_header_str
|
||||
%ELF_shstr__str>ELF_shstr # sh_name
|
||||
03 00 00 00 # sh_type: str-sht-strtab
|
||||
00 00 00 00 00 00 00 00 # sh_flags
|
||||
&ELF_str 00 00 00 00 # sh_addr
|
||||
%ELF_str>ELF_base 00 00 00 00 # sh_offset
|
||||
%ELF_sym>ELF_str 00 00 00 00 # sh_length
|
||||
00 00 00 00 # sh_link
|
||||
00 00 00 00 # sh_info
|
||||
01 00 00 00 00 00 00 00 # sh_1?
|
||||
00 00 00 00 00 00 00 00 # sh_entsize
|
||||
|
||||
# @2c0
|
||||
00 00 00 00 # align
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @2d0
|
||||
00 00 00 00 # align
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @2e0
|
||||
00 00 00 00 # align
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @2f0
|
||||
00 00 00 00 # align
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
00 00 00 00
|
||||
|
||||
# @300
|
||||
:ELF_text
|
||||
Loading…
Add table
Add a link
Reference in a new issue