w6l: purge dead elf branches; pin rx extent

This commit is contained in:
2026-08-09 04:37:33 +09:00
parent e720d4802f
commit ac8ddee6c1
8 changed files with 33 additions and 29 deletions

View File

@@ -14,7 +14,8 @@ package link_test;
//
// twoloads (620) — a DATAW input links to exactly 2 program headers,
// both PT_LOAD, exactly one R+X and one R+W (exact p_flags equality;
// any other combination fails).
// any other combination fails). R+X filesz/memsz stop at content rather
// than absorbing the page padding before R+W.
//
// nodatasingleload (620) — an input without DATAW keeps the single
// PT_LOAD layout; test 992 (selfhost w6l diff, the terminal bootstrap
@@ -169,6 +170,9 @@ fn runexit(td: str, tag: str, exe: str) i32 = {
if (phnum(o) != 2) { fail("twoloads", "e_phnum != 2"); };
let sawrx: bool = false;
let sawrw: bool = false;
let rxfilesz: u64 = 0u64;
let rxmemsz: u64 = 0u64;
let rwoff: u64 = 0u64;
let i: i32 = 0;
for (i < 2) {
let ph: i32 = phoff(o, i);
@@ -176,8 +180,14 @@ fn runexit(td: str, tag: str, exe: str) i32 = {
fail("twoloads", "phdr not PT_LOAD");
};
let flags: u64 = testenv.leu32(o, ph + 4);
if (flags == 5u64) { sawrx = true; }
else if (flags == 6u64) { sawrw = true; }
if (flags == 5u64) {
sawrx = true;
rxfilesz = testenv.leu64(o, ph + 32);
rxmemsz = testenv.leu64(o, ph + 40);
} else if (flags == 6u64) {
sawrw = true;
rwoff = testenv.leu64(o, ph + 8);
}
else {
fail("twoloads", "phdr flags not exactly R+X or R+W");
};
@@ -185,6 +195,12 @@ fn runexit(td: str, tag: str, exe: str) i32 = {
};
if (!sawrx) { fail("twoloads", "missing R+X PT_LOAD"); };
if (!sawrw) { fail("twoloads", "missing R+W PT_LOAD"); };
if (rxfilesz != rxmemsz) {
fail("twoloads", "R+X filesz != memsz");
};
if (rxmemsz >= rwoff) {
fail("twoloads", "R+X memsz includes page padding");
};
testenv.clean(td);
};