]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Add a GNU extension
authorPetr Machata <pmachata@redhat.com>
Mon, 18 Oct 2010 16:29:05 +0000 (18:29 +0200)
committerPetr Machata <pmachata@redhat.com>
Mon, 18 Oct 2010 16:29:05 +0000 (18:29 +0200)
dwarflint/Makefile.am
dwarflint/dwarf_4.cc
dwarflint/dwarf_gnu.cc [new file with mode: 0644]
dwarflint/dwarf_gnu.hh [new file with mode: 0644]
dwarflint/dwarf_version.cc

index 6d73fae650e6b10510d1481fdaa7009f6f838a67..cb0e84a85e4f4c87f8eb9c871097655531bb1f0d 100644 (file)
@@ -49,6 +49,7 @@ dwarflint_SOURCES = \
        dwarf_2.cc dwarf_2.hh \
        dwarf_3.cc dwarf_3.hh \
        dwarf_4.cc dwarf_4.hh \
+       dwarf_gnu.cc dwarf_gnu.hh \
        dwarf_mips.cc dwarf_mips.hh \
        dwarf_version-imp.cc dwarf_version-imp.hh \
        dwarf_version.cc dwarf_version.hh dwarf_version.ii \
index 3894c4999a119c8b05aed62746df2e72dde56a77..812eef6275b6378f68db6ef3bbc4265a71196fe8 100644 (file)
@@ -66,6 +66,9 @@ namespace
                                      cl_macptr, cl_rangelistptr)));
       add (exprloc_form (DW_FORM_exprloc));
       add (flag_form (DW_FORM_flag_present, fw_0));
+
+      // xxx This actually needs to be something like ref8_form.  This
+      // and DW_AT_GNU_odr_signature.
       add (ref_form (DW_FORM_ref_sig8, fw_8));
 
       // In DWARF 2 we claim that blocks are exprloc forms (see
diff --git a/dwarflint/dwarf_gnu.cc b/dwarflint/dwarf_gnu.cc
new file mode 100644 (file)
index 0000000..243b30d
--- /dev/null
@@ -0,0 +1,92 @@
+/* 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_gnu_attributes
+    : public attribute_table
+  {
+    void unused (__attribute__ ((unused)) attribute const &attrib) const {}
+    dwarf_gnu_attributes ()
+    {
+      // It's rather hard to find any reference on some of the GNU
+      // extensions.  So we simply mark these with unused.
+
+      // The MIPS documentation claims that these are "apparently only
+      // output in DWARF1, not DWARF2".  I found nothing particular
+      // about how these are used.
+      unused (const_attribute (DW_AT_sf_names));
+      unused (const_attribute (DW_AT_src_info));
+      unused (const_attribute (DW_AT_mac_info));
+      unused (const_attribute (DW_AT_src_coords));
+      unused (const_attribute (DW_AT_body_begin));
+      unused (const_attribute (DW_AT_body_end));
+
+      add (flag_attribute (DW_AT_GNU_vector));
+
+      // http://gcc.gnu.org/wiki/ThreadSafetyAnnotationsInDWARF
+
+      // xxx these are glass cl_GNU_mutexlistptr.  data4 and data8 are
+      // supposed to have this class.  So how do we smuggle this class
+      // to whatever DW_FORM_data4 and DW_FORM_data8 have in current
+      // version?  For now, just claim it's plain old constant.
+      add (const_attribute (DW_AT_GNU_guarded_by));
+      add (const_attribute (DW_AT_GNU_pt_guarded_by));
+      add (const_attribute (DW_AT_GNU_guarded));
+      add (const_attribute (DW_AT_GNU_pt_guarded));
+      add (const_attribute (DW_AT_GNU_locks_excluded));
+      add (const_attribute (DW_AT_GNU_exclusive_locks_required));
+      add (const_attribute (DW_AT_GNU_shared_locks_required));
+
+      // Contains a shallower 8-byte signature of the type described
+      // in the type unit.  We encode it the same way as
+      // DW_AT_signature, which AFAICT is just a standardized name of
+      // DW_AT_GNU_odr_signature.
+      // http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo
+      // http://wiki.dwarfstd.org/index.php?title=COMDAT_Type_Sections
+      add (ref_attribute (DW_AT_GNU_odr_signature));
+
+      add (string_attribute (DW_AT_GNU_template_name)); // xxx ???
+    }
+  };
+
+  struct dwarf_gnu_ext_t
+    : public std_dwarf
+  {
+    dwarf_gnu_ext_t ()
+      : std_dwarf (dwarf_gnu_attributes (), form_table ())
+    {}
+  };
+}
+
+dwarf_version const *
+dwarf_gnu_ext ()
+{
+  static dwarf_gnu_ext_t dw;
+  return &dw;
+}
diff --git a/dwarflint/dwarf_gnu.hh b/dwarflint/dwarf_gnu.hh
new file mode 100644 (file)
index 0000000..dde52f4
--- /dev/null
@@ -0,0 +1,33 @@
+/* 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>.  */
+
+#ifndef DWARFLINT_DWARF_GNU_HH
+#define DWARFLINT_DWARF_GNU_HH
+
+#include "dwarf_version.ii"
+
+dwarf_version const *dwarf_gnu_ext ();
+
+#endif//DWARFLINT_DWARF_GNU_HH
index 669a5f8a6d795b87e2fe60c2a304b4f0629e6f58..a8536b7129fe99188873bb258308d4fd8e5dce0d 100644 (file)
@@ -31,6 +31,7 @@
 #include "dwarf_2.hh"
 #include "dwarf_3.hh"
 #include "dwarf_4.hh"
+#include "dwarf_gnu.hh"
 #include "dwarf_mips.hh"
 #include "check_debug_info.hh"
 #include "pri.hh"
@@ -227,24 +228,27 @@ dwarf_version::get (unsigned version)
   // I wonder how to solve this "right".  We cannot simply request
   // DW_AT_producer/DW_AT_language values here, since we need the
   // version to know how to read these attributes in the first place.
+  //
+  // Similarly we assume the GNU extension is used.
+  static dwarf_version const *ext = extend (dwarf_mips_ext (), dwarf_gnu_ext ());
 
   switch (version)
     {
     case 2:
       {
-       static dwarf_version const *dw = extend (dwarf_2 (), dwarf_mips_ext ());
+       static dwarf_version const *dw = extend (dwarf_2 (), ext);
        return dw;
       }
 
     case 3:
       {
-       static dwarf_version const *dw = extend (dwarf_3 (), dwarf_mips_ext ());
+       static dwarf_version const *dw = extend (dwarf_3 (), ext);
        return dw;
       }
 
     case 4:
       {
-       static dwarf_version const *dw = extend (dwarf_4 (), dwarf_mips_ext ());
+       static dwarf_version const *dw = extend (dwarf_4 (), ext);
        return dw;
       }