v3.gen.arm64 #
ARM64 Instruction Encoding Helpers These functions provide type-safe instruction encoding for the ARM64 backend.
fn Gen.new #
fn Gen.new(m &ssa.Module) &Gen
new creates a Gen value for arm64.
fn Linker.new #
fn Linker.new(macho &MachOObject) &Linker
new creates a Linker value for arm64.
fn MachOObject.new #
fn MachOObject.new() &MachOObject
new creates a MachOObject value for arm64.
struct Gen #
struct Gen {
mut:
m &ssa.Module = unsafe { nil }
macho &MachOObject = unsafe { nil }
stack_offsets []int
alloca_offsets []int
alloca_sizes []int
stack_size int
block_offsets []int
pending_jmps []PendingJmp
fn_offsets map[string]int
string_cache map[string]int
cur_func_ret_type ssa.TypeID
cur_func_sret_offset int
}
Gen stores state for ARM64 code generation.
fn (Gen) gen #
fn (mut g Gen) gen()
gen supports gen handling for Gen.
fn (Gen) write_and_link #
fn (mut g Gen) write_and_link(output string)
write_and_link writes and link output for arm64.
struct Linker #
struct Linker {
macho &MachOObject
pub mut:
// Frameworks to link (e.g. ['Metal', 'Cocoa', 'QuartzCore'])
frameworks []string
mut:
// Output buffer
buf []u8
// Segment/section info
text_vmaddr u64
text_fileoff int
text_size int
data_vmaddr u64
data_fileoff int
data_size int
linkedit_off int
linkedit_size int
// External symbols needing binding
extern_syms []string
// GOT entries for external symbols
got_offset int // Offset within __DATA segment
got_size int
// Stubs for external function calls
stubs_offset int
stubs_size int
// Symbol to GOT index mapping
sym_to_got map[string]int
// Multi-dylib support: dylib paths and per-symbol ordinal mapping
dylibs []string // ['/usr/lib/libSystem.B.dylib', '/usr/lib/libobjc.A.dylib', ...]
sym_to_dylib map[string]int // symbol name → index into dylibs[] (ordinal = idx + 1)
// Code start offset (after header + load commands)
code_start int
}
Linker represents linker data used by arm64.
fn (Linker) link #
fn (mut l Linker) link(output_path string, entry_name string)
link supports link handling for Linker.
struct MachOObject #
struct MachOObject {
pub mut:
text_data []u8
str_data []u8
data_data []u8
relocs []RelocationInfo
symbols []Symbol
str_table []u8
sym_by_name map[string]int // symbol name → index in symbols
}
MachOObject represents mach oobject data used by arm64.
fn (MachOObject) add_symbol #
fn (mut m MachOObject) add_symbol(name string, addr u64, is_ext bool, sect u8) int
add_symbol updates add symbol state for MachOObject.
fn (MachOObject) add_undefined #
fn (mut m MachOObject) add_undefined(name string) int
add_undefined updates add undefined state for MachOObject.
fn (MachOObject) add_reloc #
fn (mut m MachOObject) add_reloc(addr int, sym_idx int, typ int, pcrel bool)
add_reloc updates add reloc state for MachOObject.
fn (MachOObject) write #
fn (mut m MachOObject) write(path string)
write supports write handling for MachOObject.