From 23b50ae8e91c864d5ef800ca97fd23384502b822 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sun, 7 Jan 2018 18:46:01 +0100
Subject: Suffixed ELF PLT entries with "@plt" in symbol names.

---
 ChangeLog                |  5 +++++
 plugins/elf/helper_arm.c | 25 +++++++++++--------------
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6ba737d..9a60bd7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 18-01-07  Cyrille Bagard <nocbos@gmail.com>
 
+	* plugins/elf/helper_arm.c:
+	Suffix ELF PLT entries with "@plt" in symbol names.
+
+18-01-07  Cyrille Bagard <nocbos@gmail.com>
+
 	* src/analysis/db/cdb.c:
 	Fix a bug when reading the compressed database.
 
diff --git a/plugins/elf/helper_arm.c b/plugins/elf/helper_arm.c
index 737e4ac..a037469 100644
--- a/plugins/elf/helper_arm.c
+++ b/plugins/elf/helper_arm.c
@@ -94,9 +94,7 @@ bool load_elf_arm_relocated_symbols(GElfFormat *format, const elf_shdr *relxxx,
     off_t index;                            /* Indice de la portion visée  */
     elf_sym sym;                            /* Définition complète         */
     const char *name;                       /* Nom du symbole trouvé       */
-
-
-
+    char *plt_name;                         /* Adaptation de l'étiquette   */
     virt_t virt;                            /* Adresse en mémoire virtuelle*/
     virt_t final_virt;                      /* Adresse virtuelle retenue   */
     bool status;                            /* Bilan d'une opération       */
@@ -105,13 +103,8 @@ bool load_elf_arm_relocated_symbols(GElfFormat *format, const elf_shdr *relxxx,
     GBinSymbol *symbol;                     /* Nouveau symbole construit   */
     mrange_t range;                         /* Couverture mémoire associée */
 
-
-
-
     result = true;
 
-
-
     get_elf_section_content(format, relxxx, &rel_start, &rel_size, NULL);
 
     base = G_BIN_FORMAT(format);
@@ -127,25 +120,25 @@ bool load_elf_arm_relocated_symbols(GElfFormat *format, const elf_shdr *relxxx,
             continue;
 
         name = get_elf_symbol_name(format, dynsym, dynstr, index);
+
         if (name == NULL)
-        {
-            /* FIXME */
             name = "unknown";
-        }
+
+        asprintf(&plt_name, "%s@plt", name);
 
         switch (ELF_REL_TYPE(format, reloc))
         {
             case R_ARM_JUMP_SLOT:
 
                 virt = ELF_SYM(format, sym, st_value);
-                if (virt == 0) continue;
+                if (virt == 0) goto lears_next;
 
                 final_virt = virt & ~0x1;
 
                 status = g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), final_virt, &addr);
-                if (!status) continue;
+                if (!status) goto lears_next;
 
-                routine = try_to_demangle_routine(name);
+                routine = try_to_demangle_routine(plt_name);
                 symbol = G_BIN_SYMBOL(routine);
 
                 init_mrange(&range, &addr, 0);
@@ -166,6 +159,10 @@ bool load_elf_arm_relocated_symbols(GElfFormat *format, const elf_shdr *relxxx,
         if (symbol != NULL)
             g_binary_format_add_symbol(base, symbol);
 
+    lears_next:
+
+        free(plt_name);
+
     }
 
     return result;
-- 
cgit v0.11.2-87-g4458