summaryrefslogtreecommitdiff
path: root/src/format/elf/elf.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2015-02-11 17:05:54 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2015-02-11 17:05:54 (GMT)
commitbf879f2562545ab7de23f9d38364b7bd4b43fb2c (patch)
tree6154160307cbca304ea9e1de178d8c2dfc8e0928 /src/format/elf/elf.c
parentabd96dbbe27246e9303173e5e2f47b2e4cedbcb7 (diff)
Registered all the supported formats in the system code.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@471 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/elf/elf.c')
-rw-r--r--src/format/elf/elf.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/format/elf/elf.c b/src/format/elf/elf.c
index cc84335..f0c361e 100644
--- a/src/format/elf/elf.c
+++ b/src/format/elf/elf.c
@@ -72,9 +72,7 @@ static bool g_elf_format_translate_offset_into_address(const GElfFormat *, off_t
/******************************************************************************
* *
-* Paramètres : type = type de format recherché. *
-* content = contenu binaire à parcourir. *
-* length = taille du contenu en question. *
+* Paramètres : content = contenu binaire à parcourir. *
* *
* Description : Indique si le format peut être pris en charge ici. *
* *
@@ -84,14 +82,17 @@ static bool g_elf_format_translate_offset_into_address(const GElfFormat *, off_t
* *
******************************************************************************/
-bool elf_is_matching(FormatType type, const bin_t *content, off_t length)
+bool elf_is_matching(GBinContent *content)
{
bool result; /* Bilan à faire connaître */
+ vmpa2t addr; /* Tête de lecture initiale */
+ char magic[4]; /* Idenfiant standard */
+
+ init_vmpa(&addr, 0, VMPA_NO_VIRTUAL);
- result = false;
+ result = g_binary_content_get_raw(content, &addr, 4, (bin_t *)magic);
- if (length >= 4)
- result = (memcmp(content, "\x7f\x45\x4c\x46" /* .ELF */, 4) == 0);
+ result &= (memcmp(magic, "\x7f\x45\x4c\x46" /* .ELF */, 4) == 0);
return result;
@@ -150,7 +151,6 @@ static void g_elf_format_init(GElfFormat *format)
/******************************************************************************
* *
* Paramètres : content = contenu binaire à parcourir. *
-* length = taille du contenu en question. *
* *
* Description : Prend en charge un nouveau format ELF. *
* *
@@ -160,13 +160,13 @@ static void g_elf_format_init(GElfFormat *format)
* *
******************************************************************************/
-GBinFormat *g_elf_format_new(const bin_t *content, off_t length)
+GBinFormat *g_elf_format_new(GBinContent *content)
{
GElfFormat *result; /* Structure à retourner */
result = g_object_new(G_TYPE_ELF_FORMAT, NULL);
- g_binary_format_set_content(G_BIN_FORMAT(result), content, length);
+ g_binary_format_set_content(G_BIN_FORMAT(result), content);
if (!read_elf_header(result, &result->header, &result->is_32b, &result->endian))
{
@@ -196,6 +196,7 @@ GBinFormat *g_elf_format_new(const bin_t *content, off_t length)
}
/* FIXME : à améliorer */
+ /*
if ((ELF_HDR(result, result->header, e_shnum) * ELF_HDR(result, result->header, e_shentsize)) >= length)
{
log_variadic_message(LMT_BAD_BINARY, ("Suspicious section table (bigger than the binary !) ; reset ! -- replacing 0x%04hx by 0x%04hx at offset 0x%x"),
@@ -203,7 +204,7 @@ GBinFormat *g_elf_format_new(const bin_t *content, off_t length)
0, ELF_HDR_OFFSET_OF(result, e_shnum));
ELF_HDR_SET(result, result->header, e_shnum, 0);
}
-
+ */