From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Subject: [PATCH, applied] dwarf-reader: Support DW_OP_GNU_variable_value
Date: Wed, 05 Apr 2023 18:07:56 +0200 [thread overview]
Message-ID: <87cz4il3c3.fsf@redhat.com> (raw)
Hello,
This solves a crash that happened with self-comparing the package
'aws' in Fedora by doing:
$ fedabipkgdiff --self-compare -a --from fc37 aws
When evaluating a DWARF expression with
eval_last_constant_dwarf_sub_expr, indirectly called from
die_member_offset, the DW_OP_GNU_variable_value appears not being
supported.
This patch adds the support for that.
To help with figuring that kind of issue in the future, I
have added a few asserts in the code of op_is_arith_logic.
* src/abg-dwarf-reader.cc (op_pushes_non_constant_value): Support
DW_OP_GNU_variable_value.
(op_is_arith_logic): Add a number of asserts and guards here.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
src/abg-dwarf-reader.cc | 44 ++++++++++++++++++++++++++++++++++++-----
1 file changed, 39 insertions(+), 5 deletions(-)
diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 4b43cf54..c0a35bca 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -7952,6 +7952,10 @@ op_pushes_non_constant_value(Dwarf_Op* ops,
next_index = index + 1;
break;
+ case DW_OP_GNU_variable_value:
+ next_index = index + 1;
+ break;
+
default:
return false;
}
@@ -8119,13 +8123,16 @@ op_is_arith_logic(Dwarf_Op* expr,
Dwarf_Op& op = expr[index];
expr_result val1, val2;
+ bool result = false;
switch (op.atom)
{
case DW_OP_abs:
+ ABG_ASSERT(ctxt.stack.size() > 0);
val1 = ctxt.pop();
val1 = val1.abs();
ctxt.push(val1);
+ result = true;
break;
case DW_OP_and:
@@ -8136,87 +8143,114 @@ op_is_arith_logic(Dwarf_Op* expr,
break;
case DW_OP_div:
+ ABG_ASSERT(ctxt.stack.size() > 1);
val1 = ctxt.pop();
val2 = ctxt.pop();
if (!val1.is_const())
val1 = 1;
ctxt.push(val2 / val1);
+ result = true;
break;
case DW_OP_minus:
+ ABG_ASSERT(ctxt.stack.size() > 1);
val1 = ctxt.pop();
val2 = ctxt.pop();
ctxt.push(val2 - val1);
+ result = true;
break;
case DW_OP_mod:
+ ABG_ASSERT(ctxt.stack.size() > 1);
val1 = ctxt.pop();
val2 = ctxt.pop();
ctxt.push(val2 % val1);
+ result = true;
break;
case DW_OP_mul:
+ ABG_ASSERT(ctxt.stack.size() > 1);
val1 = ctxt.pop();
val2 = ctxt.pop();
ctxt.push(val2 * val1);
+ result = true;
break;
case DW_OP_neg:
+ ABG_ASSERT(ctxt.stack.size() > 0);
val1 = ctxt.pop();
ctxt.push(-val1);
+ result = true;
break;
case DW_OP_not:
+ ABG_ASSERT(ctxt.stack.size() > 0);
val1 = ctxt.pop();
ctxt.push(~val1);
+ result = true;
break;
case DW_OP_or:
+ ABG_ASSERT(ctxt.stack.size() > 1);
val1 = ctxt.pop();
val2 = ctxt.pop();
ctxt.push(val1 | val2);
+ result = true;
break;
case DW_OP_plus:
+ ABG_ASSERT(ctxt.stack.size() > 1);
val1 = ctxt.pop();
val2 = ctxt.pop();
ctxt.push(val2 + val1);
+ result = true;
break;
case DW_OP_plus_uconst:
+ ABG_ASSERT(ctxt.stack.size() > 0);
val1 = ctxt.pop();
val1 += op.number;
ctxt.push(val1);
+ result = true;
break;
case DW_OP_shl:
+ ABG_ASSERT(ctxt.stack.size() > 1);
val1 = ctxt.pop();
val2 = ctxt.pop();
ctxt.push(val2 << val1);
+ result = true;
break;
case DW_OP_shr:
case DW_OP_shra:
+ ABG_ASSERT(ctxt.stack.size() > 1);
val1 = ctxt.pop();
val2 = ctxt.pop();
ctxt.push(val2 >> val1);
+ result = true;
break;
case DW_OP_xor:
+ ABG_ASSERT(ctxt.stack.size() > 1);
val1 = ctxt.pop();
val2 = ctxt.pop();
ctxt.push(val2 ^ val1);
+ result = true;
break;
default:
- return false;
+ break;
}
- if (ctxt.stack.front().is_const())
- ctxt.accum = ctxt.stack.front();
+ if (result == true)
+ {
+ if (ctxt.stack.front().is_const())
+ ctxt.accum = ctxt.stack.front();
- next_index = index + 1;
- return true;
+ next_index = index + 1;
+ }
+ return result;;
}
/// If the current operation in the dwarf expression represents a push
--
2.39.2
--
Dodji
reply other threads:[~2023-04-05 16:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87cz4il3c3.fsf@redhat.com \
--to=dodji@redhat.com \
--cc=libabigail@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).