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: 2 additions & 1 deletion core/relinker/relinker/src/pipeline/RelinkerPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ RelinkResult RelinkerPipeline::Relink() {
for (const auto& ph : programHeaders) {
if (ph.Type != PT_DYNAMIC)
continue;
if (hasDynamicSegment)
throw RelinkerException("Multiple PT_DYNAMIC segments", ph.Offset);

hasDynamicSegment = true;
dynTags = elfReader->ReadDynamicTags(ph);
break;
}

if (!hasDynamicSegment)
Expand Down
8 changes: 6 additions & 2 deletions core/relinker/relinker/tests/test_dynamic_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def main():
with tempfile.TemporaryDirectory(prefix="anyps5-dynamic-segment-") as directory:
work = Path(directory)

def convert(name, image, error=None):
def convert(name, image, error=None, modes=([], ["--windows"])):
source = work / (name + ".elf")
source.write_bytes(image)
for mode in ([], ["--windows"]):
for mode in modes:
output = work / (name + (".exe" if mode else ".out"))
result = subprocess.run([str(relinker), "--skip-sce-module", *mode, str(source), str(output)],
capture_output=True, text=True, timeout=20)
Expand Down Expand Up @@ -72,6 +72,10 @@ def convert(name, image, error=None):
struct.pack_into("<QQ", empty, 120 + 32, 0, 0)
convert("empty", empty, "Unterminated dynamic segment")

duplicate = fixture()
duplicate[64 + 2 * 56:64 + 3 * 56] = duplicate[120:176]
convert("duplicate", duplicate, "Multiple PT_DYNAMIC segments", ([], ["--windows"], ["--macos"]))

if failures:
raise AssertionError(failures)
print("Dynamic segment tests passed")
Expand Down
Loading