src/main.rs is very simple:
Code: Select all
#![no_std]
#![no_main]
#![feature(global_asm)]
use core::panic::PanicInfo;
#[panic_handler]
fn on_panic(_info: &PanicInfo) -> ! {
loop {}
}
global_asm!(r#"
.section ".mbhdr"
mb_header:
.long 0xe85250d6
.long 0
.long mb_header_end - mb_header
.long -(0xe85250d6 + 0 + (mb_header_end - mb_header))
.short 0
.short 0
.long 8
mb_header_end:
.text
.globl start
.code32
start:
movl $0x2f4b2f4f, 0xb8000
hlt
"#);
Code: Select all
{
"arch": "x86_64",
"code-model": "kernel",
"cpu": "x86-64",
"data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128",
"disable-redzone": true,
"eliminate-frame-pointer": false,
"features": "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float",
"is-builtin": true,
"llvm-target": "x86_64-elf",
"max-atomic-width": 64,
"panic-strategy": "abort",
"os": "none",
"executables": true,
"linker-flavor": "ld.lld",
"linker": "rust-lld",
"pre-link-args": {
"ld.lld": ["-Tlinker.ld"]
},
"relocation-model": "static",
"target-pointer-width": "64"
}
Code: Select all
ENTRY(start)
SECTIONS {
. = 1M;
.boot :
{
*(.mbhdr)
}
.text :
{
*(.text)
}
/DISCARD/ :
{
*(.debug*)
}
}
Code: Select all
$ objdump -x target/x86_64_kernel/debug/rosd
target/x86_64_kernel/debug/rosd: file format elf64-x86-64
target/x86_64_kernel/debug/rosd
architecture: i386:x86-64, flags 0x00000012:
EXEC_P, HAS_SYMS
start address 0x0000000000000030
Program Header:
STACK off 0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**0
filesz 0x0000000000000000 memsz 0x0000000000000000 flags rw-
Sections:
Idx Name Size VMA LMA File off Algn
0 .boot 00000018 0000000000000000 0000000000000000 000000e8 2**0
CONTENTS, READONLY
1 .comment 00000013 0000000000000000 0000000000000000 00000100 2**0
CONTENTS, READONLY
2 .text 0000000b 0000000000000030 0000000000000030 000001f0 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
SYMBOL TABLE:
0000000000000000 l df *ABS* 0000000000000000 2x5qyqlxdq6xy7n9
0000000000000000 l .boot 0000000000000000 mb_header
0000000000000018 l .boot 0000000000000000 mb_header_end
0000000000000030 g .text 0000000000000000 start