Skip to content

Commit

Permalink
Remove 4146 from libunwind (dotnet#66427)
Browse files Browse the repository at this point in the history
* Remove 4146 from libunwind

Use existing libunwind align macro and use casting
  when the operation's target should reflect a signed value.
  • Loading branch information
AaronRobinsonMSFT authored and radekdoulik committed Mar 30, 2022
1 parent 89542e5 commit be40f94
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/coreclr/pal/src/libunwind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ if(CLR_CMAKE_HOST_WIN32)

# Warnings in release builds
add_compile_options(-wd4068) # ignore unknown pragma warnings (gcc pragmas)
add_compile_options(-wd4146) # minus operator applied to unsigned
add_compile_options(-wd4244) # possible loss of data
add_compile_options(-wd4334) # 32-bit shift implicitly converted to 64 bits

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/pal/src/libunwind/include/dwarf_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static inline int
dwarf_readu8 (unw_addr_space_t as, unw_accessors_t *a, unw_word_t *addr,
uint8_t *valp, void *arg)
{
unw_word_t val, aligned_addr = *addr & -sizeof (unw_word_t);
unw_word_t val, aligned_addr = UNW_ALIGN(*addr, sizeof (unw_word_t));
unw_word_t off = *addr - aligned_addr;
int ret;

Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/pal/src/libunwind/include/remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ static inline int
fetch8 (unw_addr_space_t as, unw_accessors_t *a,
unw_word_t *addr, int8_t *valp, void *arg)
{
unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr;
unw_word_t val, aligned_addr = UNW_ALIGN(*addr, WSIZE), off = *addr - aligned_addr;
int ret;

*addr += 1;
Expand All @@ -71,7 +71,7 @@ static inline int
fetch16 (unw_addr_space_t as, unw_accessors_t *a,
unw_word_t *addr, int16_t *valp, void *arg)
{
unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr;
unw_word_t val, aligned_addr = UNW_ALIGN(*addr, WSIZE), off = *addr - aligned_addr;
int ret;

if ((off & 0x1) != 0)
Expand All @@ -94,7 +94,7 @@ static inline int
fetch32 (unw_addr_space_t as, unw_accessors_t *a,
unw_word_t *addr, int32_t *valp, void *arg)
{
unw_word_t val, aligned_addr = *addr & -WSIZE, off = *addr - aligned_addr;
unw_word_t val, aligned_addr = UNW_ALIGN(*addr, WSIZE), off = *addr - aligned_addr;
int ret;

if ((off & 0x3) != 0)
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/pal/src/libunwind/src/dwarf/Gexpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (unw_word_t)(-(unw_sword_t)tmp1);
push (tmp1);
break;

Expand Down Expand Up @@ -578,7 +578,7 @@ if (stackerror) \

case DW_OP_neg:
Debug (15, "OP_neg\n");
push (-pop ());
push (-(unw_sword_t)pop ());
break;

case DW_OP_not:
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/pal/src/libunwind/src/dwarf/Gparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,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, (unw_word_t)(-(unw_sword_t)val));
Debug (15, "CFA_GNU_negative_offset_extended cfa+0x%lx\n",
(long) -(val * dci->data_align));
(long)(unw_word_t)(-(unw_sword_t)val));
break;

case DW_CFA_GNU_window_save:
Expand Down

0 comments on commit be40f94

Please sign in to comment.