mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 03:33:25 +00:00
* refactor(native): select ELF sections through the keyed owner * test(native): pin returned exports and versions for repeated version sections * refactor(nativeaot): read neither of repeated frozen object regions (#10790) * refactor(nativeaot): read neither of repeated frozen object regions through the keyed owner * refactor(parsers): retire every first-match section lookup (#10793) * fix(nativeaot): report an ambiguous frozen object region as partial (#10812) * refactor(native): select program headers and load commands through the keyed owner (#10827) * refactor(native): select the GOT base and dependency segments through the keyed owner (#10847) * refactor(native): select the GOT base and dependency segments through the keyed owner resolveGotBase selects the SHT_DYNAMIC section and the allocated .got.plt/.got sections with uniqueKeyed, so a repeat leaves the GOT base unknown instead of taking the first match; elfDependencies reads PT_LOAD segments through the same keyed program table as PT_DYNAMIC. A new keyed-first-match guard recognizes a find/findLast or filter-then-[0] whose predicate compares a key field, whatever the table is called; existing matches are baselined. The unwind fixture can declare PT_DYNAMIC headers and repeated .dynamic/.got.plt sections. * test(native): pin the PT_DYNAMIC path and destructured keyed lookups The keyed-first-match guard moves to scripts/verify/keyed-first-match.mjs with focused tests, and now recognizes a destructured key in any position and a destructured filter predicate. The single PT_DYNAMIC unwind test declares .dynamic as SHT_PROGBITS so only the program header supplies DT_PLTGOT, and asserts the resolved ranges. * fix(macho): refuse repeated chained-fixup and dyld-info tables (#10850) parseMachoLayout kept the last LC_DYLD_CHAINED_FIXUPS range and merged the rebase/bind streams of every LC_DYLD_INFO(_ONLY) command. A repeat now refuses the slice as malformed. NativeMachoInspection's chained import-name reader already declined repeated LC_DYLD_CHAINED_FIXUPS; that rule is now covered by a test. * fix(verify): count a filter index only on the filter's own result
46 lines
1.9 KiB
TypeScript
46 lines
1.9 KiB
TypeScript
import { expect, it } from "vitest";
|
|
|
|
import { countKeyedFirstMatches } from "../../../scripts/verify/keyed-first-match.mjs";
|
|
|
|
it.each([
|
|
"sections.find((section) => section.name === wanted)",
|
|
"headers.value.findLast((program) => program.type === PT_DYNAMIC)",
|
|
"table.find((entry: Entry) => entry.tag === TAG.context3)",
|
|
"items.find(item => item.cmd === LC.UUID)",
|
|
"available.find(({ name }) => name === normalized)",
|
|
"rows.find(({ offset, name }) => name === target)",
|
|
"rows.find(({ offset, type }: Row) => type === wanted)",
|
|
"directory.sections\n .filter(\n (section) =>\n section.type === SHT_DYNAMIC && section.file_backed,\n )\n .map((section) => section.offset)[0]",
|
|
"rows.filter(({ type }) => type === wanted).map(convert)[0]",
|
|
"rows.filter((row) => row.name === wanted)[0]",
|
|
])("counts the first-match lookup %j", (source) => {
|
|
expect(countKeyedFirstMatches(source)).toBe(1);
|
|
});
|
|
|
|
it.each([
|
|
// Every match is kept, so no precedence is chosen.
|
|
"rows.filter((row) => row.type === PT_LOAD)",
|
|
// `[0]` indexes each mapped value, not the filtered result.
|
|
"rows.filter((row) => row.type === TYPE).map((row) => parse(row)[0])",
|
|
"rows.filter((row) => row.type === TYPE && row.parts[0]).map(parse)",
|
|
// A condition search, not a lookup by key.
|
|
"segments.find((segment) => segment.fileoff === 0n)",
|
|
"named(name).find((candidate) => (candidate.flags & SHF_ALLOC) !== 0n)",
|
|
// A renamed destructured key binds another identifier.
|
|
"rows.find(({ name: label }) => name === label)",
|
|
"rows.some((row) => row.name === wanted)",
|
|
])("does not count %j", (source) => {
|
|
expect(countKeyedFirstMatches(source)).toBe(0);
|
|
});
|
|
|
|
it("counts each lookup in a file", () => {
|
|
expect(
|
|
countKeyedFirstMatches(
|
|
[
|
|
"const a = rows.find((row) => row.name === first);",
|
|
"const b = rows.filter(({ tag }) => tag === second)[0];",
|
|
].join("\n"),
|
|
),
|
|
).toBe(2);
|
|
});
|