Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/relinker/relinker/src/pipeline/RelinkerPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ RelinkResult RelinkerPipeline::Relink() {
if (symOff < dynSymTabOffset || symOff > raw.size() || raw.size() - symOff < symEntSize
|| (dynSymTabSize && (off > *dynSymTabSize || symEntSize > *dynSymTabSize - off)))
throw RelinkerException("Symbol table entry out of bounds", symOff);
if (symIdx == 0 && std::any_of(raw.begin() + static_cast<std::ptrdiff_t>(symOff), raw.begin() + static_cast<std::ptrdiff_t>(symOff + symEntSize),
[](const std::uint8_t byte) { return byte != 0; }))
throw RelinkerException("Dynamic symbol table entry 0 is not a null symbol entry", symOff);
return symOff;
};

Expand Down
15 changes: 15 additions & 0 deletions core/relinker/relinker/tests/test_null_symbol_relocations.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ def main():
capture_output=True, text=True, timeout=20)
assert result.returncode == 2 and "Unnamed import symbol is not a null symbol entry" in result.stderr, (target, result.stderr)
assert not output.exists()
named_null = image_with(index=0)
names = b"\0foo\0libfoo.prx\0"
named_null[0x600:0x600 + len(names)] = names
struct.pack_into("<Q", named_null, 0x418, len(names))
struct.pack_into("<qQqQ", named_null, 0x480, 1, 5, 0, 0)
struct.pack_into("<QQ", named_null, 152, 0xa0, 0xa0)
named_null[0x620:0x638] = struct.pack("<IBBHQQ", 1, 0x12, 0, 0, 0, 0)
source = work / "named-null-entry.elf"
source.write_bytes(named_null)
for target, options, _ in TARGETS:
output = work / f"named-null-entry-{target}.out"
result = subprocess.run([str(relinker), "--skip-sce-module", *options, str(source), str(output)],
capture_output=True, text=True, timeout=20)
assert result.returncode == 2 and "Dynamic symbol table entry 0 is not a null symbol entry" in result.stderr, (target, result.returncode, result.stderr)
assert not output.exists()
print("Null symbol relocation tests passed")


Expand Down
Loading