From 848c0c6a3fcd3a05a2d8d5fbb3eb550bc423f807 Mon Sep 17 00:00:00 2001 From: Druid520 Date: Mon, 17 Aug 2026 10:47:46 -0700 Subject: ADD: charge basics stuff. --- src/main.c | 6 ++++++ src/note.s | 9 +++++++++ src/start.s | 17 +++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 src/main.c create mode 100644 src/note.s create mode 100644 src/start.s (limited to 'src') 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 @@ +int main(int argc, char** argv); + +int main(int argc, char** argv) +{ + return 0; +} 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 @@ +.section .note.netbsd.ident, "a" # allocatable section. + .align 4 + .int 7 # namesz = "NetBSD" = 7 bytes. + .int 4 # descsz = version = 4 bytes. + .int 1 # type = ELF_NOTE_TYPE_NETBSD_TAG. + .ascii "NetBSD" # name. + .byte 0 # null term for name. + .long 110000000 # desc = 11.0 (netbsd ver). + .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 @@ +.section .text +.globl _start +.type _start, @function +_start: + xorq %rbp, %rbp # frame ptr (%rbp) = null. marks stack bottom. + + movl (%rsp), %edi # argc = first 4 bytes of stack. + leaq 8(%rsp), %rsi # argv = address of first arg ptr. + + call main # see main.c. + + movl %eax, %edi # status = ret val. + movl $1, %eax # SYS_exit = 1. + syscall + + .size _start, .-_start + hlt # if syscall fails hang. -- cgit 1.4.1