elf_writer.nx
buildroot/runtime/elf_writer.nx
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
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
| 20 | func put_u64_le(dst: *u8, off: i64, v: i64) -> i64 |
| 37 | func build_elf_image_at(out: *u8, code: *u8, code_len: i64, |
| 83 | func write_elf_at(code: *u8, code_len: i64, base_vaddr: i64, |
| 109 | func build_elf_kernel_at(out: *u8, code: *u8, code_len: i64, |
| 154 | func write_elf_kernel_at(code: *u8, code_len: i64, base_vaddr: i64, |
| 165 | func build_elf_image(out: *u8, code: *u8, code_len: i64) -> i64 |
| 240 | func write_elf(code: *u8, code_len: i64, fd: i64) -> i64 called by 25: nxc_compilemainnxc_compilenxld_linkmainmain+19 calls 3: sys_mmapbuild_elf_imagesys_write |