From 2b36c54ba2ee642e21cb4ba18eaded1bf8028707 Mon Sep 17 00:00:00 2001 From: pancake Date: Sat, 19 Nov 2022 03:11:56 +0100 Subject: [PATCH] Fix wrong detection of `main` in elf-arm32 ##bin --- libr/bin/format/elf/elf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libr/bin/format/elf/elf.c b/libr/bin/format/elf/elf.c index fa449dabd2..7eccfe0e0d 100644 --- a/libr/bin/format/elf/elf.c +++ b/libr/bin/format/elf/elf.c @@ -1897,7 +1897,11 @@ ut64 Elf_(r_bin_elf_get_main_offset)(ELFOBJ *bin) { } else { /* non-thumb entry points */ if (!memcmp (buf, "\x00\xb0\xa0\xe3\x00\xe0\xa0\xe3", 8)) { - return Elf_(r_bin_elf_v2p) (bin, r_read_le32 (&buf[0x34]) & ~1); + if (buf[0x40 + 2] == 0xff && buf[0x40 + 3] == 0xeb) { + // eprintf ("custom\n"); + } else if (!memcmp (buf + 0x28 + 2, "\xff\xeb", 2)) { + return Elf_(r_bin_elf_v2p) (bin, r_read_le32 (&buf[0x34]) & ~1); + } } if (!memcmp (buf, "\x24\xc0\x9f\xe5\x00\xb0\xa0\xe3", 8)) { return Elf_(r_bin_elf_v2p) (bin, r_read_le32 (&buf[0x30]) & ~1);