summaryrefslogtreecommitdiffstats
path: root/dwarflint/dwarf_4.cc
blob: e398f76999fc95d187d757315de109744e706575 (plain)
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
/* Pedantic checking of DWARF files
   Copyright (C) 2010, 2011 Red Hat, Inc.
   This file is part of elfutils.

   This file 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.

   elfutils 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 this program.  If not, see <http://www.gnu.org/licenses/>.  */

#include "dwarf_version-imp.hh"
#include "dwarf_3.hh"
#include "dwarf_4.hh"
#include "../libdw/dwarf.h"

namespace
{
  struct dwarf_4_attributes
    : public attribute_table
  {
    dwarf_4_attributes ()
    {
      add (attribute (DW_AT_high_pc, dw_class_set (cl_address, cl_constant)));
      add (ref_attribute (DW_AT_namelist_item));
      add (ref_attribute (DW_AT_signature));
      add (flag_attribute (DW_AT_main_subprogram));
      add (const_attribute (DW_AT_data_bit_offset));
      add (flag_attribute (DW_AT_const_expr));
      add (flag_attribute (DW_AT_enum_class));
      add (string_attribute (DW_AT_linkage_name));
    }
  };

  struct exprloc_form
    : public preset_form<sc_block, cl_exprloc>
  {
    exprloc_form (int a_name)
      : preset_form<sc_block, cl_exprloc> (a_name, fw_uleb)
    {}
  };

  struct dwarf_4_forms
    : public form_table
  {
    dwarf_4_forms ()
    {
      add (const_form (DW_FORM_data4, fw_4));
      add (const_form (DW_FORM_data8, fw_8));
      add (offset_form (DW_FORM_sec_offset,
			dw_class_set (cl_lineptr, cl_loclistptr,
				      cl_macptr, cl_rangelistptr)));
      add (exprloc_form (DW_FORM_exprloc));
      add (flag_form (DW_FORM_flag_present, fw_0));

      // http://wiki.dwarfstd.org/index.php?title=COMDAT_Type_Sections
      add (ref_form (DW_FORM_ref_sig8, fw_8));

      // In DWARF 2 we claim that blocks are exprloc forms (see
      // comment there).  Revert back to pure blocks now that we have
      // proper support for cl_exprloc.
      add (block_form (DW_FORM_block, fw_uleb));
      add (block_form (DW_FORM_block1, fw_1));
      add (block_form (DW_FORM_block2, fw_2));
      add (block_form (DW_FORM_block4, fw_4));
    }
  };

  struct dwarf_4_ext_t
    : public std_dwarf
  {
    dwarf_4_ext_t ()
      : std_dwarf (dwarf_4_attributes (), dwarf_4_forms ())
    {}
  };
}

dwarf_version const *
dwarf_4_ext ()
{
  static dwarf_4_ext_t dw;
  return &dw;
}

dwarf_version const *
dwarf_4 ()
{
  static dwarf_version const *dw =
    dwarf_version::extend (dwarf_3 (), dwarf_4_ext ());
  return dw;
}