From: Tom Tromey Date: Thu, 6 Feb 2025 17:56:54 +0000 (-0700) Subject: Assume DW_AT_alignment is unsigned X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dfcc760bcc714eb22110aa6fa2380053ccc688c5;p=thirdparty%2Fbinutils-gdb.git Assume DW_AT_alignment is unsigned This changes get_alignment to assume that DW_AT_alignment refers to an unsigned value. Approved-By: Simon Marchi --- diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e5744ebac9c..6d173a54af1 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -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 val = attr->unsigned_constant (); + if (!val.has_value ()) + return 0; + + ULONGEST align = *val; if (align == 0) {