diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.c | 6 | ||||
| -rw-r--r-- | src/note.s | 9 | ||||
| -rw-r--r-- | src/start.s | 17 |
3 files changed, 32 insertions, 0 deletions
| diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..83423bb --- /dev/null +++ b/src/main.c | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | int main(int argc, char** argv); | ||
| 2 | |||
| 3 | int main(int argc, char** argv) | ||
| 4 | { | ||
| 5 | return 0; | ||
| 6 | } | ||
| diff --git a/src/note.s b/src/note.s new file mode 100644 index 0000000..a8b606e --- /dev/null +++ b/src/note.s | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | .section .note.netbsd.ident, "a" # allocatable section. | ||
| 2 | .align 4 | ||
| 3 | .int 7 # namesz = "NetBSD" = 7 bytes. | ||
| 4 | .int 4 # descsz = version = 4 bytes. | ||
| 5 | .int 1 # type = ELF_NOTE_TYPE_NETBSD_TAG. | ||
| 6 | .ascii "NetBSD" # name. | ||
| 7 | .byte 0 # null term for name. | ||
| 8 | .long 110000000 # desc = 11.0 (netbsd ver). | ||
| 9 | .align 4 | ||
| diff --git a/src/start.s b/src/start.s new file mode 100644 index 0000000..58efed0 --- /dev/null +++ b/src/start.s | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | .section .text | ||
| 2 | .globl _start | ||
| 3 | .type _start, @function | ||
| 4 | _start: | ||
| 5 | xorq %rbp, %rbp # frame ptr (%rbp) = null. marks stack bottom. | ||
| 6 | |||
| 7 | movl (%rsp), %edi # argc = first 4 bytes of stack. | ||
| 8 | leaq 8(%rsp), %rsi # argv = address of first arg ptr. | ||
| 9 | |||
| 10 | call main # see main.c. | ||
| 11 | |||
| 12 | movl %eax, %edi # status = ret val. | ||
| 13 | movl $1, %eax # SYS_exit = 1. | ||
| 14 | syscall | ||
| 15 | |||
| 16 | .size _start, .-_start | ||
| 17 | hlt # if syscall fails hang. | ||
