]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Assume DW_AT_alignment is unsigned
authorTom Tromey <tromey@adacore.com>
Thu, 6 Feb 2025 17:56:54 +0000 (10:56 -0700)
committerTom Tromey <tromey@adacore.com>
Tue, 18 Mar 2025 18:40:58 +0000 (12:40 -0600)
This changes get_alignment to assume that DW_AT_alignment refers to an
unsigned value.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/dwarf2/read.c

index e5744ebac9c823b991aa2d454f0e848152977183..6d173a54af19200f767af29255da2983e07057d1 100644 (file)
@@ -11131,16 +11131,11 @@ get_alignment (struct dwarf2_cu *cu, struct die_info *die)
       return 0;
     }
 
-  LONGEST val = attr->constant_value (0);
-  if (val < 0)
-    {
-      complaint (_("DW_AT_alignment value must not be negative"
-                  " - DIE at %s [in module %s]"),
-                sect_offset_str (die->sect_off),
-                objfile_name (cu->per_objfile->objfile));
-      return 0;
-    }
-  ULONGEST align = val;
+  std::optional<ULONGEST> val = attr->unsigned_constant ();
+  if (!val.has_value ())
+    return 0;
+
+  ULONGEST align = *val;
 
   if (align == 0)
     {