summaryrefslogtreecommitdiff
path: root/plugins/dwarf/v4/form.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-11-24 11:41:13 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-11-24 11:41:13 (GMT)
commitdad453ff553f0ab07206f26345dc0adeffb775fd (patch)
tree322f3b26da0d0d25011b7e64afc7c7ee37aa5608 /plugins/dwarf/v4/form.c
parent615171f171f53791a25aeab7970e29b024177d48 (diff)
Moved the DWARF support as plugin and disabled it.
Diffstat (limited to 'plugins/dwarf/v4/form.c')
-rw-r--r--plugins/dwarf/v4/form.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/plugins/dwarf/v4/form.c b/plugins/dwarf/v4/form.c
new file mode 100644
index 0000000..80dbf1e
--- /dev/null
+++ b/plugins/dwarf/v4/form.c
@@ -0,0 +1,106 @@
+
+/* 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 <http://www.gnu.org/licenses/>.
+ */
+
+
+#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;
+
+}