Merge pull request #10401 from roboterspinne/fix/relinker-elf-type-allowlist

fix(relinker): accept only ET_EXEC, ET_DYN and the SCE dynamic ELF types as executable input
This commit is contained in:
Dean authored and GitHub committed 2026-10-27 10:54:16 +13:00
commit 7a1dd637ae
2 files changed
+8

No files matched your search

@@ -22,6 +22,8 @@ namespace {
constexpr std::uint16_t kEtNone = 0;
constexpr std::uint16_t kEtRel = 1;
constexpr std::uint16_t kEtCore = 4;
constexpr std::uint16_t kEtSceDynExec = 0xfe10;
constexpr std::uint16_t kEtSceDynamic = 0xfe18;
}
@@ -64,6 +66,11 @@ RelinkResult RelinkerPipeline::Relink() {
throw RelinkerException("ET_NONE inputs do not specify an ELF object type");
if (inputType == kEtCore)
throw RelinkerException("ET_CORE core dumps are not executable images");
if (inputType != ET_EXEC && inputType != ET_DYN && inputType != kEtSceDynExec && inputType != kEtSceDynamic) {
std::ostringstream message;
message << "Unsupported ELF object type 0x" << std::hex << inputType << ": expected ET_EXEC, ET_DYN, 0xfe10 or 0xfe18";
throw RelinkerException(message.str(), 0x10);
}
auto programHeaders = elfReader->ReadProgramHeaders();
@@ -77,6 +77,7 @@ def object_type_cases(relinker, directory):
cases = ((0, "ET_NONE inputs do not specify an ELF object type"),
(1, "ET_REL relocatable inputs are not supported"),
(4, "ET_CORE core dumps are not executable images"),
*((value, f"Unsupported ELF object type 0x{value:x}") for value in (5, 0x1234, 0xFE00, 0xFE01, 0xFE04, 0xFFFF)),
(2, None), (3, None), (0xFE10, None), (0xFE18, None))
for mode, flags in enumerate(MODES):
for filter_level in (0, 1, 2):