summaryrefslogtreecommitdiff
path: root/plugins/elf
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-05-21 12:08:29 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-05-21 12:08:29 (GMT)
commit7e5b1add6fdeb74b2356acf8ccf7009f45cfa85e (patch)
treeb7373554017e97fcbe24db79d9818272764e858d /plugins/elf
parent5dd935b27a765177960bdfe4d2fcb296cbbd41da (diff)
Changed the hierarchy of format objects.
Diffstat (limited to 'plugins/elf')
-rw-r--r--plugins/elf/dynamic.c4
-rw-r--r--plugins/elf/elf-int.c14
-rw-r--r--plugins/elf/format.c30
-rw-r--r--plugins/elf/helper_arm.c4
-rw-r--r--plugins/elf/loading.c6
-rw-r--r--plugins/elf/section.c2
-rw-r--r--plugins/elf/strings.c2
-rw-r--r--plugins/elf/symbols.c14
8 files changed, 40 insertions, 36 deletions
diff --git a/plugins/elf/dynamic.c b/plugins/elf/dynamic.c
index 13292ec..6ab2ce2 100644
--- a/plugins/elf/dynamic.c
+++ b/plugins/elf/dynamic.c
@@ -272,7 +272,7 @@ const char **list_elf_needed_objects(const GElfFormat *format, size_t *count)
/* Seconde passe : recherche des objets requis */
- content = G_BIN_FORMAT(format)->content;
+ content = G_KNOWN_FORMAT(format)->content;
g_binary_content_compute_end_pos(content, &end);
@@ -343,7 +343,7 @@ bool resolve_plt_using_got(GElfFormat *format, virt_t *virt)
if (!g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format), got_virt, &got_addr))
goto exit;
- content = G_BIN_FORMAT(format)->content;
+ content = G_KNOWN_FORMAT(format)->content;
/**
* Quelques pistes pour la connaissance des premières cellules d'une GOT :
diff --git a/plugins/elf/elf-int.c b/plugins/elf/elf-int.c
index 8fb290e..bfe183a 100644
--- a/plugins/elf/elf-int.c
+++ b/plugins/elf/elf-int.c
@@ -49,7 +49,7 @@ bool read_elf_header(GElfFormat *format, elf_header *header, bool *is_32b, Sourc
const GBinContent *content; /* Contenu binaire à lire */
vmpa2t pos; /* Position de lecture */
- content = G_BIN_FORMAT(format)->content;
+ content = G_KNOWN_FORMAT(format)->content;
init_vmpa(&pos, 0, VMPA_NO_VIRTUAL);
@@ -143,7 +143,7 @@ bool read_elf_program_header(const GElfFormat *format, phys_t phys, elf_phdr *he
const GBinContent *content; /* Contenu binaire à lire */
vmpa2t pos; /* Position de lecture */
- content = G_BIN_FORMAT(format)->content;
+ content = G_KNOWN_FORMAT(format)->content;
init_vmpa(&pos, phys, VMPA_NO_VIRTUAL);
@@ -199,7 +199,7 @@ bool read_elf_section_header(const GElfFormat *format, phys_t phys, elf_shdr *se
result = true;
- content = G_BIN_FORMAT(format)->content;
+ content = G_KNOWN_FORMAT(format)->content;
init_vmpa(&pos, phys, VMPA_NO_VIRTUAL);
@@ -261,7 +261,7 @@ bool read_elf_dynamic_entry(const GElfFormat *format, phys_t phys, elf_dyn *dyn)
const GBinContent *content; /* Contenu binaire à lire */
vmpa2t pos; /* Position de lecture */
- content = G_BIN_FORMAT(format)->content;
+ content = G_KNOWN_FORMAT(format)->content;
init_vmpa(&pos, phys, VMPA_NO_VIRTUAL);
@@ -301,7 +301,7 @@ bool read_elf_symbol(const GElfFormat *format, phys_t *phys, elf_sym *sym)
const GBinContent *content; /* Contenu binaire à lire */
vmpa2t pos; /* Position de lecture */
- content = G_BIN_FORMAT(format)->content;
+ content = G_KNOWN_FORMAT(format)->content;
init_vmpa(&pos, *phys, VMPA_NO_VIRTUAL);
@@ -352,7 +352,7 @@ bool read_elf_relocation(const GElfFormat *format, phys_t *phys, elf_rel *reloc)
const GBinContent *content; /* Contenu binaire à lire */
vmpa2t pos; /* Position de lecture */
- content = G_BIN_FORMAT(format)->content;
+ content = G_KNOWN_FORMAT(format)->content;
init_vmpa(&pos, *phys, VMPA_NO_VIRTUAL);
@@ -396,7 +396,7 @@ bool read_elf_note(const GElfFormat *format, GBinContent *content, phys_t *phys,
vmpa2t pos; /* Position de lecture */
if (content == NULL)
- content = G_BIN_FORMAT(format)->content;
+ content = G_KNOWN_FORMAT(format)->content;
init_vmpa(&pos, *phys, VMPA_NO_VIRTUAL);
diff --git a/plugins/elf/format.c b/plugins/elf/format.c
index d102ad8..75b9a6c 100644
--- a/plugins/elf/format.c
+++ b/plugins/elf/format.c
@@ -63,10 +63,10 @@ static void g_elf_format_dispose(GElfFormat *);
static void g_elf_format_finalize(GElfFormat *);
/* Indique la désignation interne du format. */
-static const char *g_elf_format_get_name(const GElfFormat *);
+static char *g_elf_format_get_key(const GElfFormat *);
/* Fournit une description humaine du format. */
-static const char *g_elf_format_get_description(const GElfFormat *);
+static char *g_elf_format_get_description(const GElfFormat *);
/* Assure l'interprétation d'un format en différé. */
static bool g_elf_format_analyze(GElfFormat *, wgroup_id_t, GtkStatusStack *);
@@ -137,6 +137,7 @@ G_DEFINE_TYPE(GElfFormat, g_elf_format, G_TYPE_EXE_FORMAT);
static void g_elf_format_class_init(GElfFormatClass *klass)
{
GObjectClass *object; /* Autre version de la classe */
+ GKnownFormatClass *known; /* Version de format connu */
GBinFormatClass *fmt; /* Version en format basique */
GExeFormatClass *exe; /* Version en exécutable */
@@ -145,11 +146,14 @@ static void g_elf_format_class_init(GElfFormatClass *klass)
object->dispose = (GObjectFinalizeFunc/* ! */)g_elf_format_dispose;
object->finalize = (GObjectFinalizeFunc)g_elf_format_finalize;
+ known = G_KNOWN_FORMAT_CLASS(klass);
+
+ known->get_key = (known_get_key_fc)g_elf_format_get_key;
+ known->get_desc = (known_get_desc_fc)g_elf_format_get_description;
+ known->analyze = (known_analyze_fc)g_elf_format_analyze;
+
fmt = G_BIN_FORMAT_CLASS(klass);
- fmt->get_name = (format_get_name_fc)g_elf_format_get_name;
- fmt->get_desc = (format_get_desc_fc)g_elf_format_get_description;
- fmt->analyze = (format_analyze_fc)g_elf_format_analyze;
fmt->get_endian = (format_get_endian_fc)g_elf_format_get_endianness;
exe = G_EXE_FORMAT_CLASS(klass);
@@ -249,7 +253,7 @@ GExeFormat *g_elf_format_new(GBinContent *content)
result = g_object_new(G_TYPE_ELF_FORMAT, NULL);
- g_binary_format_set_content(G_BIN_FORMAT(result), content);
+ g_known_format_set_content(G_KNOWN_FORMAT(result), content);
return G_EXE_FORMAT(result);
@@ -262,17 +266,17 @@ GExeFormat *g_elf_format_new(GBinContent *content)
* *
* Description : Indique la désignation interne du format. *
* *
-* Retour : Description du format. *
+* Retour : Désignation du format. *
* *
* Remarques : - *
* *
******************************************************************************/
-static const char *g_elf_format_get_name(const GElfFormat *format)
+static char *g_elf_format_get_key(const GElfFormat *format)
{
- const char *result; /* Désignation à retourner */
+ char *result; /* Désignation à retourner */
- result = "elf";
+ result = strdup("elf");
return result;
@@ -291,11 +295,11 @@ static const char *g_elf_format_get_name(const GElfFormat *format)
* *
******************************************************************************/
-static const char *g_elf_format_get_description(const GElfFormat *format)
+static char *g_elf_format_get_description(const GElfFormat *format)
{
- const char *result; /* Désignation à retourner */
+ char *result; /* Désignation à retourner */
- result = "Executable and Linkable Format";
+ result = strdup("Executable and Linkable Format");
return result;
diff --git a/plugins/elf/helper_arm.c b/plugins/elf/helper_arm.c
index cc0a233..8a80243 100644
--- a/plugins/elf/helper_arm.c
+++ b/plugins/elf/helper_arm.c
@@ -107,7 +107,7 @@ bool find_first_plt_entry(GElfFormat *format, vmpa2t *addr)
result = false;
- content = G_BIN_FORMAT(format)->content;
+ content = G_KNOWN_FORMAT(format)->content;
while (!result)
{
@@ -161,7 +161,7 @@ bool retrieve_arm_linkage_offset(GElfFormat *format, vmpa2t *addr, uint64_t *off
*
*/
- content = G_BIN_FORMAT(format)->content;
+ content = G_KNOWN_FORMAT(format)->content;
result = g_binary_content_read_u32(content, addr, format->endian, &raw);
if (!result) goto exit;
diff --git a/plugins/elf/loading.c b/plugins/elf/loading.c
index 181c864..976dd49 100644
--- a/plugins/elf/loading.c
+++ b/plugins/elf/loading.c
@@ -422,7 +422,7 @@ GElfLoading *g_elf_loading_new_for_strings(GElfFormat *format, phys_t begin, phy
result->global_end = gb_end;
result->global_addr = addr;
- result->content = g_binary_format_get_content(G_BIN_FORMAT(format));
+ result->content = g_known_format_get_content(G_KNOWN_FORMAT(format));
init_vmpa(&pos, gb_start, addr);
@@ -590,7 +590,7 @@ const char *g_elf_loading_build_name(const GElfLoading *loading, uint32_t name,
{
init_vmpa(&pos, loading->str_start + name, VMPA_NO_VIRTUAL);
- content = G_BIN_FORMAT(format)->content;
+ content = G_KNOWN_FORMAT(format)->content;
result = (const char *)g_binary_content_get_raw_access(content, &pos, 1);
@@ -739,7 +739,7 @@ GBinSymbol *g_elf_loading_build_plt_symbol(const GElfLoading *loading, uint64_t
init_vmpa(&pos, offset, VMPA_NO_VIRTUAL);
base = G_BIN_FORMAT(format);
- content = base->content;
+ content = G_KNOWN_FORMAT(base)->content;
raw_label = (const char *)g_binary_content_get_raw_access(content, &pos, 1);
diff --git a/plugins/elf/section.c b/plugins/elf/section.c
index 2121ca9..3d87da2 100644
--- a/plugins/elf/section.c
+++ b/plugins/elf/section.c
@@ -349,7 +349,7 @@ const char *extract_name_from_elf_string_section(const GElfFormat *format, const
init_vmpa(&pos, phys, VMPA_NO_VIRTUAL);
- content = G_BIN_FORMAT(format)->content;
+ content = G_KNOWN_FORMAT(format)->content;
result = (const char *)g_binary_content_get_raw_access(content, &pos, 1);
diff --git a/plugins/elf/strings.c b/plugins/elf/strings.c
index 9b14753..e74b666 100644
--- a/plugins/elf/strings.c
+++ b/plugins/elf/strings.c
@@ -359,7 +359,7 @@ static bool do_elf_string_loading(GElfLoading *loading, GElfFormat *format, phys
{
range = g_arch_instruction_get_range(instr);
- symbol = g_string_symbol_new_read_only(SET_GUESS, base, range);
+ symbol = g_string_symbol_new_read_only(SET_GUESS, G_KNOWN_FORMAT(base), range);
g_object_ref(G_OBJECT(symbol));
diff --git a/plugins/elf/symbols.c b/plugins/elf/symbols.c
index 004ac6a..a7cf05c 100644
--- a/plugins/elf/symbols.c
+++ b/plugins/elf/symbols.c
@@ -572,7 +572,7 @@ static bool count_elf_global_symbols(GElfFormat *format, GExeFormat *exec, uint3
advance_vmpa(&addr, sizeof(uint32_t));
- result = g_binary_content_read_u32(G_BIN_FORMAT(format)->content, &addr, format->endian, count);
+ result = g_binary_content_read_u32(G_KNOWN_FORMAT(format)->content, &addr, format->endian, count);
if (!result) goto exit;
goto exit;
@@ -588,13 +588,13 @@ static bool count_elf_global_symbols(GElfFormat *format, GExeFormat *exec, uint3
result = g_exe_format_translate_address_into_vmpa(exec, ELF_DYN(format, hash, d_un.d_ptr), &addr);
if (!result) goto exit;
- result = g_binary_content_read_u32(G_BIN_FORMAT(format)->content, &addr, format->endian, &n_buckets);
+ result = g_binary_content_read_u32(G_KNOWN_FORMAT(format)->content, &addr, format->endian, &n_buckets);
if (!result) goto exit;
- result = g_binary_content_read_u32(G_BIN_FORMAT(format)->content, &addr, format->endian, &sym_offset);
+ result = g_binary_content_read_u32(G_KNOWN_FORMAT(format)->content, &addr, format->endian, &sym_offset);
if (!result) goto exit;
- result = g_binary_content_read_u32(G_BIN_FORMAT(format)->content, &addr, format->endian, &bloom_size);
+ result = g_binary_content_read_u32(G_KNOWN_FORMAT(format)->content, &addr, format->endian, &bloom_size);
if (!result) goto exit;
/* Saut de bloom_shift */
@@ -612,7 +612,7 @@ static bool count_elf_global_symbols(GElfFormat *format, GExeFormat *exec, uint3
for (i = 0; i < n_buckets; i++)
{
- result = g_binary_content_read_u32(G_BIN_FORMAT(format)->content, &addr, format->endian, &start);
+ result = g_binary_content_read_u32(G_KNOWN_FORMAT(format)->content, &addr, format->endian, &start);
if (!result) goto exit;
if (last_symbol < start)
@@ -634,7 +634,7 @@ static bool count_elf_global_symbols(GElfFormat *format, GExeFormat *exec, uint3
while (true)
{
- result = g_binary_content_read_u32(G_BIN_FORMAT(format)->content, &addr, format->endian, &value);
+ result = g_binary_content_read_u32(G_KNOWN_FORMAT(format)->content, &addr, format->endian, &value);
if (!result) goto exit;
last_symbol++;
@@ -1274,7 +1274,7 @@ static bool load_elf_entry_points_from_array(GElfFormat *format, const elf_dyn *
assert(sizeof(fullname) >= (strlen(prefix) + sizeof(XSTR(UINT64_MAX) + 1)));
base = G_BIN_FORMAT(format);
- content = base->content;
+ content = G_KNOWN_FORMAT(base)->content;
result = g_exe_format_translate_address_into_vmpa(G_EXE_FORMAT(format),
ELF_DYN(format, *array, d_un.d_val),