summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-12-18 12:49:46 -0800
committerJonas Devlieghere <jonas@devlieghere.com>2019-12-18 12:54:04 -0800
commite194d890126007bc8e5acb655f007ef76002edb7 (patch)
tree6dbb510ebb8ee81ccbc9a52456516a7cec7b3b2d /lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
parent19464613440894f5906a83ea1b52999d9fa08882 (diff)
downloadbcm5719-llvm-e194d890126007bc8e5acb655f007ef76002edb7.tar.gz
bcm5719-llvm-e194d890126007bc8e5acb655f007ef76002edb7.zip
[lldb/MachO] "Fix" intentional out-of-bounds error (NFC)
Remove the hack that populates the cpsr register in the gpr struct by writing past the end of the array. This was tripping up ASan. Patch by: Reva Cuthbertson
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp')
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 57c43de0c94..ef6ad1696c4 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -479,12 +479,13 @@ public:
switch (flavor) {
case GPRAltRegSet:
case GPRRegSet:
- for (uint32_t i = 0; i < count; ++i) {
+ // On ARM, the CPSR register is also included in the count but it is
+ // not included in gpr.r so loop until (count-1).
+ for (uint32_t i = 0; i < (count - 1); ++i) {
gpr.r[i] = data.GetU32(&offset);
}
-
- // Note that gpr.cpsr is also copied by the above loop; this loop
- // technically extends one element past the end of the gpr.r[] array.
+ // Save cpsr explicitly.
+ gpr.cpsr = data.GetU32(&offset);
SetError(GPRRegSet, Read, 0);
offset = next_thread_state;
OpenPOWER on IntegriCloud