From dcab698e658d0e3d66c82c3aa70e97c4e50c73b5 Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 25 Jan 2016 23:01:40 +0100 Subject: [PATCH] Fix Thumb detection in ELF shared libraries --- libr/bin/format/elf/elf.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/libr/bin/format/elf/elf.c b/libr/bin/format/elf/elf.c index 544984b01a..1cca1a1267 100644 --- a/libr/bin/format/elf/elf.c +++ b/libr/bin/format/elf/elf.c @@ -1014,9 +1014,24 @@ int Elf_(r_bin_elf_get_bits)(struct Elf_(r_bin_elf_obj_t) *bin) { if (bin->ehdr.e_machine == EM_ARC_A5) return 16; /* Hack for Thumb */ if (bin->ehdr.e_machine == EM_ARM) { - ut64 entry = Elf_(r_bin_elf_get_entry_offset) (bin); - if (entry & 1) { - return 16; + if (bin->ehdr.e_type != ET_EXEC) { + struct r_bin_elf_symbol_t *symbol; + if ((symbol = Elf_(r_bin_elf_get_symbols) (bin, R_BIN_ELF_SYMBOLS))) { + int i; + for (i = 0; !symbol[i].last; i++) { + ut64 paddr = symbol[i].offset; + if (paddr & 1) { + return 16; + } + break; + } + } + } + { + ut64 entry = Elf_(r_bin_elf_get_entry_offset) (bin); + if (entry & 1) { + return 16; + } } } switch (bin->ehdr.e_ident[EI_CLASS]) {