XXX DRAFT x86_64: build: Cater for M2-Planet.
What about - -f include/m2/lib.h \ XXX scaffold tests run, * MES_DEBUG=3 bin/mes-m2 segfaults in gc_init. * kaem.run: Define __<cpu>__. * kaem.x86_64, lib/linux/x86_64-mes-m2/_exit.c, lib/linux/x86_64-mes-m2/_write.c, lib/linux/x86_64-mes-m2/crt1.M1, lib/linux/x86_64-mes-m2/crt1.c, lib/linux/x86_64-mes-m2/syscall.c, lib/m2/x86_64/ELF-x86_64.hex2, lib/m2/x86_64/x86_64_defs.M1: New files. * build-aux/build.sh.in: Also allow kaem build for X86_64. * include/mes/lib-mini.h[__M2__ && __x86_64__](M2_PTR_SIZE): Define as 8. * include/mes/mes.h[__M2__ && __x86_64__](M2_CELL_SIZE): Define as 24. * lib/x86_64-mes/x86_64.M1 (add____$i8,%rbp, mov____%rdi,%rbp): New defines.
This commit is contained in:
parent
ef12ed4df7
commit
c70f51919f
|
@ -102,7 +102,8 @@ fi
|
||||||
)
|
)
|
||||||
|
|
||||||
if test -n "$M2_PLANET" && (test "$mes_cpu" == "x86" \
|
if test -n "$M2_PLANET" && (test "$mes_cpu" == "x86" \
|
||||||
|| test "$mes_cpu" == "arm"); then
|
|| test "$mes_cpu" == "x86_64" \
|
||||||
|
|| test "$mes_cpu" == "arm" ); then
|
||||||
(
|
(
|
||||||
. ${srcdest}build-aux/trace.sh
|
. ${srcdest}build-aux/trace.sh
|
||||||
if [ -z "$V" -o "$V" = 0 ]; then
|
if [ -z "$V" -o "$V" = 0 ]; then
|
||||||
|
|
|
@ -41,7 +41,11 @@
|
||||||
for that by multiplying with M2_PTR_SIZE when using (char)
|
for that by multiplying with M2_PTR_SIZE when using (char)
|
||||||
pointers. */
|
pointers. */
|
||||||
#if __M2__
|
#if __M2__
|
||||||
|
#if __x86_64__
|
||||||
|
#define M2_PTR_SIZE 8
|
||||||
|
#else
|
||||||
#define M2_PTR_SIZE 4
|
#define M2_PTR_SIZE 4
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#define M2_PTR_SIZE 1
|
#define M2_PTR_SIZE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,7 +57,11 @@ struct scm
|
||||||
for that by multiplying with M2_CELL_SIZE when using cell
|
for that by multiplying with M2_CELL_SIZE when using cell
|
||||||
pointers. */
|
pointers. */
|
||||||
#if __M2__
|
#if __M2__
|
||||||
|
#if __x86_64__
|
||||||
|
#define M2_CELL_SIZE 24
|
||||||
|
#else
|
||||||
#define M2_CELL_SIZE 12
|
#define M2_CELL_SIZE 12
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#define M2_CELL_SIZE 1
|
#define M2_CELL_SIZE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
1
kaem.run
1
kaem.run
|
@ -27,6 +27,7 @@ mkdir -p m2
|
||||||
M2-Planet \
|
M2-Planet \
|
||||||
--debug \
|
--debug \
|
||||||
--architecture ${stage0_cpu} \
|
--architecture ${stage0_cpu} \
|
||||||
|
-D __${mes_cpu}__=1 \
|
||||||
-D __linux__=1 \
|
-D __linux__=1 \
|
||||||
-f include/mes/config.h \
|
-f include/mes/config.h \
|
||||||
-f include/mes/lib-mini.h \
|
-f include/mes/lib-mini.h \
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#! /bin/sh
|
||||||
|
# Copyright © 2022 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/>.
|
||||||
|
|
||||||
|
# Usage:
|
||||||
|
# kaem --verbose --strict
|
||||||
|
|
||||||
|
mes_cpu=x86_64
|
||||||
|
stage0_cpu=amd64
|
||||||
|
kaem --verbose --strict
|
|
@ -0,0 +1,29 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2020,2022 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)
|
||||||
|
{
|
||||||
|
asm ("mov____$i32,%rax SYS_exit");
|
||||||
|
asm ("mov____0x8(%rbp),%rdi !-8");
|
||||||
|
asm ("syscall");
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2020,2022 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
|
||||||
|
_write (int filedes, void const *buffer, size_t size)
|
||||||
|
{
|
||||||
|
asm ("mov____$i32,%rax SYS_write");
|
||||||
|
asm ("mov____0x8(%rbp),%rdi !-8");
|
||||||
|
asm ("mov____0x8(%rbp),%rsi !-16");
|
||||||
|
asm ("mov____0x8(%rbp),%rdx !-24");
|
||||||
|
asm ("syscall");
|
||||||
|
}
|
|
@ -0,0 +1,118 @@
|
||||||
|
### GNU Mes --- Maxwell Equations of Software
|
||||||
|
### Copyright (C) 2016 Jeremiah Orians
|
||||||
|
### Copyright © 2017,2018,2019,2022 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/>.
|
||||||
|
|
||||||
|
:UNUSED_start
|
||||||
|
push___%rbp
|
||||||
|
mov____%rsp,%rbp
|
||||||
|
sub____$i32,%rsp %0x10a4
|
||||||
|
mov____$i8,%rax !0
|
||||||
|
movl___%eax,0x32 &GLOBAL___stdin
|
||||||
|
mov____$i8,%rax !1
|
||||||
|
movl___%eax,0x32 &GLOBAL___stdout
|
||||||
|
mov____$i8,%rax !2
|
||||||
|
movl___%eax,0x32 &GLOBAL___stderr
|
||||||
|
|
||||||
|
mov____%rbp,%rax
|
||||||
|
add____$i8,%rax !8
|
||||||
|
mov____(%rax),%rax
|
||||||
|
add____$i8,%rax !0x03
|
||||||
|
shl____$i8,%rax !0x03
|
||||||
|
add____%rbp,%rax
|
||||||
|
mov____%rax,0x32 &GLOBAL_environ
|
||||||
|
;; push___%rax ;M2-Planet pushes forward
|
||||||
|
|
||||||
|
mov____%rbp,%rax ;argc
|
||||||
|
add____$i8,%rax !8
|
||||||
|
mov____(%rax),%rax
|
||||||
|
push___%rax
|
||||||
|
|
||||||
|
mov____%rbp,%rax ;argv
|
||||||
|
add____$i8,%rax !16
|
||||||
|
push___%rax
|
||||||
|
|
||||||
|
mov____0x32,%rax &GLOBAL_environ
|
||||||
|
push___%rax ;env
|
||||||
|
|
||||||
|
mov____%rdi,%rbp ;M2-Planet calling convention
|
||||||
|
add____$i8,%rbp !8
|
||||||
|
|
||||||
|
call32 %FUNCTION_main
|
||||||
|
add____$i8,%rsp !0x0
|
||||||
|
test___%rax,%rax
|
||||||
|
mov____%rax,%rdi
|
||||||
|
mov____$i32,%rax %0x3c
|
||||||
|
syscall
|
||||||
|
hlt
|
||||||
|
mov____%rbp,%rsp
|
||||||
|
pop____%rbp
|
||||||
|
ret
|
||||||
|
|
||||||
|
:_start
|
||||||
|
|
||||||
|
COPY_rsp_to_rbp ; Protect rsp
|
||||||
|
|
||||||
|
;; Prepare argv
|
||||||
|
LOAD_BASE_ADDRESS_rax %8 ; ARGV_address = RBP + 8
|
||||||
|
PUSH_RAX ; Put argv on the stack
|
||||||
|
|
||||||
|
;; Prepare envp
|
||||||
|
COPY_rbp_to_rax ; Address we need to load from
|
||||||
|
LOAD_INTEGER ; Get ARGC
|
||||||
|
ADD_IMMEDIATE_to_rax %2 ; OFFSET = ARGC + 2
|
||||||
|
SAL_rax_Immediate8 !3 ; OFFSET = OFFSET * WORDSIZE
|
||||||
|
ADD_rbp_to_rax ; ENVP_address = RSP + OFFSET
|
||||||
|
PUSH_RAX ; Put envp on the stack
|
||||||
|
|
||||||
|
;; mes c lib environ
|
||||||
|
mov____%rax,0x32 &GLOBAL_environ
|
||||||
|
;; mes c lib io
|
||||||
|
mov____$i8,%rax !0
|
||||||
|
movl___%eax,0x32 &GLOBAL___stdin
|
||||||
|
mov____$i8,%rax !1
|
||||||
|
movl___%eax,0x32 &GLOBAL___stdout
|
||||||
|
mov____$i8,%rax !2
|
||||||
|
movl___%eax,0x32 &GLOBAL___stderr
|
||||||
|
|
||||||
|
LOAD_IMMEDIATE_rax &GLOBAL___stdin
|
||||||
|
PUSH_RAX #_common_recursion
|
||||||
|
LOAD_IMMEDIATE_rax %0
|
||||||
|
POP_RBX # _common_recursion
|
||||||
|
STORE_INTEGER
|
||||||
|
|
||||||
|
LOAD_IMMEDIATE_rax &GLOBAL___stdout
|
||||||
|
PUSH_RAX #_common_recursion
|
||||||
|
LOAD_IMMEDIATE_rax %1
|
||||||
|
POP_RBX # _common_recursion
|
||||||
|
STORE_INTEGER
|
||||||
|
|
||||||
|
LOAD_IMMEDIATE_rax &GLOBAL___stderr
|
||||||
|
PUSH_RAX #_common_recursion
|
||||||
|
LOAD_IMMEDIATE_rax %2
|
||||||
|
POP_RBX # _common_recursion
|
||||||
|
STORE_INTEGER
|
||||||
|
|
||||||
|
;; Stack offset
|
||||||
|
ADD_IMMEDIATE_to_rbp %8 ; Fix rbp
|
||||||
|
|
||||||
|
;; Perform the main loop
|
||||||
|
CALL_IMMEDIATE %FUNCTION_main
|
||||||
|
|
||||||
|
mov____%rax,%rdi
|
||||||
|
mov____$i32,%rax SYS_exit
|
||||||
|
syscall
|
|
@ -0,0 +1,34 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2018,2022 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 __stdin;
|
||||||
|
int __stdout;
|
||||||
|
int __stderr;
|
||||||
|
char **environ;
|
||||||
|
int main (int argc, char **argv, char **envp);
|
||||||
|
|
||||||
|
/* FIXME: this is going to be called `FUNCTION__start' */
|
||||||
|
//#int
|
||||||
|
//#_start ()
|
||||||
|
//#{
|
||||||
|
//# ..
|
||||||
|
//#}
|
|
@ -0,0 +1,137 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2016,2017,2018,2020,2022 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 sys_call)
|
||||||
|
{
|
||||||
|
asm ("mov____0x8(%rbp),%rax !-8");
|
||||||
|
asm ("syscall");
|
||||||
|
}
|
||||||
|
|
||||||
|
long
|
||||||
|
__sys_call1 (long sys_call, long one)
|
||||||
|
{
|
||||||
|
asm ("mov____0x8(%rbp),%rax !-8");
|
||||||
|
asm ("mov____0x8(%rbp),%rdi !-16");
|
||||||
|
asm ("syscall");
|
||||||
|
}
|
||||||
|
|
||||||
|
long
|
||||||
|
__sys_call2 (long sys_call, long one, long two)
|
||||||
|
{
|
||||||
|
asm ("mov____0x8(%rbp),%rax !-8");
|
||||||
|
asm ("mov____0x8(%rbp),%rdi !-16");
|
||||||
|
asm ("mov____0x8(%rbp),%rsi !-24");
|
||||||
|
asm ("syscall");
|
||||||
|
}
|
||||||
|
|
||||||
|
long
|
||||||
|
__sys_call3 (long sys_call, long one, long two, long three)
|
||||||
|
{
|
||||||
|
asm ("mov____0x8(%rbp),%rax !-8");
|
||||||
|
asm ("mov____0x8(%rbp),%rdi !-16");
|
||||||
|
asm ("mov____0x8(%rbp),%rsi !-24");
|
||||||
|
asm ("mov____0x8(%rbp),%rdx !-32");
|
||||||
|
asm ("syscall");
|
||||||
|
}
|
||||||
|
|
||||||
|
long
|
||||||
|
__sys_call4 (long sys_call, long one, long two, long three, long four)
|
||||||
|
{
|
||||||
|
asm ("mov____0x8(%rbp),%rax !-8");
|
||||||
|
asm ("mov____0x8(%rbp),%rdi !-16");
|
||||||
|
asm ("mov____0x8(%rbp),%rsi !-24");
|
||||||
|
asm ("mov____0x8(%rbp),%rdx !-32");
|
||||||
|
asm ("mov____0x8(%rbp),%r10 !-40");
|
||||||
|
asm ("syscall");
|
||||||
|
}
|
||||||
|
|
||||||
|
long
|
||||||
|
_sys_call (long 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 r = __sys_call1 (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 r = __sys_call2 (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 r = __sys_call3 (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 r = __sys_call4 (sys_call, one, two, three, four);
|
||||||
|
if (r < 0)
|
||||||
|
{
|
||||||
|
errno = -r;
|
||||||
|
r = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
errno = 0;
|
||||||
|
return r;
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
### Copyright (C) 2016 Jeremiah Orians
|
||||||
|
### Copyright (C) 2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
||||||
|
### This file is part of M2-Planet.
|
||||||
|
###
|
||||||
|
### M2-Planet 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.
|
||||||
|
###
|
||||||
|
### M2-Planet 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 M2-Planet. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
### stage0's hex2 format
|
||||||
|
### !<label> 1 byte relative
|
||||||
|
### $<label> 2 byte address
|
||||||
|
### @<label> 2 byte relative
|
||||||
|
### &<label> 4 byte address
|
||||||
|
### %<label> 4 byte relative
|
||||||
|
|
||||||
|
### if you wish to use this header, you need to add :ELF_end to the end of your
|
||||||
|
### M1 or hex2 files.
|
||||||
|
|
||||||
|
## ELF Header
|
||||||
|
|
||||||
|
: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
|
||||||
|
|
||||||
|
03 # e_ident[EI_OSABI] Set at 3 because FreeBSD is strict
|
||||||
|
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
|
||||||
|
|
||||||
|
&_start 00 00 00 00 # e_entry Address of the entry point
|
||||||
|
%ELF_program_headers>ELF_base 00 00 00 00 # e_phoff Address of program header table
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
: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 # 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
|
||||||
|
|
||||||
|
:ELF_text
|
|
@ -0,0 +1,101 @@
|
||||||
|
## Copyright (C) 2017 Jeremiah Orians
|
||||||
|
## This file is part of M2-Planet.
|
||||||
|
##
|
||||||
|
## M2-Planet 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.
|
||||||
|
##
|
||||||
|
## M2-Planet 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 M2-Planet. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
DEFINE ADD_IMMEDIATE_to_rax 4805
|
||||||
|
DEFINE ADD_IMMEDIATE_to_rbp 4881C5
|
||||||
|
DEFINE ADD_rax_to_rbx 4801C3
|
||||||
|
DEFINE ADD_rbp_to_rax 4801E8
|
||||||
|
DEFINE ADD_rbx_to_rax 4801D8
|
||||||
|
DEFINE AND_rax_rbx 4821D8
|
||||||
|
DEFINE CALL_IMMEDIATE E8
|
||||||
|
DEFINE CALL_rax FFD0
|
||||||
|
DEFINE CMP 4839C3
|
||||||
|
DEFINE COPY_rax_to_rcx 4889C1
|
||||||
|
DEFINE COPY_rax_to_rdi 4889C7
|
||||||
|
DEFINE COPY_rbx_to_rax 4889D8
|
||||||
|
DEFINE COPY_rbp_to_rax 4889E8
|
||||||
|
DEFINE COPY_rbx_to_rdi 4889DF
|
||||||
|
DEFINE COPY_rdi_to_rbp 4889FD
|
||||||
|
DEFINE COPY_rsp_to_rbp 4889E5
|
||||||
|
DEFINE COPY_RSP_to_RDI 4889E7
|
||||||
|
DEFINE CQTO 4899
|
||||||
|
DEFINE DIVIDE_rax_by_rbx_into_rax 48F7F3
|
||||||
|
DEFINE DIVIDES_rax_by_rbx_into_rax 48F7FB
|
||||||
|
DEFINE JUMP E9
|
||||||
|
DEFINE JUMP_EQ 0F84
|
||||||
|
DEFINE JUMP_NE 0F85
|
||||||
|
DEFINE LOAD_BASE_ADDRESS_rax 488D85
|
||||||
|
DEFINE LOAD_BYTE 480FBE00
|
||||||
|
DEFINE LOAD_BYTE_rbx 480FBE1B
|
||||||
|
DEFINE LOAD_EFFECTIVE_ADDRESS_rax 488D8424
|
||||||
|
DEFINE LOAD_EFFECTIVE_ADDRESS_rdi 488DBC24
|
||||||
|
DEFINE LOAD_EFFECTIVE_ADDRESS_rdx 488D9424
|
||||||
|
DEFINE LOAD_EFFECTIVE_ADDRESS_rsi 488DB424
|
||||||
|
DEFINE LOAD_IMMEDIATE_r10 48C7C2
|
||||||
|
DEFINE LOAD_IMMEDIATE_rax 48C7C0
|
||||||
|
DEFINE LOAD_IMMEDIATE_rbx 48C7C3
|
||||||
|
DEFINE LOAD_IMMEDIATE_rdi 48C7C7
|
||||||
|
DEFINE LOAD_IMMEDIATE_rdx 48C7C2
|
||||||
|
DEFINE LOAD_IMMEDIATE_rsi 48C7C6
|
||||||
|
DEFINE LOAD_INTEGER 488B00
|
||||||
|
DEFINE LOAD_INTEGER_rbx 488B1B
|
||||||
|
DEFINE LOAD_INTEGER_rdi 488B3F
|
||||||
|
DEFINE LOAD_INTEGER_rdx 488B12
|
||||||
|
DEFINE LOAD_INTEGER_rsi 488B36
|
||||||
|
DEFINE LOAD_RSP_IMMEDIATE_into_rax 488B8424
|
||||||
|
DEFINE MODULUS_rax_from_rbx_into_rbx 48F7F3
|
||||||
|
DEFINE MODULUSS_rax_from_rbx_into_rbx 48F7FB
|
||||||
|
DEFINE MOVE_rbx_to_rax 4889D8
|
||||||
|
DEFINE MOVE_rdx_to_rax 4889D0
|
||||||
|
DEFINE MOVEZX 480FB6C0
|
||||||
|
DEFINE MOVESX 4863C0
|
||||||
|
DEFINE MULTIPLY_rax_by_rbx_into_rax 48F7EB
|
||||||
|
DEFINE MULTIPLYS_rax_by_rbx_into_rax 48F7E3
|
||||||
|
DEFINE NULL 0000000000000000
|
||||||
|
DEFINE NOT_rax 48F7D0
|
||||||
|
DEFINE OR_rax_rbx 4809D8
|
||||||
|
DEFINE POP_RAX 58
|
||||||
|
DEFINE POP_RBP 5D
|
||||||
|
DEFINE POP_RBX 5B
|
||||||
|
DEFINE POP_RDI 5F
|
||||||
|
DEFINE PUSH_RAX 50
|
||||||
|
DEFINE PUSH_RBP 55
|
||||||
|
DEFINE PUSH_RBX 53
|
||||||
|
DEFINE PUSH_RDI 57
|
||||||
|
DEFINE RETURN C3
|
||||||
|
DEFINE SAL_rax_Immediate8 48C1E0
|
||||||
|
DEFINE SHL_rax_cl 48D3E0
|
||||||
|
DEFINE SAL_rax_cl 48D3F0
|
||||||
|
DEFINE SHR_rax_cl 48D3E8
|
||||||
|
DEFINE SAR_rax_cl 48D3F8
|
||||||
|
DEFINE SETA 0F97C0
|
||||||
|
DEFINE SETAE 0F93C0
|
||||||
|
DEFINE SETB 0F92C0
|
||||||
|
DEFINE SETBE 0F96C0
|
||||||
|
DEFINE SETE 0F94C0
|
||||||
|
DEFINE SETG 0F9FC0
|
||||||
|
DEFINE SETGE 0F9DC0
|
||||||
|
DEFINE SETL 0F9CC0
|
||||||
|
DEFINE SETLE 0F9EC0
|
||||||
|
DEFINE SETNE 0F95C0
|
||||||
|
DEFINE STORE_CHAR 8803
|
||||||
|
DEFINE STORE_INTEGER 488903
|
||||||
|
DEFINE SUBTRACT_rax_from_rbx_into_rbx 4829C3
|
||||||
|
DEFINE SYSCALL 0F05
|
||||||
|
DEFINE TEST 4885C0
|
||||||
|
DEFINE XCHG_rax_rbx 4893
|
||||||
|
DEFINE XOR_rbx_rax_into_rax 4831D8
|
|
@ -28,6 +28,7 @@ DEFINE add____$i32,%rdi 4881c7
|
||||||
DEFINE add____$i32,(%rax) 8100
|
DEFINE add____$i32,(%rax) 8100
|
||||||
DEFINE add____$i32,0x32(%rbp) 8185
|
DEFINE add____$i32,0x32(%rbp) 8185
|
||||||
DEFINE add____$i8,%rax 4883c0
|
DEFINE add____$i8,%rax 4883c0
|
||||||
|
DEFINE add____$i8,%rbp 4883c5
|
||||||
DEFINE add____$i8,%rdi 4883c7
|
DEFINE add____$i8,%rdi 4883c7
|
||||||
DEFINE add____$i8,%rsp 4883c4
|
DEFINE add____$i8,%rsp 4883c4
|
||||||
DEFINE add____$i8,(%rax) 8300
|
DEFINE add____$i8,(%rax) 8300
|
||||||
|
@ -115,6 +116,7 @@ DEFINE mov____%rbp,%rsp 4889ec
|
||||||
DEFINE mov____%rbp,0x8(%rbp) 48896d
|
DEFINE mov____%rbp,0x8(%rbp) 48896d
|
||||||
DEFINE mov____%rdi,%r8 4989f8
|
DEFINE mov____%rdi,%r8 4989f8
|
||||||
DEFINE mov____%rdi,%rax 4889f8
|
DEFINE mov____%rdi,%rax 4889f8
|
||||||
|
DEFINE mov____%rdi,%rbp 4889fd
|
||||||
DEFINE mov____%rdi,%rcx 4889f9
|
DEFINE mov____%rdi,%rcx 4889f9
|
||||||
DEFINE mov____%rdi,%rdi 4889ff
|
DEFINE mov____%rdi,%rdi 4889ff
|
||||||
DEFINE mov____%rdi,0x32 48893c25
|
DEFINE mov____%rdi,0x32 48893c25
|
||||||
|
|
Loading…
Reference in New Issue