/* Chrysalide - Outil d'analyse de fichiers binaires * form.c - chargement en mémoire des valeurs d'attributs * * Copyright (C) 2016-2017 Cyrille Bagard * * This file is part of Chrysalide. * * Chrysalide 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. * * Chrysalide 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 Chrysalide. If not, see . */ #include "form.h" #include "../dwarf-int.h" #include "../v2/form.h" /****************************************************************************** * * * Paramètres : format = contenu binaire de débogage à parcourir. * * cu = unité de compilation parente. * * form = nature de la valeur à lire. * * pos = tête de lecture au sein des données. [OUT] * * value = valeur au format donné lue. [OUT] * * * * Description : Lit la valeur correspondant à un type donné. * * * * Retour : Bilan de l'opération. * * * * Remarques : - * * * ******************************************************************************/ bool read_dwarf_v4_form_value(const GDwarfFormat *format, const dw_compil_unit_header *cu, DwarfForm form, vmpa2t *pos, dw_v4_form_value *value) { bool result; /* Bilan de lecture à renvoyer */ GBinContent *content; /* Contenu binaire à parcourir */ SourceEndian endian; /* Boutisme des enregistrements*/ uint32_t tmp32; /* Données sur 32 bits */ uint64_t tmp64; /* Données sur 64 bits */ uleb128_t tmpuleb; /* Données sur xxx bits */ content = G_BIN_FORMAT(format)->content; endian = g_binary_format_get_endianness(G_BIN_FORMAT(format)); switch (form) { case DW_FORM_sec_offset: if (cu->is_32b) { result = g_binary_content_read_u32(content, pos, endian, &tmp32); tmp64 = tmp32; } else result = g_binary_content_read_u64(content, pos, endian, &tmp64); value->sec_offset = tmp64; break; case DW_FORM_exprloc: tmpuleb = 0; /* Pour GCC */ result = g_binary_content_read_uleb128(content, pos, &tmpuleb); if (!result) break; value->expr.size = tmpuleb; value->expr.start = g_binary_content_get_raw_access(content, pos, value->expr.size); result = (value->expr.start != NULL); break; case DW_FORM_flag_present: result = true; value->has_flag = true; break; case DW_FORM_ref_sig8: result = g_binary_content_read_u64(content, pos, endian, &value->signature); break; default: result = read_dwarf_v2_form_value(format, cu, form, pos, &value->v2); break; } return result; }