ww+wcc: emit and lex // MODULE: <name> directive in combined.ww

This commit is contained in:
2026-05-11 14:54:56 +09:00
parent 5d91ee778e
commit d7036be0e5
9 changed files with 296 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
// MODULE: os
// os — process and filesystem facade. The body of each call lands
// either in libwwrt.a (rt_syscall trampoline) or libc bindings,
// depending on how the program was linked.
@@ -207,6 +208,7 @@ export fn getdents64(fd: i32, buf: *u8, n: u64) i64 = {
return syscall3(SYS_GETDENTS64, fd: i64, buf: i64, n: i64);
};
// MODULE: wcc
// selfhost/cmd/wcc/mem.ww — port of cmd/wcc/mem.c.
//
// Bump arena allocator. Backed by the runtime page allocator
@@ -314,6 +316,7 @@ export fn freearena(a: *arena) void = {
};
};
// MODULE: w6l
// selfhost/cmd/w6l/sym.ww — port of cmd/w6l/sym.c.
//
// Linker symbol table. Singly-linked list, usually a few hundred
@@ -416,6 +419,7 @@ export fn lookup(l: *lnk, name: str) *lsym = {
return nil;
};
// MODULE: w6l
// selfhost/cmd/w6l/obj.ww — port of cmd/w6l/obj.c.
//
// Loads relocatable ELF64 .o files emitted by w6a, appends .text to
@@ -903,6 +907,7 @@ fn loadimage(l: *lnk, path: *u8, buf: *u8, len: u64) i32 = {
return 0;
};
// MODULE: w6l
// selfhost/cmd/w6l/dyn.ww — port of cmd/w6l/dyn.c.
//
// Load a shared object (ET_DYN) so the linker knows which symbols it
@@ -1302,6 +1307,7 @@ export fn soversion(so: *lso, name: str) str = {
// `streq` lives in sym.ww — same bundle, single definition.
// MODULE: w6l
// selfhost/cmd/w6l/pass.ww — port of cmd/w6l/pass.c.
//
// Resolution + relocation. l_resolve flags every undefined symbol
@@ -1418,6 +1424,7 @@ export fn relocate(l: *lnk, base: u64) i32 = {
return l.errs;
};
// MODULE: w6l
// selfhost/cmd/w6l/dynout.ww — port of cmd/w6l/dynout.c.
//
// Emit a dynamic-linked ELF executable. The shape is the simplest
@@ -2162,6 +2169,7 @@ export fn emitdynelf(l: *lnk, fd: i32, base: u64, entry: u64) i32 = {
return 0;
};
// MODULE: w6l
// selfhost/cmd/w6l/out.ww — port of cmd/w6l/out.c.
//
// Emit a static ELF64 executable. File layout (per the C original):
@@ -2263,6 +2271,7 @@ export fn emitelf(l: *lnk, fd: i32, base: u64, entry: u64) i32 = {
return 0;
};
// MODULE: w6l
// selfhost/cmd/w6l/main.ww — port of cmd/w6l/main.c.
//
// w6l = amd64 linker. Reads relocatable ELF .o files, SysV `ar`