From 1fc3cd833f19ffa534f04caf541e88042124fd91 Mon Sep 17 00:00:00 2001 From: Alexander Taylor Date: Tue, 25 Feb 2025 20:32:24 -0500 Subject: Remove platform registration API footgun. Turns out, you can just pass this thing an architecture that is *completely* different from the one in the platform you are also passing in and it'll just happily do the wrong thing. While that's pretty wild, I'm in favor of not having to make this particular mistake again the next time I copy/paste some code, so we're now deprecating it. --- platform/linux/platform_linux.cpp | 76 +++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'platform/linux/platform_linux.cpp') diff --git a/platform/linux/platform_linux.cpp b/platform/linux/platform_linux.cpp index 2ba346f8..3bbb7248 100644 --- a/platform/linux/platform_linux.cpp +++ b/platform/linux/platform_linux.cpp @@ -307,8 +307,8 @@ extern "C" platform = new LinuxX86Platform(x86); Platform::Register("linux", platform); // Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one - BinaryViewType::RegisterPlatform("ELF", 0, x86, platform); - BinaryViewType::RegisterPlatform("ELF", 3, x86, platform); + BinaryViewType::RegisterPlatform("ELF", 0, platform); + BinaryViewType::RegisterPlatform("ELF", 3, platform); } Ref x64 = Architecture::GetByName("x86_64"); @@ -319,8 +319,8 @@ extern "C" platform = new LinuxX64Platform(x64); Platform::Register("linux", platform); // Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one - BinaryViewType::RegisterPlatform("ELF", 0, x64, platform); - BinaryViewType::RegisterPlatform("ELF", 3, x64, platform); + BinaryViewType::RegisterPlatform("ELF", 0, platform); + BinaryViewType::RegisterPlatform("ELF", 3, platform); } Ref armv7 = Architecture::GetByName("armv7"); @@ -344,10 +344,10 @@ extern "C" Platform::Register("linux", armebPlatform); Platform::Register("linux", thumbebPlatform); // Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one - BinaryViewType::RegisterPlatform("ELF", 0, armv7, armPlatform); - BinaryViewType::RegisterPlatform("ELF", 3, armv7, armPlatform); - BinaryViewType::RegisterPlatform("ELF", 0, armv7eb, armebPlatform); - BinaryViewType::RegisterPlatform("ELF", 3, armv7eb, armebPlatform); + BinaryViewType::RegisterPlatform("ELF", 0, armPlatform); + BinaryViewType::RegisterPlatform("ELF", 3, armPlatform); + BinaryViewType::RegisterPlatform("ELF", 0, armebPlatform); + BinaryViewType::RegisterPlatform("ELF", 3, armebPlatform); } Ref arm64 = Architecture::GetByName("aarch64"); @@ -358,8 +358,8 @@ extern "C" platform = new LinuxArm64Platform(arm64); Platform::Register("linux", platform); // Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one - BinaryViewType::RegisterPlatform("ELF", 0, arm64, platform); - BinaryViewType::RegisterPlatform("ELF", 3, arm64, platform); + BinaryViewType::RegisterPlatform("ELF", 0, platform); + BinaryViewType::RegisterPlatform("ELF", 3, platform); } Ref ppc = Architecture::GetByName("ppc"); @@ -374,10 +374,10 @@ extern "C" Platform::Register("linux", platform); Platform::Register("linux", platformle); // Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one - BinaryViewType::RegisterPlatform("ELF", 0, ppc, platform); - BinaryViewType::RegisterPlatform("ELF", 3, ppc, platform); - BinaryViewType::RegisterPlatform("ELF", 0, ppcle, platformle); - BinaryViewType::RegisterPlatform("ELF", 3, ppcle, platformle); + BinaryViewType::RegisterPlatform("ELF", 0, platform); + BinaryViewType::RegisterPlatform("ELF", 3, platform); + BinaryViewType::RegisterPlatform("ELF", 0, platformle); + BinaryViewType::RegisterPlatform("ELF", 3, platformle); } Ref ppc64 = Architecture::GetByName("ppc64"); @@ -392,10 +392,10 @@ extern "C" Platform::Register("linux", platform); Platform::Register("linux", platformle); // Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one - BinaryViewType::RegisterPlatform("ELF", 0, ppc64, platform); - BinaryViewType::RegisterPlatform("ELF", 3, ppc64, platform); - BinaryViewType::RegisterPlatform("ELF", 0, ppc64le, platformle); - BinaryViewType::RegisterPlatform("ELF", 3, ppc64le, platformle); + BinaryViewType::RegisterPlatform("ELF", 0, platform); + BinaryViewType::RegisterPlatform("ELF", 3, platform); + BinaryViewType::RegisterPlatform("ELF", 0, platformle); + BinaryViewType::RegisterPlatform("ELF", 3, platformle); } Ref mipsel = Architecture::GetByName("mipsel32"); @@ -421,18 +421,18 @@ extern "C" Platform::Register("linux", platformBE64); Platform::Register("linux", platformBE64cn); // Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one - BinaryViewType::RegisterPlatform("ELF", 0, mipsel, platformLE); - BinaryViewType::RegisterPlatform("ELF", 0, mipseb, platformBE); - BinaryViewType::RegisterPlatform("ELF", 0, mips3el, platform3LE); - BinaryViewType::RegisterPlatform("ELF", 0, mips3eb, platform3BE); - BinaryViewType::RegisterPlatform("ELF", 0, mips64eb, platformBE64); - BinaryViewType::RegisterPlatform("ELF", 0, cnmips64eb, platformBE64cn); - BinaryViewType::RegisterPlatform("ELF", 3, mipsel, platformLE); - BinaryViewType::RegisterPlatform("ELF", 3, mipseb, platformBE); - BinaryViewType::RegisterPlatform("ELF", 3, mips3el, platform3LE); - BinaryViewType::RegisterPlatform("ELF", 3, mips3eb, platform3BE); - BinaryViewType::RegisterPlatform("ELF", 3, mips64eb, platformBE64); - BinaryViewType::RegisterPlatform("ELF", 3, cnmips64eb, platformBE64cn); + BinaryViewType::RegisterPlatform("ELF", 0, platformLE); + BinaryViewType::RegisterPlatform("ELF", 0, platformBE); + BinaryViewType::RegisterPlatform("ELF", 0, platform3LE); + BinaryViewType::RegisterPlatform("ELF", 0, platform3BE); + BinaryViewType::RegisterPlatform("ELF", 0, platformBE64); + BinaryViewType::RegisterPlatform("ELF", 0, platformBE64cn); + BinaryViewType::RegisterPlatform("ELF", 3, platformLE); + BinaryViewType::RegisterPlatform("ELF", 3, platformBE); + BinaryViewType::RegisterPlatform("ELF", 3, platform3LE); + BinaryViewType::RegisterPlatform("ELF", 3, platform3BE); + BinaryViewType::RegisterPlatform("ELF", 3, platformBE64); + BinaryViewType::RegisterPlatform("ELF", 3, platformBE64cn); } Ref rv32 = Architecture::GetByName("rv32gc"); @@ -443,8 +443,8 @@ extern "C" platform = new LinuxRiscVPlatform(rv32, "linux-rv32gc"); Platform::Register("linux", platform); // Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one - BinaryViewType::RegisterPlatform("ELF", 0, rv32, platform); - BinaryViewType::RegisterPlatform("ELF", 3, rv32, platform); + BinaryViewType::RegisterPlatform("ELF", 0, platform); + BinaryViewType::RegisterPlatform("ELF", 3, platform); } Ref rv64 = Architecture::GetByName("rv64gc"); @@ -455,8 +455,8 @@ extern "C" platform = new LinuxRiscVPlatform(rv64, "linux-rv64gc"); Platform::Register("linux", platform); // Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one - BinaryViewType::RegisterPlatform("ELF", 0, rv64, platform); - BinaryViewType::RegisterPlatform("ELF", 3, rv64, platform); + BinaryViewType::RegisterPlatform("ELF", 0, platform); + BinaryViewType::RegisterPlatform("ELF", 3, platform); } #ifdef ULTIMATE_EDITION @@ -468,8 +468,8 @@ extern "C" platform = new LinuxCSkyV1Platform(cskyv1, "linux-csky_le_v1"); Platform::Register("linux", platform); // Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one - BinaryViewType::RegisterPlatform("ELF", 0, cskyv1, platform); - BinaryViewType::RegisterPlatform("ELF", 3, cskyv1, platform); + BinaryViewType::RegisterPlatform("ELF", 0, platform); + BinaryViewType::RegisterPlatform("ELF", 3, platform); } Ref cskyv2 = Architecture::GetByName("csky_le"); @@ -480,8 +480,8 @@ extern "C" platform = new LinuxCSkyV2Platform(cskyv2, "linux-csky_le"); Platform::Register("linux", platform); // Linux binaries sometimes have an OS identifier of zero, even though 3 is the correct one - BinaryViewType::RegisterPlatform("ELF", 0, cskyv2, platform); - BinaryViewType::RegisterPlatform("ELF", 3, cskyv2, platform); + BinaryViewType::RegisterPlatform("ELF", 0, platform); + BinaryViewType::RegisterPlatform("ELF", 3, platform); } #endif -- cgit v1.3.1