summaryrefslogtreecommitdiff
path: root/src/dwarf
diff options
context:
space:
mode:
authorAaron Robinson <arobins@microsoft.com>2022-03-09 17:29:26 -0800
committerDave Watson <dade.watson@gmail.com>2022-05-22 10:58:11 -0700
commit0554c9bfb7def1e021127208f5351bded62aa659 (patch)
tree439a1f15f6f5e071cd730952c6fadcff14f2303c /src/dwarf
parent19eebe4b42d41a83763efcb8739a625fc1b8f39b (diff)
downloadlibunwind-0554c9bfb7def1e021127208f5351bded62aa659.tar.gz
Remove 4146 from libunwind
This converts the invalid arithmetic negation on an unsigned value to use the identity of bitwise negation plus one.
Diffstat (limited to 'src/dwarf')
-rw-r--r--src/dwarf/Gexpr.c4
-rw-r--r--src/dwarf/Gparser.c4
2 files changed, 4 insertions, 4 deletions
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, &regnum, 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: