Skip to content

v2.gen.x64 #

fn ElfObject.new #

fn ElfObject.new() &ElfObject

fn Gen.new #

fn Gen.new(mod &ssa.Module) &Gen

struct ElfObject #

struct ElfObject {
pub mut:
	text_data []u8
	data_data []u8
	rodata    []u8

	// Symbol Table
	symbols   []ElfSymbol
	str_table []u8

	// Relocations
	text_relocs []ElfRela

	// Section Names
	shstr_table []u8
}

fn (ElfObject) add_symbol #

fn (mut e ElfObject) add_symbol(name string, value u64, is_func bool, shndx u16) int

fn (ElfObject) add_undefined #

fn (mut e ElfObject) add_undefined(name string) int

fn (ElfObject) add_text_reloc #

fn (mut e ElfObject) add_text_reloc(offset u64, sym_idx int, type_ int, addend i64)

fn (ElfObject) write #

fn (mut e ElfObject) write(path string)

struct Gen #

struct Gen {
	mod &ssa.Module
mut:
	elf &ElfObject

	stack_map      map[int]int
	alloca_offsets map[int]int
	stack_size     int
	curr_offset    int

	block_offsets  map[int]int
	pending_labels map[int][]int

	// Register allocation
	reg_map   map[int]int
	used_regs []int
}

fn (Gen) gen #

fn (mut g Gen) gen()

fn (Gen) write_file #

fn (mut g Gen) write_file(path string)