1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/* Chrysalide - Outil d'analyse de fichiers binaires
* form.c - chargement en mémoire des valeurs d'attributs
*
* Copyright (C) 2015 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 Foobar. 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;
}
|