Skip to content

Commit 6d2f24c

Browse files
committed
More conservative detection of ARM BE8 binaries. Fix #5621
1 parent 7fe9007 commit 6d2f24c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

view/elf/elfview.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ void BinaryNinja::InitElfViewType()
3131
"description" : "Maximum number of entries to include in section header array",
3232
"ignore" : ["SettingsProjectScope"]
3333
})");
34+
35+
settings->RegisterSetting("files.elf.detectARMBE8Binary",
36+
R"({
37+
"title" : "Enable ARM BE8 binary detection",
38+
"type" : "boolean",
39+
"default" : true,
40+
"description" : "Enable ARM BE8 binary detection for mixed little/big endianness for code/data",
41+
"ignore" : ["SettingsProjectScope"]
42+
})");
3443
}
3544

3645

@@ -2740,7 +2749,8 @@ uint64_t ElfViewType::ParseHeaders(BinaryView* data, ElfIdent& ident, ElfCommonH
27402749
// retrieve architecture
27412750
// FIXME: Architecture registration methods should perhaps be virtual and take the raw data, or some additional opaque information.
27422751

2743-
endianness = header.flags & EF_ARM_BE8 ? BigEndian : endianness;
2752+
if (Settings::Instance()->Get<bool>("files.elf.detectARMBE8Binary"))
2753+
endianness = ((commonHeader.arch == EM_ARM) && (header.flags & EF_ARM_BE8)) ? BigEndian : endianness;
27442754

27452755
/* for architectures where .e_machine field doesn't disambiguate between 32/64 (like MIPS),
27462756
form the conventional alternative id, including the .e_ident[EI_CLASS] field */

0 commit comments

Comments
 (0)