Skip to content

Commit 11e1d46

Browse files
committed
[lldb] Fix UBSan complaints for #151460
1 parent d09dbda commit 11e1d46

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_arm64.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ class RegisterInfoPOSIX_arm64
4646

4747
// based on RegisterContextDarwin_arm64.h
4848
// Pack this so there are no extra bytes, but align its start address to at
49-
// least 4 bytes to prevent alignment errors on Arm 32-bit.
49+
// least 8 bytes to prevent alignment errors.
5050
LLVM_PACKED_START
51-
struct alignas(4) GPR {
51+
struct alignas(8) GPR {
5252
uint64_t x[29]; // x0-x28
5353
uint64_t fp; // x29
5454
uint64_t lr; // x30

lldb/unittests/Instruction/ARM64/TestAArch64Emulator.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct Arch64EmulatorTester : public EmulateInstructionARM64 {
6262
reg_value.SetUInt64(tester->gpr.pc);
6363
return true;
6464
case gpr_cpsr_arm64:
65-
reg_value.SetUInt64(tester->gpr.cpsr);
65+
reg_value.SetUInt32(tester->gpr.cpsr);
6666
return true;
6767
default:
6868
return false;
@@ -97,7 +97,7 @@ struct Arch64EmulatorTester : public EmulateInstructionARM64 {
9797
tester->gpr.pc = reg_value.GetAsUInt64();
9898
return true;
9999
case gpr_cpsr_arm64:
100-
tester->gpr.cpsr = reg_value.GetAsUInt64();
100+
tester->gpr.cpsr = reg_value.GetAsUInt32();
101101
return true;
102102
default:
103103
return false;
@@ -112,7 +112,7 @@ struct Arch64EmulatorTester : public EmulateInstructionARM64 {
112112
assert(addr - tester->memory_offset + length <= sizeof(tester->memory));
113113
if (addr >= tester->memory_offset &&
114114
addr - tester->memory_offset + length <= sizeof(tester->memory)) {
115-
memcpy(dst, tester->memory + addr - tester->memory_offset, length);
115+
memcpy(dst, tester->memory + (addr - tester->memory_offset), length);
116116
return length;
117117
}
118118
return 0;

0 commit comments

Comments
 (0)