summaryrefslogtreecommitdiff
path: root/src/format/elf
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-10-01 16:24:23 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-10-01 16:24:23 (GMT)
commit7e5540029350ab7e69ee8f75c96fc3fbc9ad5751 (patch)
tree383a776617c3925207b81ecccae20c0171ca3f98 /src/format/elf
parent6784e2ad98fa62cb2e7ac10a30a602c296a7b266 (diff)
Fixed the support of ELF internal arrays.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@583 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/elf')
-rw-r--r--src/format/elf/symbols.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/format/elf/symbols.c b/src/format/elf/symbols.c
index 04c584d..57d14cd 100644
--- a/src/format/elf/symbols.c
+++ b/src/format/elf/symbols.c
@@ -291,27 +291,37 @@ static bool load_all_elf_basic_entry_points(GElfFormat *format)
for (i = 0; get_phy_addr(&pos) < length; i++)
{
+ /**
+ * Selon la libc d'Android (https://www.codeaurora.org/.../android/bionic/linker/README.TXT) :
+ *
+ * DT_INIT_ARRAY
+ * Points to an array of function addresses that must be
+ * called, in-order, to perform initialization. Some of
+ * the entries in the array can be 0 or -1, and should
+ * be ignored.
+ *
+ * On étend le principe aux sections DT_FINI_ARRAY et DT_PREINIT_ARRAY.
+ */
+
if (fmt->is_32b)
{
status = g_binary_content_read_u32(content, &pos, fmt->endian, &virt_32);
+ status &= (virt_32 != 0x0 && virt_32 != 0xffffffff);
ep = virt_32;
}
else
{
status = g_binary_content_read_u64(content, &pos, fmt->endian, &virt_64);
+ status &= (virt_64 != 0x0 && virt_64 != 0xffffffffffffffff);
ep = virt_64;
}
if (!status) break;
- if (ep != 0x0)
- {
- snprintf(fullname, sizeof(fullname), "%s%u", prefix, i);
-
- routine = try_to_demangle_routine(fullname);
- register_elf_entry_point(fmt, ep, 0, routine);
+ snprintf(fullname, sizeof(fullname), "%s%u", prefix, i);
- }
+ routine = try_to_demangle_routine(fullname);
+ register_elf_entry_point(fmt, ep, 0, routine);
}
@@ -506,7 +516,7 @@ static bool load_elf_internal_symbols(GElfFormat *format)
vmpa2t addr; /* Localisation d'une routine */
mrange_t range; /* Couverture mémoire associée */
const char *name; /* Nom du symbole trouvé */
- char alt_name[5 + VMPA_MAX_LEN]; /* Nom abstrait de substitution*/
+ char alt_name[6 + VMPA_MAX_LEN]; /* Nom abstrait de substitution*/
GBinRoutine *routine; /* Nouvelle routine trouvée */
GBinSymbol *symbol; /* Nouveau symbole construit */