Created
July 24, 2016 02:45
-
-
Save JustAPerson/8583c562ebb4eff39b59a1414faae5bb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TARGET(elf32-i386) | |
INPUT(beta.o) /* assembly stage1 */ | |
INPUT(gamma.o) /* rust code */ | |
OUTPUT_ARCH(i386) | |
OUTPUT_FORMAT("binary") | |
SECTIONS | |
{ | |
/DISCARD/ : { | |
* (.eh_frame) | |
} | |
text 0x7c00 : | |
{ | |
beta.o (*) /* other assembly file, not related */ | |
gamma.o (.text.rust_boot) /* put this symbol first */ | |
gamma.o (*) | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note: using Steve Klabnik's floating point free libcore https://github.com/intermezzOS/libcore/ | |
// Libcore compiled with: | |
// cargo rustc --release --target i686-unknown-linux-gnu -- -C panic=abort | |
// Compiled with | |
// rustc --target i686-unknown-linux-gnu -C opt-level=3 -o bin/boot/gamma.o src/boot/gamma.rs -L libcore/target/i686-unknown-linux-gnu/release/ -C relocation-model=static -C panic=abort | |
// | |
// Linker output | |
// vos/bin/boot//gamma.o(gamma.0.o): In function `rust_boot': gamma.0.rs:(.text.rust_boot+0x86): undefined reference to `core::panicking::panic_bounds_check::ha826e5548fbc34dd' | |
#![crate_type="lib"] | |
#![feature(lang_items, asm, intrinsics, core_panic)] | |
#![no_std] | |
#[no_mangle] | |
pub fn rust_boot() -> ! { | |
unsafe { | |
let mut vga = ::core::slice::from_raw_parts_mut(0xb8000 as *mut u16, 80*25); | |
for bg in 0..16 { | |
for fg in 0..16 { | |
let index = (bg * 80 + fg) as usize; | |
vga[index] = (bg << 12) | (fg << 8) | ('a' as u16); | |
} | |
} | |
} | |
// prevent CPU executing past this point | |
// anything beyond this is likely an invalid instruction sequence | |
loop {} | |
} | |
// all of this is required due to no libstd | |
pub mod lang { | |
use core::fmt; | |
#[no_mangle] | |
pub fn __morestack() {} | |
#[lang = "panic_fmt"] | |
#[no_mangle] | |
pub extern fn rust_begin_panic(msg: fmt::Arguments, | |
file: &'static str, | |
line: u32) -> ! { | |
loop {} | |
} | |
#[lang="eh_personality"] | |
fn eh_personality() {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In archive bin/boot/gamma.o: | |
gamma.0.o: file format elf32-i386 | |
rw-r--r-- 0/0 1444 Dec 31 19:00 1969 gamma.0.o | |
architecture: i386, flags 0x00000011: | |
HAS_RELOC, HAS_SYMS | |
start address 0x00000000 | |
Sections: | |
Idx Name Size VMA LMA File off Algn | |
0 .text 00000000 00000000 00000000 00000034 2**2 | |
CONTENTS, ALLOC, LOAD, READONLY, CODE | |
1 .text.rust_boot 0000008a 00000000 00000000 00000040 2**4 | |
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE | |
2 .text.__morestack 00000001 00000000 00000000 000000d0 2**4 | |
CONTENTS, ALLOC, LOAD, READONLY, CODE | |
3 .text.rust_begin_unwind 00000002 00000000 00000000 000000e0 2**4 | |
CONTENTS, ALLOC, LOAD, READONLY, CODE | |
4 .text.rust_eh_personality 00000001 00000000 00000000 000000f0 2**4 | |
CONTENTS, ALLOC, LOAD, READONLY, CODE | |
5 .rodata.str2398 00000011 00000000 00000000 00000100 2**4 | |
CONTENTS, ALLOC, LOAD, READONLY, DATA | |
6 .rodata.panic_bounds_check_loc2399 0000000c 00000000 00000000 00000114 2**2 | |
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA | |
7 .note.GNU-stack 00000000 00000000 00000000 00000120 2**0 | |
CONTENTS, READONLY | |
8 .eh_frame 00000040 00000000 00000000 00000120 2**2 | |
CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA | |
SYMBOL TABLE: | |
00000000 l df *ABS* 00000000 gamma.0.rs | |
00000000 l O .rodata.panic_bounds_check_loc2399 0000000c panic_bounds_check_loc2399 | |
00000000 l O .rodata.str2398 00000011 str2398 | |
00000000 l d .text.rust_boot 00000000 .text.rust_boot | |
00000000 l d .rodata.str2398 00000000 .rodata.str2398 | |
00000000 l d .rodata.panic_bounds_check_loc2399 00000000 .rodata.panic_bounds_check_loc2399 | |
00000000 *UND* 00000000 _ZN4core9panicking18panic_bounds_check17ha826e5548fbc34ddE | |
00000000 g F .text.__morestack 00000001 __morestack | |
00000000 g F .text.rust_begin_unwind 00000002 rust_begin_unwind | |
00000000 g F .text.rust_boot 0000008a rust_boot | |
00000000 g F .text.rust_eh_personality 00000001 rust_eh_personality | |
Disassembly of section .text.rust_boot: | |
00000000 <rust_boot>: | |
0: 55 push ebp | |
1: 53 push ebx | |
2: 57 push edi | |
3: 56 push esi | |
4: 83 ec 0c sub esp,0xc | |
7: 31 c0 xor eax,eax | |
9: 0f 1f 80 00 00 00 00 nop DWORD PTR [eax+0x0] | |
10: 66 89 c1 mov cx,ax | |
13: 8d 41 01 lea eax,[ecx+0x1] | |
16: 0f b7 d1 movzx edx,cx | |
19: c1 e1 0c shl ecx,0xc | |
1c: c1 e2 04 shl edx,0x4 | |
1f: 8d 14 92 lea edx,[edx+edx*4] | |
22: 31 f6 xor esi,esi | |
24: 31 ff xor edi,edi | |
26: 66 2e 0f 1f 84 00 00 nop WORD PTR cs:[eax+eax*1+0x0] | |
2d: 00 00 00 | |
30: 8d 1c 17 lea ebx,[edi+edx*1] | |
33: 0f b7 db movzx ebx,bx | |
36: 81 fb cf 07 00 00 cmp ebx,0x7cf | |
3c: 77 34 ja 72 <rust_boot+0x72> | |
3e: 47 inc edi | |
3f: 89 f5 mov ebp,esi | |
41: 09 cd or ebp,ecx | |
43: 83 cd 61 or ebp,0x61 | |
46: 66 89 ac 1b 00 80 0b mov WORD PTR [ebx+ebx*1+0xb8000],bp | |
4d: 00 | |
4e: 81 c6 00 01 00 00 add esi,0x100 | |
54: 0f b7 df movzx ebx,di | |
57: 83 fb 10 cmp ebx,0x10 | |
5a: 72 d4 jb 30 <rust_boot+0x30> | |
5c: 0f b7 c8 movzx ecx,ax | |
5f: 83 f9 0f cmp ecx,0xf | |
62: 76 ac jbe 10 <rust_boot+0x10> | |
64: 66 66 66 2e 0f 1f 84 data16 data16 nop WORD PTR cs:[eax+eax*1+0x0] | |
6b: 00 00 00 00 00 | |
70: eb fe jmp 70 <rust_boot+0x70> | |
72: 89 5c 24 04 mov DWORD PTR [esp+0x4],ebx | |
76: c7 44 24 08 d0 07 00 mov DWORD PTR [esp+0x8],0x7d0 | |
7d: 00 | |
7e: c7 04 24 00 00 00 00 mov DWORD PTR [esp],0x0 | |
81: R_386_32 .rodata.panic_bounds_check_loc2399 | |
85: e8 fc ff ff ff call 86 <rust_boot+0x86> | |
86: R_386_PC32 _ZN4core9panicking18panic_bounds_check17ha826e5548fbc34ddE | |
Disassembly of section .text.__morestack: | |
00000000 <__morestack>: | |
0: c3 ret | |
Disassembly of section .text.rust_begin_unwind: | |
00000000 <rust_begin_unwind>: | |
0: eb fe jmp 0 <rust_begin_unwind> | |
Disassembly of section .text.rust_eh_personality: | |
00000000 <rust_eh_personality>: | |
0: c3 ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment