diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2008-09-06 13:56:57 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2008-09-06 13:56:57 (GMT) |
commit | f14993aac5b0b4b7ae174f27e4d1f0f540057c58 (patch) | |
tree | fcb3ef8e5b2965a79f7ae9984e1c0c783f5530eb /src/format/elf | |
parent | ada3040b9b2b6d0a2d6e2157b3f79e772e36b2d7 (diff) |
Added a panel allowing to browse found symbols.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@24 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/elf')
-rw-r--r-- | src/format/elf/e_elf.c | 39 | ||||
-rw-r--r-- | src/format/elf/e_elf.h | 6 |
2 files changed, 44 insertions, 1 deletions
diff --git a/src/format/elf/e_elf.c b/src/format/elf/e_elf.c index a6399ab..0493df8 100644 --- a/src/format/elf/e_elf.c +++ b/src/format/elf/e_elf.c @@ -59,6 +59,7 @@ elf_format *load_elf(const uint8_t *content, off_t length) EXE_FORMAT(result)->length = length; EXE_FORMAT(result)->find_section = (find_section_fc)find_elf_section; + EXE_FORMAT(result)->get_symbols = (get_symbols_fc)get_elf_symbols; memcpy(&result->header, content, sizeof(Elf32_Ehdr)); @@ -75,3 +76,41 @@ elf_format *load_elf(const uint8_t *content, off_t length) return result; } + + +/****************************************************************************** +* * +* Paramètres : format = informations chargées à consulter. * +* labels = liste des commentaires à insérer. [OUT] * +* types = type des symboles listés. [OUT] * +* offsets = liste des indices des commentaires. [OUT] * +* * +* Description : Récupère tous les symboles présents dans le contenu binaire. * +* * +* Retour : Nombre d'éléments mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +size_t get_elf_symbols(const elf_format *format, char ***labels, SymbolType **types, uint64_t **offsets) +{ + size_t result; /* Quantité à retourner */ + size_t i; /* Boucle de parcours */ + + result = format->sym_count; + + *labels = (char **)calloc(result, sizeof(char *)); + *types = (SymbolType *)calloc(result, sizeof(SymbolType)); + *offsets = (uint64_t *)calloc(result, sizeof(uint64_t)); + + for (i = 0; i < format->sym_count; i++) + { + (*labels)[i] = strdup(format->symbols[i].name); + (*types)[i] = STP_SECTION; + (*offsets)[i] = format->symbols[i].address; + } + + return result; + +} diff --git a/src/format/elf/e_elf.h b/src/format/elf/e_elf.h index fabee77..d4bf39b 100644 --- a/src/format/elf/e_elf.h +++ b/src/format/elf/e_elf.h @@ -30,6 +30,9 @@ #include <sys/types.h> +#include "../exe_format.h" + + /* Description du format ELF */ typedef struct _elf_format elf_format; @@ -39,7 +42,8 @@ typedef struct _elf_format elf_format; /* Prend en charge un nouvel ELF. */ elf_format *load_elf(const uint8_t *, off_t); - +/* Récupère tous les symboles présents dans le contenu binaire. */ +size_t get_elf_symbols(const elf_format *, char ***, SymbolType **, uint64_t **); |