diff options
author | Tom Tromey <tromey@adacore.com> | 2025-03-19 07:25:55 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2025-04-24 13:25:08 -0600 |
commit | 21b5371ef19ebf2659dfa7061c892d1ba382a9f0 (patch) | |
tree | 2d57f22c53223c70430583529121a77c062c68da /gdb | |
parent | 898477d819f4917609cfacb1ab1a2ee550b53a78 (diff) | |
download | binutils-21b5371ef19ebf2659dfa7061c892d1ba382a9f0.zip binutils-21b5371ef19ebf2659dfa7061c892d1ba382a9f0.tar.gz binutils-21b5371ef19ebf2659dfa7061c892d1ba382a9f0.tar.bz2 |
Use correct sign for DW_AT_GNU_bias
DW_AT_GNU_bias may be signed or unsigned, depending on the underlying
type. This patch changes the DWARF reader to examine the type before
decoding the attribute.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32680
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/dwarf2/read.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index e29fef0..8941643 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -14096,8 +14096,13 @@ read_subrange_type (struct die_info *die, struct dwarf2_cu *cu) LONGEST bias = 0; struct attribute *bias_attr = dwarf2_attr (die, DW_AT_GNU_bias, cu); - if (bias_attr != nullptr && bias_attr->form_is_constant ()) - bias = bias_attr->constant_value (0); + if (bias_attr != nullptr) + { + if (base_type->is_unsigned ()) + bias = (LONGEST) bias_attr->unsigned_constant ().value_or (0); + else + bias = bias_attr->signed_constant ().value_or (0); + } /* Normally, the DWARF producers are expected to use a signed constant form (Eg. DW_FORM_sdata) to express negative bounds. |