summaryrefslogtreecommitdiff
path: root/plugins/elf/helper_arm.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/elf/helper_arm.c')
-rw-r--r--plugins/elf/helper_arm.c66
1 files changed, 56 insertions, 10 deletions
diff --git a/plugins/elf/helper_arm.c b/plugins/elf/helper_arm.c
index 3632f54..cc0a233 100644
--- a/plugins/elf/helper_arm.c
+++ b/plugins/elf/helper_arm.c
@@ -87,10 +87,9 @@ virt_t fix_elf_arm_virtual_address(virt_t virt)
/******************************************************************************
* *
* Paramètres : format = description de l'exécutable à manipuler. *
-* range = emplacement de la procédure de liaison. *
-* offset = décalage retrouvé par désassemblage... [OUT] *
+* addr = position de la PLT à faire évoluer. [OUT] *
* *
-* Description : Retrouve le décalage appliqué lors d'une résolution. *
+* Description : Détermine l'emplacement de la première entrée dans la PLT. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -98,12 +97,61 @@ virt_t fix_elf_arm_virtual_address(virt_t virt)
* *
******************************************************************************/
-bool retrieve_arm_linkage_offset(GElfFormat *format, const mrange_t *range, uint64_t *offset)
+bool find_first_plt_entry(GElfFormat *format, vmpa2t *addr)
{
bool result; /* Bilan à retourner */
GBinContent *content; /* Contenu binaire à parcourir */
vmpa2t pos; /* Tete de lecture */
uint32_t raw; /* Valeur brute lue */
+ bool status; /* Bilan d'une lecture */
+
+ result = false;
+
+ content = G_BIN_FORMAT(format)->content;
+
+ while (!result)
+ {
+ copy_vmpa(&pos, addr);
+
+ status = g_binary_content_read_u32(content, &pos, format->endian, &raw);
+ if (!status) break;
+
+ /**
+ * Analyse à mettre en relation avec la fonction retrieve_arm_linkage_offset().
+ */
+
+ if ((raw & 0xfffff000) == 0xe28fc000)
+ result = true;
+
+ else
+ copy_vmpa(addr, &pos);
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : format = description de l'exécutable à manipuler. *
+* addr = position de la PLT à faire évoluer. [OUT] *
+* offset = décalage retrouvé par désassemblage. [OUT] *
+* *
+* Description : Retrouve le décalage appliqué lors d'une résolution. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool retrieve_arm_linkage_offset(GElfFormat *format, vmpa2t *addr, uint64_t *offset)
+{
+ bool result; /* Bilan à retourner */
+ GBinContent *content; /* Contenu binaire à parcourir */
+ uint32_t raw; /* Valeur brute lue */
uint32_t shift; /* Décalage arithmétique */
/**
@@ -115,9 +163,7 @@ bool retrieve_arm_linkage_offset(GElfFormat *format, const mrange_t *range, uint
content = G_BIN_FORMAT(format)->content;
- copy_vmpa(&pos, get_mrange_addr(range));
-
- result = g_binary_content_read_u32(content, &pos, format->endian, &raw);
+ result = g_binary_content_read_u32(content, addr, format->endian, &raw);
if (!result) goto exit;
/**
@@ -142,7 +188,7 @@ bool retrieve_arm_linkage_offset(GElfFormat *format, const mrange_t *range, uint
if ((raw & 0xfffff000) == 0xe28fc000)
{
- *offset = get_virt_addr(get_mrange_addr(range)) + 8;
+ *offset = get_virt_addr(addr) + 4;
/**
* Les deux premières instructions répondent à l'encodage spécifié dans :
@@ -187,7 +233,7 @@ bool retrieve_arm_linkage_offset(GElfFormat *format, const mrange_t *range, uint
* Seconde instruction...
*/
- result = g_binary_content_read_u32(content, &pos, format->endian, &raw);
+ result = g_binary_content_read_u32(content, addr, format->endian, &raw);
if (!result) goto exit;
if ((raw & 0xfffff000) != 0xe28cc000)
@@ -222,7 +268,7 @@ bool retrieve_arm_linkage_offset(GElfFormat *format, const mrange_t *range, uint
*
*/
- result = g_binary_content_read_u32(content, &pos, format->endian, &raw);
+ result = g_binary_content_read_u32(content, addr, format->endian, &raw);
if (!result) goto exit;
if ((raw & 0xfffff000) != 0xe5bcf000)