code wiki / (root) / elf_writer.nx

elf_writer.nx

buildroot/runtime/elf_writer.nx

9296 B247 linesdepth 2pulls 2 transitivereach 27 importersview sourcekind librarytopic elf
docsdependenciesstructsconstsfunctions

about

elf_writer.nx -- emit a minimal RV64 Linux ELF executable. Library form: `write_elf(code, code_len, fd)` produces a statically- loadable ELF64 on `fd` that executes `code` when run. No linker, no libc, no gcc `as`. With this + nxasm + nxc2.nx we have the full binary-up chain in pure NishiLang. Layout: [0..64) ELF header (e_ehsize = 64) [64..120) Program header (PT_LOAD, 56 bytes) [120..120+N) Code -- N bytes of RV64 machine code Virtual address base = 0x10000 (standard for statically-linked Linux RV64). Entry point = 0x10000 + 120 so execution starts at the first code byte.

dependencies 1 imports · 25 importers

nx_syscalls.nx elf_writer.nx _offc_nxc_small.nx nx_nxasm_main.nx nx_nxc.nx nx_nxld.nx nx_smoke_elf_minimal.nx nx_smoke_nxc_pipeline10.nx nx_smoke_nxc_pipeline11.nx nx_smoke_nxc_pipeline12.nx nx_smoke_nxc_pipeline13.nx nx_smoke_nxc_pipeline15.nx

diagram shows first 10 each side; +0 more imports, +15 more importers in the complete lists below.

imports: nx_syscalls.nx

imported by: _offc_nxc_small.nxnx_nxasm_main.nxnx_nxc.nxnx_nxld.nxnx_smoke_elf_minimal.nxnx_smoke_nxc_pipeline10.nxnx_smoke_nxc_pipeline11.nxnx_smoke_nxc_pipeline12.nxnx_smoke_nxc_pipeline13.nxnx_smoke_nxc_pipeline15.nxnx_smoke_nxc_pipeline7.nxnx_smoke_nxc_pipeline8.nxnx_smoke_nxc_pipeline9.nxnxasm_main.nxnxc.nxnxld.nxsmoke_elf_minimal.nxsmoke_nxc_pipeline10.nxsmoke_nxc_pipeline11.nxsmoke_nxc_pipeline12.nxsmoke_nxc_pipeline13.nxsmoke_nxc_pipeline15.nxsmoke_nxc_pipeline7.nxsmoke_nxc_pipeline8.nxsmoke_nxc_pipeline9.nx

structs

none

consts

none

functions

20func put_u64_le(dst: *u8, off: i64, v: i64) -> i64
37func build_elf_image_at(out: *u8, code: *u8, code_len: i64,
called by 1: write_elf_at calls 1: put_u64_le
83func write_elf_at(code: *u8, code_len: i64, base_vaddr: i64,
109func build_elf_kernel_at(out: *u8, code: *u8, code_len: i64,
called by 1: write_elf_kernel_at calls 1: put_u64_le
154func write_elf_kernel_at(code: *u8, code_len: i64, base_vaddr: i64,
165func build_elf_image(out: *u8, code: *u8, code_len: i64) -> i64
called by 1: write_elf calls 1: put_u64_le
240func write_elf(code: *u8, code_len: i64, fd: i64) -> i64