selfhost: mirror writable .data + R_X86_64_64 across the wwstage
Bring the wwstage toolchain to parity with C-side DATAW / DATAR /
.data / .rela.data support. With this, w6c_ww + w6a_ww + w6l_ww can
compile, assemble and link `let g: str = "lit";` (and the scalar /
str / slice / struct globals that landed earlier) end-to-end, with
output that's byte-identical to the C-side pipeline.
w6a (types.ww / parse.ww / asm.ww / obj.ww):
- A_DATAW + A_DATAR opcodes; parser learns `name+disp(SB)`;
A_DATAR records an R_X86_64_64 reloc in .data via the new
addrelocdata helper; areloc gains a `section` flag and asym
an `isdata` flag; obj.ww splits relocs into .rela.text /
.rela.data, emits .data PROGBITS + .rela.data conditionally,
and shuffles section indices the same way cmd/w6a/obj.c does
so byte output stays identical when no DATAW/DATAR are used.
w6l (sym.ww / obj.ww / pass.ww / out.ww / dynout.ww / main.ww):
- lrel grows `section`; lsym grows `indata`; lobj tracks
dataoff / datasize; lnk grows combined .data buffer;
- obj.ww loads .data and .rela.data, registers data symbols
with indata=1 and val shifted by the input's data_off, and
the archive scanner includes both .text and .data globals;
- pass.ww adds R_X86_64_64 (patch 8 bytes in .text or .data
with sym_va + addend); relocate's signature becomes
(textva, datava);
- out.ww emits a second PT_LOAD (R+W) when datalen > 0, with
.data at the page-aligned offset after .text;
- dynout.ww refuses .data + -l/-L cleanly (matches the C-side
error message);
- main.ww computes text_va / data_va and passes both to
relocate.
wcc cgen (cgen.ww / cgendecl.ww):
- letpreintern walks top-level str-lets and interns the strlit
BEFORE emitdatasection emits its DATA row, so emitletdataw
can later look up the same label;
- emitletdataw's 16B branch detects non-empty strlit init and
emits the 8-zero + 8-LE-len DATAW plus a DATAR slot+0,strlit
reloc, mirroring cmd/w6c/cgen.c.
Verified: `wwdump_ww -c` byte-matches `w6c` on a `let g: str =
"hello world\n";` fixture; `w6a_ww` and `w6l_ww` produce a
binary byte-identical to the C-side pipeline that runs and
prints "hello world". Bootstrap fixed-point holds (ww2 == ww3 ==
ww4), 26/26 tests green.
This commit is contained in:
@@ -459,6 +459,13 @@ def A_JNZ: i32 = 58;
|
||||
|
||||
def A_SYSCALL: i32 = 59;
|
||||
|
||||
// Writable data + reloc-only data. Mirror cmd/w6c/6.out.h.
|
||||
// A_DATAW: bytes land in .data (RW) instead of .text.
|
||||
// A_DATAR: record an R_X86_64_64 reloc at a .data slot, patched
|
||||
// to a target symbol's runtime VA at link time.
|
||||
def A_DATAW: i32 = 60;
|
||||
def A_DATAR: i32 = 61;
|
||||
|
||||
// ---- structs (mirror cmd/w6a/a.h) --------------------------------------
|
||||
|
||||
type aoperand = struct {
|
||||
@@ -487,14 +494,16 @@ type asym = struct {
|
||||
name: str,
|
||||
defined: i32,
|
||||
istext: i32,
|
||||
isdata: i32, // mutually exclusive with istext; DATAW symbols
|
||||
isglobal: i32,
|
||||
addr: u64,
|
||||
addr: u64, // offset within its section (.text or .data)
|
||||
idx: i32,
|
||||
snext: *asym,
|
||||
};
|
||||
|
||||
type areloc = struct {
|
||||
off: u64,
|
||||
section: i32, // 0 = .text, 1 = .data
|
||||
kind: i32,
|
||||
asy: *asym,
|
||||
addend: i64,
|
||||
@@ -522,6 +531,14 @@ type asm_ = struct {
|
||||
textcap: u64,
|
||||
textlen: u64,
|
||||
|
||||
// Writable .data. Empty unless any DATAW directive was seen;
|
||||
// obj.ww emits the extra section conditionally so .o output
|
||||
// stays byte-identical for inputs that don't use DATAW (test
|
||||
// 991 byte-diff invariant).
|
||||
data: *u8,
|
||||
datacap: u64,
|
||||
datalen: u64,
|
||||
|
||||
syms: *asym,
|
||||
relocs: *areloc,
|
||||
fixups: *afixup,
|
||||
@@ -686,6 +703,8 @@ fn opcodelookup(p: *u8, n: u64) i32 = {
|
||||
if (streqlit(p, n, "SYSCALL")) { return A_SYSCALL; };
|
||||
if (streqlit(p, n, "TEXT")) { return A_TEXT; };
|
||||
if (streqlit(p, n, "DATA")) { return A_DATA; };
|
||||
if (streqlit(p, n, "DATAW")) { return A_DATAW; };
|
||||
if (streqlit(p, n, "DATAR")) { return A_DATAR; };
|
||||
return A_NOP;
|
||||
};
|
||||
|
||||
@@ -891,13 +910,25 @@ fn parseoperand(a: *asm_, p: *u8, offin: u64, n: u64, out: *aoperand) u64 = {
|
||||
return after;
|
||||
};
|
||||
|
||||
// IDENT — register, symbol(SB), or branch label
|
||||
// IDENT — register, symbol(SB), symbol+disp(SB), or branch label
|
||||
if (isidstart(c0: i32)) {
|
||||
let istart: u64 = off;
|
||||
for (off < n) {
|
||||
if (isidcont(p[off]: i32)) { off += 1u64; continue; };
|
||||
off = off; off += 0u64; // loop break
|
||||
let in_: u64 = off - istart;
|
||||
// Optional `+disp` between the ident and `(SB)`. Used
|
||||
// by DATAR to address bytes within a previously-defined
|
||||
// .data slot (e.g. `DATAR s+8(SB),...`).
|
||||
let symdisp: i64 = 0i64;
|
||||
if (off < n) { if (p[off] == 43u8) { // '+'
|
||||
off += 1u64;
|
||||
let v: i64;
|
||||
let used: u64;
|
||||
v, used = parsenum(p + off, n - off);
|
||||
symdisp = v;
|
||||
off += used;
|
||||
};};
|
||||
// IDENT(SB) — external
|
||||
if (off < n) { if (p[off] == 40u8) { // '('
|
||||
let rstart: u64 = off + 1u64;
|
||||
@@ -910,6 +941,7 @@ fn parseoperand(a: *asm_, p: *u8, offin: u64, n: u64, out: *aoperand) u64 = {
|
||||
if (r == D_PSB) {
|
||||
out.atype = D_EXTERN;
|
||||
out.asym = dupstr(a.a, p + istart, in_);
|
||||
out.offset = symdisp;
|
||||
} else {
|
||||
out.atype = D_INDIR;
|
||||
out.reg = r;
|
||||
@@ -1059,8 +1091,9 @@ export fn parse(a: *asm_) i32 = {
|
||||
a.line += 1; continue;
|
||||
};
|
||||
|
||||
if (opc == A_DATA) {
|
||||
// DATA name(SB),"escaped bytes" — find first '(' as end of name.
|
||||
if (opc == A_DATA || opc == A_DATAW) {
|
||||
// DATA / DATAW name(SB),"escaped bytes" — same syntax,
|
||||
// different destination section (.text vs .data).
|
||||
let q: u64 = r0;
|
||||
let lparen: u64 = n;
|
||||
let scand: bool = true;
|
||||
@@ -1209,8 +1242,9 @@ export fn emitu32(a: *asm_, v: u32) void = {
|
||||
};
|
||||
|
||||
export fn addreloc(a: *asm_, off: u64, kind: i32, s: *asym, add: i64) void = {
|
||||
let r: *areloc = amalloc(a.a, 48u64): *areloc;
|
||||
let r: *areloc = amalloc(a.a, 64u64): *areloc;
|
||||
r.off = off;
|
||||
r.section = 0; // .text
|
||||
r.kind = kind;
|
||||
r.asy = s;
|
||||
r.addend = add;
|
||||
@@ -1218,6 +1252,37 @@ export fn addreloc(a: *asm_, off: u64, kind: i32, s: *asym, add: i64) void = {
|
||||
a.relocs = r;
|
||||
};
|
||||
|
||||
// Record a relocation that lives in the .data section. Used by
|
||||
// DATAR to patch a 64-bit slot with a symbol's runtime VA. obj.ww
|
||||
// separates these into .rela.data when emitting the .o.
|
||||
export fn addrelocdata(a: *asm_, off: u64, kind: i32, s: *asym, add: i64) void = {
|
||||
let r: *areloc = amalloc(a.a, 64u64): *areloc;
|
||||
r.off = off;
|
||||
r.section = 1; // .data
|
||||
r.kind = kind;
|
||||
r.asy = s;
|
||||
r.addend = add;
|
||||
r.rnext = a.relocs;
|
||||
a.relocs = r;
|
||||
};
|
||||
|
||||
// Append one byte to the writable .data buffer. Mirrors emitbyte
|
||||
// but targets a.data instead of a.text.
|
||||
export fn emitdatabyte(a: *asm_, b: u8) void = {
|
||||
if (a.datalen + 1u64 > a.datacap) {
|
||||
let nc: u64 = a.datacap;
|
||||
if (nc == 0u64) { nc = 256u64; };
|
||||
nc = nc * 2u64;
|
||||
let nb: *u8 = os.alloc(nc): *u8;
|
||||
let i: u64 = 0u64;
|
||||
for (i < a.datalen) { nb[i] = a.data[i]; i += 1u64; };
|
||||
a.data = nb;
|
||||
a.datacap = nc;
|
||||
};
|
||||
a.data[a.datalen] = b;
|
||||
a.datalen += 1u64;
|
||||
};
|
||||
|
||||
// ---- register codes ----------------------------------------------------
|
||||
|
||||
// Low 3 bits of register encoding.
|
||||
@@ -1441,6 +1506,38 @@ export fn encode(a: *asm_) i32 = {
|
||||
for (i < p.nbytes) { emitbyte(a, p.bytes[i]); i += 1u64; };
|
||||
p = p.link; continue;
|
||||
};
|
||||
if (op == A_DATAW) {
|
||||
// Writable variant: bytes go into .data instead of
|
||||
// .text. obj.ww emits the extra section conditionally
|
||||
// on datalen > 0 so .o output stays byte-identical
|
||||
// for inputs that don't use DATAW.
|
||||
let s: *asym = intern(a, p.to.asym);
|
||||
s.defined = 1;
|
||||
s.isdata = 1;
|
||||
s.isglobal = 1;
|
||||
s.addr = a.datalen;
|
||||
let i: u64 = 0u64;
|
||||
for (i < p.nbytes) { emitdatabyte(a, p.bytes[i]); i += 1u64; };
|
||||
p = p.link; continue;
|
||||
};
|
||||
if (op == A_DATAR) {
|
||||
// DATAR slot+off(SB), target(SB) — record an
|
||||
// R_X86_64_64 relocation at slot+off in .data
|
||||
// pointing at target. Slot must already be defined
|
||||
// by a prior DATAW.
|
||||
let holder: *asym = intern(a, p.from.asym);
|
||||
if (holder.defined == 0) {
|
||||
p = p.link; continue;
|
||||
};
|
||||
if (holder.isdata == 0) {
|
||||
p = p.link; continue;
|
||||
};
|
||||
let target: *asym = intern(a, p.to.asym);
|
||||
let reloff: u64 = holder.addr + p.from.offset: u64;
|
||||
addrelocdata(a, reloff, 1 /* R_X86_64_64 */,
|
||||
target, 0i64);
|
||||
p = p.link; continue;
|
||||
};
|
||||
if (op == A_RET) {
|
||||
emitbyte(a, 195u8); // 0xC3
|
||||
p = p.link; continue;
|
||||
@@ -1902,12 +1999,14 @@ def SHT_SYMTAB_C: u32 = 2u32;
|
||||
def SHT_STRTAB_C: u32 = 3u32;
|
||||
def SHT_RELA_C: u32 = 4u32;
|
||||
|
||||
def SHF_WRITE: u64 = 1u64;
|
||||
def SHF_ALLOC: u64 = 2u64;
|
||||
def SHF_EXECINSTR: u64 = 4u64;
|
||||
def SHF_INFO_LINK: u64 = 64u64; // 0x40
|
||||
|
||||
def STB_GLOBAL: u8 = 1u8;
|
||||
def STT_NOTYPE: u8 = 0u8;
|
||||
def STT_OBJECT: u8 = 1u8;
|
||||
def STT_FUNC: u8 = 2u8;
|
||||
|
||||
// Sizes of fixed structures.
|
||||
@@ -1987,15 +2086,56 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
|
||||
let str_: buf; bufinit(&str_, a.a);
|
||||
let sym: buf; bufinit(&sym, a.a);
|
||||
let rela: buf; bufinit(&rela, a.a);
|
||||
let relad: buf; bufinit(&relad, a.a);
|
||||
|
||||
// Index 0 = empty.
|
||||
let zero: u8 = 0u8;
|
||||
bufputb(&shstr, &zero, 1u64);
|
||||
bufputb(&str_, &zero, 1u64);
|
||||
|
||||
// Section name offsets.
|
||||
let hasdata: bool = a.datalen > 0u64;
|
||||
let hasdatarelocs: bool = false;
|
||||
let rscan: *areloc = a.relocs;
|
||||
for (rscan != nil) {
|
||||
if (rscan.section == 1) { hasdatarelocs = true; };
|
||||
rscan = rscan.rnext;
|
||||
};
|
||||
|
||||
// Section indices (mirror cmd/w6a/obj.c):
|
||||
// without data, without data-relocs:
|
||||
// 1=.text 2=.rela.text 3=.symtab 4=.strtab 5=.shstrtab
|
||||
// with data, no data-relocs:
|
||||
// 1=.text 2=.rela.text 3=.data 4=.symtab 5=.strtab 6=.shstrtab
|
||||
// with data + data-relocs:
|
||||
// 1=.text 2=.rela.text 3=.data 4=.rela.data 5=.symtab
|
||||
// 6=.strtab 7=.shstrtab
|
||||
let SH_TEXT: u16 = 1u16;
|
||||
let SH_DATA: u16 = 0u16;
|
||||
let SH_RELAD: u16 = 0u16;
|
||||
let SH_SYMTAB: u16 = 3u16;
|
||||
if (hasdata) {
|
||||
SH_DATA = 3u16;
|
||||
if (hasdatarelocs) {
|
||||
SH_RELAD = 4u16;
|
||||
SH_SYMTAB = 5u16;
|
||||
} else {
|
||||
SH_SYMTAB = 4u16;
|
||||
};
|
||||
};
|
||||
let SH_STRTAB: u16 = SH_SYMTAB + 1u16;
|
||||
let SH_SHSTR: u16 = SH_STRTAB + 1u16;
|
||||
|
||||
// Section name offsets. Append .data / .rela.data only when
|
||||
// used so the .shstrtab buffer stays byte-identical for the
|
||||
// no-DATAW case (test 991 byte-diff invariant).
|
||||
let shntext: u32 = bufputcstr(&shstr, ".text");
|
||||
let shnrela: u32 = bufputcstr(&shstr, ".rela.text");
|
||||
let shndata: u32 = 0u32;
|
||||
let shnrelad: u32 = 0u32;
|
||||
if (hasdata) { shndata = bufputcstr(&shstr, ".data"); };
|
||||
if (hasdata) { if (hasdatarelocs) {
|
||||
shnrelad = bufputcstr(&shstr, ".rela.data");
|
||||
};};
|
||||
let shnsymtab: u32 = bufputcstr(&shstr, ".symtab");
|
||||
let shnstrtab: u32 = bufputcstr(&shstr, ".strtab");
|
||||
let shnshstrtab: u32 = bufputcstr(&shstr, ".shstrtab");
|
||||
@@ -2006,8 +2146,6 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
|
||||
for (zi < 24) { zsym[zi] = 0u8; zi += 1; };
|
||||
bufputb(&sym, zsym.ptr, 24u64);
|
||||
|
||||
let SH_TEXT: u16 = 1u16;
|
||||
|
||||
// Build symbols.
|
||||
let idx: i32 = 1;
|
||||
let s: *asym = a.syms;
|
||||
@@ -2018,8 +2156,13 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
|
||||
let stname: u32 = bufputcstr(&str_, s.name);
|
||||
wru32(entry.ptr, 0u64, stname);
|
||||
if (s.defined != 0) {
|
||||
wru8(entry.ptr, 4u64, ((STB_GLOBAL << 4u8) | STT_FUNC));
|
||||
wru16(entry.ptr, 6u64, SH_TEXT);
|
||||
if (s.isdata != 0) {
|
||||
wru8(entry.ptr, 4u64, ((STB_GLOBAL << 4u8) | STT_OBJECT));
|
||||
wru16(entry.ptr, 6u64, SH_DATA);
|
||||
} else {
|
||||
wru8(entry.ptr, 4u64, ((STB_GLOBAL << 4u8) | STT_FUNC));
|
||||
wru16(entry.ptr, 6u64, SH_TEXT);
|
||||
};
|
||||
wru64(entry.ptr, 8u64, s.addr);
|
||||
} else {
|
||||
wru8(entry.ptr, 4u64, ((STB_GLOBAL << 4u8) | STT_NOTYPE));
|
||||
@@ -2031,7 +2174,7 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
|
||||
s = s.snext;
|
||||
};
|
||||
|
||||
// Build relocations.
|
||||
// Build relocations — split into text vs data buffers.
|
||||
let r: *areloc = a.relocs;
|
||||
for (r != nil) {
|
||||
let entry: [24]u8;
|
||||
@@ -2039,7 +2182,11 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
|
||||
let rinfo: u64 = (r.asy.idx: u64 << 32u64) | (r.kind: u64 & 4294967295u64);
|
||||
wru64(entry.ptr, 8u64, rinfo);
|
||||
wru64(entry.ptr, 16u64, r.addend: u64);
|
||||
bufputb(&rela, entry.ptr, 24u64);
|
||||
if (r.section == 1) {
|
||||
bufputb(&relad, entry.ptr, 24u64);
|
||||
} else {
|
||||
bufputb(&rela, entry.ptr, 24u64);
|
||||
};
|
||||
r = r.rnext;
|
||||
};
|
||||
|
||||
@@ -2047,12 +2194,20 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
|
||||
let off: u64 = EHDR_SZ;
|
||||
let offtext: u64 = off; off = off + a.textlen;
|
||||
let offrela: u64 = off; off = off + rela.n;
|
||||
let offdata: u64 = off; if (hasdata) { off = off + a.datalen; };
|
||||
let offrelad: u64 = off; if (hasdata) { if (hasdatarelocs) {
|
||||
off = off + relad.n;
|
||||
};};
|
||||
let offsym: u64 = off; off = off + sym.n;
|
||||
let offstr: u64 = off; off = off + str_.n;
|
||||
let offshstr: u64 = off; off = off + shstr.n;
|
||||
for ((off & 7u64) != 0u64) { off += 1u64; };
|
||||
let offshdr: u64 = off;
|
||||
let NSECT: u16 = 6u16;
|
||||
if (hasdata) {
|
||||
if (hasdatarelocs) { NSECT = 8u16; }
|
||||
else { NSECT = 7u16; };
|
||||
};
|
||||
|
||||
// ---- Ehdr ----
|
||||
let eh: [64]u8;
|
||||
@@ -2077,7 +2232,7 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
|
||||
wru16(eh.ptr, 56u64, 0u16); // e_phnum
|
||||
wru16(eh.ptr, 58u64, 64u16); // e_shentsize
|
||||
wru16(eh.ptr, 60u64, NSECT); // e_shnum
|
||||
wru16(eh.ptr, 62u64, 5u16); // e_shstrndx
|
||||
wru16(eh.ptr, 62u64, SH_SHSTR); // e_shstrndx
|
||||
|
||||
if (!wrn(fd, eh.ptr, 64u64, 64i64)) { return -1; };
|
||||
if (a.textlen > 0u64) {
|
||||
@@ -2086,6 +2241,16 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
|
||||
if (rela.n > 0u64) {
|
||||
if (!wrn(fd, rela.p, rela.n, rela.n: i64)) { return -1; };
|
||||
};
|
||||
if (hasdata) {
|
||||
if (a.datalen > 0u64) {
|
||||
if (!wrn(fd, a.data, a.datalen, a.datalen: i64)) { return -1; };
|
||||
};
|
||||
if (hasdatarelocs) {
|
||||
if (relad.n > 0u64) {
|
||||
if (!wrn(fd, relad.p, relad.n, relad.n: i64)) { return -1; };
|
||||
};
|
||||
};
|
||||
};
|
||||
if (sym.n > 0u64) {
|
||||
if (!wrn(fd, sym.p, sym.n, sym.n: i64)) { return -1; };
|
||||
};
|
||||
@@ -2098,6 +2263,10 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
|
||||
|
||||
// Pad to 8 before shdrs.
|
||||
let written: u64 = EHDR_SZ + a.textlen + rela.n + sym.n + str_.n + shstr.n;
|
||||
if (hasdata) {
|
||||
written += a.datalen;
|
||||
if (hasdatarelocs) { written += relad.n; };
|
||||
};
|
||||
for ((written & 7u64) != 0u64) {
|
||||
wrdrop(fd, &zero, 1u64);
|
||||
written += 1u64;
|
||||
@@ -2127,11 +2296,38 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
|
||||
wru64(shbuf.ptr, 8u64, SHF_INFO_LINK);
|
||||
wru64(shbuf.ptr, 24u64, offrela);
|
||||
wru64(shbuf.ptr, 32u64, rela.n);
|
||||
wru32(shbuf.ptr, 40u64, 3u32); // sh_link = symtab idx
|
||||
wru32(shbuf.ptr, 44u64, 1u32); // sh_info = .text idx
|
||||
wru32(shbuf.ptr, 40u64, SH_SYMTAB: u32); // sh_link
|
||||
wru32(shbuf.ptr, 44u64, 1u32); // sh_info = .text idx
|
||||
wru64(shbuf.ptr, 48u64, 8u64);
|
||||
wru64(shbuf.ptr, 56u64, RELA_SZ);
|
||||
wrdrop(fd, shbuf.ptr, 64u64);
|
||||
if (hasdata) {
|
||||
// .data
|
||||
sn = 0;
|
||||
for (sn < 64) { shbuf[sn] = 0u8; sn += 1; };
|
||||
wru32(shbuf.ptr, 0u64, shndata);
|
||||
wru32(shbuf.ptr, 4u64, SHT_PROGBITS_C);
|
||||
wru64(shbuf.ptr, 8u64, SHF_ALLOC | SHF_WRITE);
|
||||
wru64(shbuf.ptr, 24u64, offdata);
|
||||
wru64(shbuf.ptr, 32u64, a.datalen);
|
||||
wru64(shbuf.ptr, 48u64, 8u64); // sh_addralign
|
||||
wrdrop(fd, shbuf.ptr, 64u64);
|
||||
if (hasdatarelocs) {
|
||||
// .rela.data
|
||||
sn = 0;
|
||||
for (sn < 64) { shbuf[sn] = 0u8; sn += 1; };
|
||||
wru32(shbuf.ptr, 0u64, shnrelad);
|
||||
wru32(shbuf.ptr, 4u64, SHT_RELA_C);
|
||||
wru64(shbuf.ptr, 8u64, SHF_INFO_LINK);
|
||||
wru64(shbuf.ptr, 24u64, offrelad);
|
||||
wru64(shbuf.ptr, 32u64, relad.n);
|
||||
wru32(shbuf.ptr, 40u64, SH_SYMTAB: u32);
|
||||
wru32(shbuf.ptr, 44u64, SH_DATA: u32); // applies to .data
|
||||
wru64(shbuf.ptr, 48u64, 8u64);
|
||||
wru64(shbuf.ptr, 56u64, RELA_SZ);
|
||||
wrdrop(fd, shbuf.ptr, 64u64);
|
||||
};
|
||||
};
|
||||
// .symtab
|
||||
sn = 0;
|
||||
for (sn < 64) { shbuf[sn] = 0u8; sn += 1; };
|
||||
@@ -2139,7 +2335,7 @@ export fn emitelf(a: *asm_, fd: i32) i32 = {
|
||||
wru32(shbuf.ptr, 4u64, SHT_SYMTAB_C);
|
||||
wru64(shbuf.ptr, 24u64, offsym);
|
||||
wru64(shbuf.ptr, 32u64, sym.n);
|
||||
wru32(shbuf.ptr, 40u64, 4u32); // sh_link = strtab
|
||||
wru32(shbuf.ptr, 40u64, SH_STRTAB: u32); // sh_link
|
||||
wru32(shbuf.ptr, 44u64, 1u32); // sh_info = one local (STN_UNDEF)
|
||||
wru64(shbuf.ptr, 48u64, 8u64);
|
||||
wru64(shbuf.ptr, 56u64, SYM_SZ);
|
||||
|
||||
Reference in New Issue
Block a user