From 6d2f24c84947f188f4056d39b2cb22ee1d870022 Mon Sep 17 00:00:00 2001 From: Xusheng Date: Tue, 18 Jun 2024 15:27:14 +0800 Subject: More conservative detection of ARM BE8 binaries. Fix https://github.com/Vector35/binaryninja-api/issues/5621 --- view/elf/elfview.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'view/elf/elfview.cpp') diff --git a/view/elf/elfview.cpp b/view/elf/elfview.cpp index defd6600..cf9f4efa 100644 --- a/view/elf/elfview.cpp +++ b/view/elf/elfview.cpp @@ -31,6 +31,15 @@ void BinaryNinja::InitElfViewType() "description" : "Maximum number of entries to include in section header array", "ignore" : ["SettingsProjectScope"] })"); + + settings->RegisterSetting("files.elf.detectARMBE8Binary", + R"({ + "title" : "Enable ARM BE8 binary detection", + "type" : "boolean", + "default" : true, + "description" : "Enable ARM BE8 binary detection for mixed little/big endianness for code/data", + "ignore" : ["SettingsProjectScope"] + })"); } @@ -2740,7 +2749,8 @@ uint64_t ElfViewType::ParseHeaders(BinaryView* data, ElfIdent& ident, ElfCommonH // retrieve architecture // FIXME: Architecture registration methods should perhaps be virtual and take the raw data, or some additional opaque information. - endianness = header.flags & EF_ARM_BE8 ? BigEndian : endianness; + if (Settings::Instance()->Get("files.elf.detectARMBE8Binary")) + endianness = ((commonHeader.arch == EM_ARM) && (header.flags & EF_ARM_BE8)) ? BigEndian : endianness; /* for architectures where .e_machine field doesn't disambiguate between 32/64 (like MIPS), form the conventional alternative id, including the .e_ident[EI_CLASS] field */ -- cgit v1.3.1