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

   Red Hat elfutils 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; version 2 of the License.

   Red Hat 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 Red Hat elfutils; if not, write to the Free Software Foundation,
   Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.

   Red Hat elfutils is an included package of the Open Invention Network.
   An included package of the Open Invention Network is a package for which
   Open Invention Network licensees cross-license their patents.  No patent
   license is granted, either expressly or impliedly, by designation as an
   included package.  Should you wish to participate in the Open Invention
   Network licensing program, please visit www.openinventionnetwork.com
   <http://www.openinventionnetwork.com>.  */

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

namespace
{
  struct dwarf_mips_attributes
    : public attribute_table
  {
    void unused (__attribute__ ((unused)) attribute const &attrib) const {}
    dwarf_mips_attributes ()
    {
      // Most of these are really just sketched, since we don't emit
      // them anyway.  For those in need, the documentation is in
      // mips_extensions.pdf that's installed by libdwarf-devel in
      // Fedora.  According to that document, some forms were never
      // even emitted.  Those are marked as unused and not added.
      // Their class is arbitrarily chosen as cl_constant.

      add (const_attribute (DW_AT_MIPS_fde));
      unused (const_attribute (DW_AT_MIPS_loop_begin));
      unused (const_attribute (DW_AT_MIPS_tail_loop_begin));
      unused (const_attribute (DW_AT_MIPS_epilog_begin));
      unused (const_attribute (DW_AT_MIPS_loop_unroll_factor));
      unused (const_attribute (DW_AT_MIPS_software_pipeline_depth));
      add (string_attribute (DW_AT_MIPS_linkage_name));

      // [section 8.10] If DW_AT_MIPS_stride is present, the attribute
      // contains a reference to a DIE which describes the location
      // holding the stride, and the DW_AT_stride_size field of
      // DW_TAG_array_type is ignored if present. The value of the
      // stride is the number of 4 byte words between elements along
      // that axis.
      add (ref_attribute (DW_AT_MIPS_stride));

      add (string_attribute (DW_AT_MIPS_abstract_name));

      // xxx in addition, this is supposed to be CU-local reference,
      // similarly to the DW_AT_sibling.  An opportunity to generalize
      // sibling_form_suitable.
      add (ref_attribute (DW_AT_MIPS_clone_origin));

      add (flag_attribute (DW_AT_MIPS_has_inlines));

      // The documentation is unclear on what form these should take.
      // I'm making them the same as DW_AT_byte_stride in DWARF2, in
      // hopes that that's what they are supposed to be.
      add (const_attribute (DW_AT_MIPS_stride_byte));
      add (const_attribute (DW_AT_MIPS_stride_elem));

      add (ref_attribute (DW_AT_MIPS_ptr_dopetype));
      add (ref_attribute (DW_AT_MIPS_allocatable_dopetype));
      add (ref_attribute (DW_AT_MIPS_assumed_shape_dopetype));
      add (flag_attribute (DW_AT_MIPS_assumed_size));
    }
  };

  struct dwarf_mips_ext_t
    : public std_dwarf
  {
    dwarf_mips_ext_t ()
      : std_dwarf (dwarf_mips_attributes (), form_table ())
    {}
  };
}

dwarf_version const *
dwarf_mips_ext ()
{
  static dwarf_mips_ext_t dw;
  return &dw;
}