summaryrefslogtreecommitdiff
path: root/src/format/elf
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-03-22 17:58:36 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-03-22 17:58:36 (GMT)
commitcd956221a807e4c1961e17602d5ca641b93a937a (patch)
tree77c53ebad8404da4182fdba5b70e9f3ae8e05fbd /src/format/elf
parent88e34a085a69d23da262a92641a80f409931ea82 (diff)
Ensured all string symbols referenced by instructions get a label.
Diffstat (limited to 'src/format/elf')
-rw-r--r--src/format/elf/strings.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/format/elf/strings.c b/src/format/elf/strings.c
index 755163e..9bcb87f 100644
--- a/src/format/elf/strings.c
+++ b/src/format/elf/strings.c
@@ -152,7 +152,7 @@ bool parse_elf_string_data(GElfFormat *format, phys_t start, phys_t size, virt_t
{
bool result; /* Bilan à faire remonter */
GBinContent *content; /* Contenu binaire à lire */
- char *data; /* Données copiées à traiter */
+ const bin_t *data; /* Contenu complet et original */
vmpa2t pos; /* Tête de lecture */
bool cut; /* Séparation nette ? */
off_t i; /* Boucle de parcours */
@@ -161,7 +161,8 @@ bool parse_elf_string_data(GElfFormat *format, phys_t start, phys_t size, virt_t
GBinSymbol *symbol; /* Symbole à intégrer */
char *label; /* Désignation de la chaîne */
- if (address == 0) return false;
+ if (address == 0)
+ return false;
result = false;
@@ -169,11 +170,11 @@ bool parse_elf_string_data(GElfFormat *format, phys_t start, phys_t size, virt_t
content = g_binary_format_get_content(G_BIN_FORMAT(format));
- data = (char *)malloc(size * sizeof(char));
-
init_vmpa(&pos, start, address);
- if (!g_binary_content_read_raw(content, &pos, size, (bin_t *)data))
+ data = g_binary_content_get_raw_access(content, &pos, size);
+
+ if (data == NULL)
goto pesd_error;
/* Boucle de parcours */
@@ -194,8 +195,7 @@ bool parse_elf_string_data(GElfFormat *format, phys_t start, phys_t size, virt_t
init_vmpa(&pos, start + i, address + i);
- instr = g_raw_instruction_new_array(G_BIN_FORMAT(format)->content, MDS_8_BITS,
- end - i, &pos, format->endian);
+ instr = g_raw_instruction_new_array(content, MDS_8_BITS, end - i, &pos, format->endian);
g_raw_instruction_mark_as_string(G_RAW_INSTRUCTION(instr), true);
@@ -207,7 +207,7 @@ bool parse_elf_string_data(GElfFormat *format, phys_t start, phys_t size, virt_t
{
init_vmpa(&pos, start + i, address + i);
- label = create_string_label(G_BIN_FORMAT(format), &pos, &data[i], end - i);
+ label = create_string_label(G_BIN_FORMAT(format), &pos, end - i);
g_binary_symbol_set_alt_label(symbol, label);
@@ -229,8 +229,6 @@ bool parse_elf_string_data(GElfFormat *format, phys_t start, phys_t size, virt_t
g_object_unref(G_OBJECT(content));
- free(data);
-
return result;
}