]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
dwarflint: Add --nognu option for not using the GNU extension to DWARF
authorPetr Machata <pmachata@redhat.com>
Mon, 18 Oct 2010 17:56:42 +0000 (19:56 +0200)
committerPetr Machata <pmachata@redhat.com>
Mon, 18 Oct 2010 17:56:42 +0000 (19:56 +0200)
dwarflint/dwarf_gnu.cc
dwarflint/dwarf_version.cc

index 243b30dc5025209ca935e51517a1a5c2b360689a..36c826c25860a5ef04f974047ad54e5f444d56ff 100644 (file)
@@ -49,12 +49,11 @@ namespace
 
       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.
+      // http://gcc.gnu.org/wiki/ThreadSafetyAnnotationsInDWARF
       add (const_attribute (DW_AT_GNU_guarded_by));
       add (const_attribute (DW_AT_GNU_pt_guarded_by));
       add (const_attribute (DW_AT_GNU_guarded));
index a8536b7129fe99188873bb258308d4fd8e5dce0d..9b4ebaaf8e79926b6ecc4dbb561dbb984c2c2923 100644 (file)
@@ -220,17 +220,31 @@ dwarf_version::extend (dwarf_version const *source,
   return new dwarf_version_union (source, extension);
 }
 
+global_opt<void_option>
+  nognu ("Don't use GNU extension.", "nognu");
+
+namespace
+{
+  dwarf_version const *get_ext ()
+  {
+    // xxx The GNU toolchain commonly uses DW_AT_MIPS_linkage_name,
+    // which is part of the MIPS extensions.  So that's what we
+    // return.  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.
+
+    if (nognu)
+      return dwarf_mips_ext ();
+    else
+      return dwarf_version::extend (dwarf_mips_ext (), dwarf_gnu_ext ());
+  }
+}
+
 dwarf_version const *
 dwarf_version::get (unsigned version)
 {
-  // xxx The GNU toolchain commonly uses DW_AT_MIPS_linkage_name,
-  // which is part of the MIPS extensions.  So that's what we return.
-  // 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 ());
+  static dwarf_version const *ext = get_ext ();
 
   switch (version)
     {
@@ -252,7 +266,8 @@ dwarf_version::get (unsigned version)
        return dw;
       }
 
-    default: return NULL;
+    default:
+      return NULL;
     };
 }