Skip to content

Commit 147bf1f

Browse files
committed
fix(pkg): the machine guard requires both headers before it fires
An unreadable ELF header -- a dangling farm link, a file the reader cannot open -- is not evidence of a foreign machine. Reporting it as one would put a wrong reason in the record; the symbol test then rejects it for the reason that applies.
1 parent 7a33dde commit 147bf1f

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

pkgs/c/compat.opencl-runtime.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,15 @@ local function elf_machine(file)
283283
return tonumber(lo) + tonumber(hi) * 256
284284
end
285285

286+
-- Both answers are required before the guard fires. An unreadable header --
287+
-- a dangling farm link, a file the reader cannot open -- is not evidence of a
288+
-- foreign machine, and reporting it as one would put a wrong reason in the
289+
-- record; the symbol test below then rejects it for the reason that applies.
290+
local function machines_differ(a, b)
291+
local ma, mb = elf_machine(a), elf_machine(b)
292+
return ma ~= nil and mb ~= nil and ma ~= mb
293+
end
294+
286295
-- Payloads first, with the same criterion compat.vulkan-runtime applies: the
287296
-- payload's versioned symbol set must cover the host copy's.
288297
local function prefer_payloads(outdir, seeds)
@@ -318,7 +327,7 @@ local function prefer_payloads(outdir, seeds)
318327
local hit = find_in_store(base)
319328
if not hit then
320329
entry.class = "host; no installed payload provides this soname"
321-
elseif elf_machine(hit) ~= elf_machine(target) then
330+
elseif machines_differ(hit, target) then
322331
entry.class = string.format(
323332
"host; the payload %s is built for another machine", hit)
324333
elseif not nm then

pkgs/c/compat.vulkan-runtime.lua

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,15 @@ local function elf_machine(file)
581581
return tonumber(lo) + tonumber(hi) * 256
582582
end
583583

584+
-- Both answers are required before the guard fires. An unreadable header --
585+
-- a dangling farm link, a file the reader cannot open -- is not evidence of a
586+
-- foreign machine, and reporting it as one would put a wrong reason in the
587+
-- record; the symbol test below then rejects it for the reason that applies.
588+
local function machines_differ(a, b)
589+
local ma, mb = elf_machine(a), elf_machine(b)
590+
return ma ~= nil and mb ~= nil and ma ~= mb
591+
end
592+
584593
-- The versioned dynamic symbols a library defines, as a set. `name@@VERSION`
585594
-- for a versioned symbol, so the GLIBCXX and CXXABI nodes of a C++ runtime
586595
-- take part in the comparison exactly as the loader would apply them.
@@ -642,7 +651,7 @@ local function prefer_payloads(outdir)
642651
.. "and is not installed, so the declaration did not "
643652
.. "take effect")
644653
or "host; no installed payload provides this soname"
645-
elseif elf_machine(hit) ~= elf_machine(target) then
654+
elseif machines_differ(hit, target) then
646655
entry.class = string.format(
647656
"host; the payload %s is built for another machine", hit)
648657
elseif not nm then

0 commit comments

Comments
 (0)