From 0554c9bfb7def1e021127208f5351bded62aa659 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Wed, 9 Mar 2022 17:29:26 -0800 Subject: Remove 4146 from libunwind This converts the invalid arithmetic negation on an unsigned value to use the identity of bitwise negation plus one. --- src/dwarf/Gexpr.c | 4 ++-- src/dwarf/Gparser.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/dwarf') diff --git a/src/dwarf/Gexpr.c b/src/dwarf/Gexpr.c index 963a064d..977c5593 100644 --- a/src/dwarf/Gexpr.c +++ b/src/dwarf/Gexpr.c @@ -530,7 +530,7 @@ if (stackerror) \ Debug (15, "OP_abs\n"); tmp1 = pop (); if (tmp1 & ((unw_word_t) 1 << (8 * dwarf_addr_size (as) - 1))) - tmp1 = -tmp1; + tmp1 = (~tmp1 + 1); push (tmp1); break; @@ -578,7 +578,7 @@ if (stackerror) \ case DW_OP_neg: Debug (15, "OP_neg\n"); - push (-pop ()); + push (~pop () + 1); break; case DW_OP_not: diff --git a/src/dwarf/Gparser.c b/src/dwarf/Gparser.c index edd34526..3f3722a3 100644 --- a/src/dwarf/Gparser.c +++ b/src/dwarf/Gparser.c @@ -397,9 +397,9 @@ run_cfi_program (struct dwarf_cursor *c, dwarf_state_record_t *sr, if (((ret = read_regnum (as, a, addr, ®num, arg)) < 0) || ((ret = dwarf_read_uleb128 (as, a, addr, &val, arg)) < 0)) break; - set_reg (sr, regnum, DWARF_WHERE_CFAREL, -(val * dci->data_align)); + set_reg (sr, regnum, DWARF_WHERE_CFAREL, ~(val * dci->data_align) + 1); Debug (15, "CFA_GNU_negative_offset_extended cfa+0x%lx\n", - (long) -(val * dci->data_align)); + (long) (~(val * dci->data_align) + 1)); break; case DW_CFA_GNU_window_save: -- cgit v1.2.1