diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2015-08-12 19:05:31 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2015-08-12 19:05:31 (GMT) |
commit | 4b2f65ed2125cd7b6ef598cf02738f6c839d8935 (patch) | |
tree | de62e9daaafe63248c45202004758e91b7341cc5 /src/format/dwarf/dwarf-int.c | |
parent | b5c6bcea25b1b840fd6c8e89a4a3c9fbd83ba84b (diff) |
Extended the loading process of binary formats to prepare the DWARF support.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@568 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/format/dwarf/dwarf-int.c')
-rw-r--r-- | src/format/dwarf/dwarf-int.c | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/format/dwarf/dwarf-int.c b/src/format/dwarf/dwarf-int.c new file mode 100644 index 0000000..310f926 --- /dev/null +++ b/src/format/dwarf/dwarf-int.c @@ -0,0 +1,75 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * dwarf-int.c - structures internes du format DWARF + * + * Copyright (C) 2015 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * OpenIDA is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * OpenIDA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "dwarf-int.h" + + + +/****************************************************************************** +* * +* Paramètres : format = informations chargées à consulter. * +* pos = position de début de lecture. [OUT] * +* endian = boutisme reconnu dans le format. * +* header = en-tête à déterminer. [OUT] * +* * +* Description : Procède à la lecture de l'en-tête d'un contenu binaire ELF. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool read_dwarf_section_header(GBinContent *content, vmpa2t *pos, SourceEndian endian, dw_section_header *header) +{ + bool result; /* Bilan à retourner */ + uint32_t first; /* Premier paquet d'octets */ + bool status; /* Bilan d'opération */ + + result = false; + + status = g_binary_content_read_u32(content, pos, endian, &first); + if (!status) goto rdsh_exit; + + if (first >= 0xfffffff0 && first != 0xffffffff) + goto rdsh_exit; + + if (first == 0xffffffff) + { + result = g_binary_content_read_u64(content, pos, endian, &header->unit_length); + header->is_32b = false; + } + else + { + result = true; + header->unit_length = first; + header->is_32b = true; + } + + result &= g_binary_content_read_u16(content, pos, endian, &header->version); + + rdsh_exit: + + return result; + +} |