porting: Add x86_64 scaffold: exit and write in assembly.
* lib/x86_64-mes-gcc/exit-42.S: New file. * lib/x86_64-mes-gcc/hello-mes.S: New file. * lib/x86_64-mes/elf64-0exit-42.hex2: New file. * lib/x86_64-mes/elf64-0hello-mes.hex2: New file. * lib/x86_64-mes/elf64-body-exit-42.hex2: Rewrite.. * lib/x86_64-mes/elf64-body-hello-mes.hex2: * lib/x86_64-mes/elf64-0header.hex2: Fix copyright header. * lib/x86_64-mes/elf64-header.hex2: Likewise. * lib/x86_64-mes/elf-0footer.hex2: Remove.
This commit is contained in:
parent
fbe0b2eef8
commit
9f60920538
46
lib/x86_64-mes-gcc/exit-42.S
Normal file
46
lib/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
lib/x86_64-mes-gcc/hello-mes.S
Normal file
58
lib/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
|
|
@ -1,26 +0,0 @@
|
||||||
### 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>
|
|
||||||
|
|
||||||
:ELF_end
|
|
36
lib/x86_64-mes/elf64-0exit-42.hex2
Normal file
36
lib/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
|
|
@ -1,28 +1,36 @@
|
||||||
### Copyright (C) 2016 Jeremiah Orians
|
### Copyright (C) 2016 Jeremiah Orians
|
||||||
### Copyright (C) 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
### Copyright (C) 2017,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
### This file is part of stage0.
|
|
||||||
###
|
###
|
||||||
### stage0 is free software: you can redistribute it and/or modify
|
### This file is part of GNU Mes.
|
||||||
### 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,
|
### GNU Mes is free software; you can redistribute it and/or modify it
|
||||||
### but WITHOUT ANY WARRANTY; without even the implied warranty of
|
### 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
|
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
### GNU General Public License for more details.
|
### GNU General Public License for more details.
|
||||||
###
|
###
|
||||||
### You should have received a copy of the GNU General Public License
|
### You should have received a copy of the GNU General Public License
|
||||||
### along with stage0. If not, see <http://www.gnu.org/licenses/>.
|
### along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
### stage0's hex2 format for x86_64
|
### Commentary:
|
||||||
### !<label> 1 byte relative
|
|
||||||
### $<label> 2 byte address
|
# elf64-0header.hex2: Simplest 64 bit elf header in hex2. Only a text
|
||||||
### @<label> 2 byte relative
|
# segment, no data segment, no symbol tables.
|
||||||
### &<label> 4 byte address
|
|
||||||
### %<label> 4 byte relative
|
# stage0's hex2 format for x86_64
|
||||||
### local_<label> function-local
|
# !<label> 1 byte relative
|
||||||
### string_<index> string #<index>
|
# $<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
|
:ELF_base
|
||||||
7F 45 4C 46 # e_ident[EI_MAG0-3] ELF's magic number
|
7F 45 4C 46 # e_ident[EI_MAG0-3] ELF's magic number
|
||||||
|
@ -58,11 +66,6 @@
|
||||||
|
|
||||||
00 00 # e_shstrndx index of the section names
|
00 00 # e_shstrndx index of the section names
|
||||||
|
|
||||||
# @34
|
|
||||||
00 00 00 00
|
|
||||||
00 00 00 00
|
|
||||||
00 00 00 00
|
|
||||||
|
|
||||||
# @40
|
# @40
|
||||||
:ELF_program_headers
|
:ELF_program_headers
|
||||||
:ELF_program_header__text
|
:ELF_program_header__text
|
||||||
|
@ -75,4 +78,6 @@
|
||||||
%ELF_end>ELF_base 00 00 00 00 # ph_memsz
|
%ELF_end>ELF_base 00 00 00 00 # ph_memsz
|
||||||
01 00 00 00 00 00 00 00 # ph_align
|
01 00 00 00 00 00 00 00 # ph_align
|
||||||
|
|
||||||
|
00 00 00 00 00 00 00 00 # align to @80
|
||||||
|
# @80
|
||||||
:ELF_text
|
:ELF_text
|
||||||
|
|
52
lib/x86_64-mes/elf64-0hello-mes.hex2
Normal file
52
lib/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
|
|
@ -1,47 +1,51 @@
|
||||||
### Copyright (C) 2017, 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
### GNU Mes --- Maxwell Equations of Software
|
||||||
### This file is part of stage0.
|
### Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
###
|
###
|
||||||
### stage0 is free software: you can redistribute it and/or modify
|
### This file is part of GNU Mes.
|
||||||
### 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,
|
### GNU Mes is free software; you can redistribute it and/or modify it
|
||||||
### but WITHOUT ANY WARRANTY; without even the implied warranty of
|
### 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
|
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
### GNU General Public License for more details.
|
### GNU General Public License for more details.
|
||||||
###
|
###
|
||||||
### You should have received a copy of the GNU General Public License
|
### You should have received a copy of the GNU General Public License
|
||||||
### along with stage0. If not, see <http://www.gnu.org/licenses/>.
|
### along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
### stage0's hex2 format for x86_64
|
### Commentary:
|
||||||
### !<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>
|
|
||||||
|
|
||||||
### elf64-body-exit-42.hex2: 64 bit elf body in hex2 for `exit 42'
|
# 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.
|
||||||
|
|
||||||
# @200
|
# This ELF binary contains a symbol table, which means that objdump and
|
||||||
|
# gdb can be used to inspect and debug.
|
||||||
|
|
||||||
|
### Code:
|
||||||
|
|
||||||
|
# @300
|
||||||
:ELF_text
|
:ELF_text
|
||||||
:_start
|
:_start
|
||||||
# exit(42)
|
# exit(42)
|
||||||
e8 %main # callq +11 <main>
|
e8 %main # call +11 <main>
|
||||||
00 00 00
|
00 00 00
|
||||||
00 00 00 00
|
00 00 00 00
|
||||||
00 00 00 00
|
00 00 00 00
|
||||||
|
|
||||||
# @210
|
# @310
|
||||||
:main
|
:main
|
||||||
48 c7 c7 2a 00 00 00 # mov $42,%rdi
|
48 b8 3c 00 00 00 00 00 00 00 # movabs $0x3c,%rax
|
||||||
48 c7 c0 3c 00 00 00 # mov $0x3c,%rax
|
48 bf 2a 00 00 00 00 00 00 00 # movabs $42,%rdi
|
||||||
0f 05 # syscall
|
0f 05 # syscall
|
||||||
|
f4 # hlt
|
||||||
|
|
||||||
00 00 00 00
|
00 00 00 00 00 00 00 00 00 # align to 330
|
||||||
|
|
||||||
# @220
|
# @330
|
||||||
:ELF_data
|
:ELF_data
|
||||||
65 78 69 74 34 32 20 64 61 74 61 20 68 65 72 65 # exit42 data here"
|
65 78 69 74 34 32 20 64 61 74 61 20 68 65 72 65 # exit42 data here"
|
||||||
|
00
|
||||||
|
|
63
lib/x86_64-mes/elf64-body-hello-mes.hex2
Normal file
63
lib/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
|
|
@ -1,28 +1,36 @@
|
||||||
### Copyright (C) 2016 Jeremiah Orians
|
### Copyright (C) 2016 Jeremiah Orians
|
||||||
### Copyright (C) 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
### Copyright (C) 2017,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||||
### This file is part of stage0.
|
|
||||||
###
|
###
|
||||||
### stage0 is free software: you can redistribute it and/or modify
|
### This file is part of GNU Mes.
|
||||||
### 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,
|
### GNU Mes is free software; you can redistribute it and/or modify it
|
||||||
### but WITHOUT ANY WARRANTY; without even the implied warranty of
|
### 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
|
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
### GNU General Public License for more details.
|
### GNU General Public License for more details.
|
||||||
###
|
###
|
||||||
### You should have received a copy of the GNU General Public License
|
### You should have received a copy of the GNU General Public License
|
||||||
### along with stage0. If not, see <http://www.gnu.org/licenses/>.
|
### along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
### stage0's hex2 format for x86_64
|
### Commentary:
|
||||||
### !<label> 1 byte relative
|
|
||||||
### $<label> 2 byte address
|
# elf64-header.hex2: 64 bit elf header in hex2, with text segment, data
|
||||||
### @<label> 2 byte relative
|
# segment and symbol tables.
|
||||||
### &<label> 4 byte address
|
|
||||||
### %<label> 4 byte relative
|
# stage0's hex2 format for x86_64
|
||||||
### local_<label> function-local
|
# !<label> 1 byte relative
|
||||||
### string_<index> string #<index>
|
# $<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
|
:ELF_base
|
||||||
7F 45 4c 46 # e_ident[EI_MAG0-3] ELF's magic number
|
7F 45 4c 46 # e_ident[EI_MAG0-3] ELF's magic number
|
||||||
|
|
Loading…
Reference in a new issue