faerie
Emit some object files, at your leisure:
let name = "test.o";
let file = create?;
let mut obj = new
.name
.finish;
// first we declare our symbolic references;
// it is a runtime error to define a symbol _without_ declaring it first
obj.declarations?;
// we now define our local functions and data
// 0000000000000000 <deadbeef>:
// 0: 55 push %rbp
// 1: 48 89 e5 mov %rsp,%rbp
// 4: 48 8b 05 00 00 00 00 mov 0x0(%rip),%rax # b <deadbeef+0xb>
// 7: R_X86_64_GOTPCREL DEADBEEF-0x4
// b: 8b 08 mov (%rax),%ecx
// d: 83 c1 01 add $0x1,%ecx
// 10: 89 c8 mov %ecx,%eax
// 12: 5d pop %rbp
// 13: c3 retq
obj.define?;
// main:
// 55 push %rbp
// 48 89 e5 mov %rsp,%rbp
// b8 00 00 00 00 mov $0x0,%eax
// e8 00 00 00 00 callq 0x0 <deadbeef>
// 89 c6 mov %eax,%esi
// 48 8d 3d 00 00 00 00 lea 0x0(%rip),%rdi # will be: deadbeef: 0x%x\n
// b8 00 00 00 00 mov $0x0,%eax
// e8 00 00 00 00 callq 0x3f <main+33> # printf
// b8 00 00 00 00 mov $0x0,%eax
// 5d pop %rbp
// c3 retq
obj.define?;
obj.define?;
// Next, we declare our relocations,
// which are _always_ relative to the `from` symbol
obj.link?;
obj.link?;
obj.link?;
obj.link?;
// Finally, we write which object file we desire
obj.?;
Will emit an object file like this:
:sunglasses: