diff options
author | Nico Weber <thakis@chromium.org> | 2022-11-18 14:28:59 -0500 |
---|---|---|
committer | Nico Weber <thakis@chromium.org> | 2022-11-18 14:42:08 -0500 |
commit | f65e8c3c519ade29139f90d235884d3ad12fae5d (patch) | |
tree | 5ef684b2111d3b08593a3fc55240d25e9b44aa91 /lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h | |
parent | aaea4e38aba15617ccf08c5d40fb384f6cea1ea8 (diff) | |
download | llvm-f65e8c3c519ade29139f90d235884d3ad12fae5d.zip llvm-f65e8c3c519ade29139f90d235884d3ad12fae5d.tar.gz llvm-f65e8c3c519ade29139f90d235884d3ad12fae5d.tar.bz2 |
[bolt] Fix std::prev()-past-begin in veneer handling code
matchLinkerVeneer() returns 3 if `Instruction` and the last
two instructions in `[Instructions.begin, Instructions.end())`
match the pattern
ADRP x16, imm
ADD x16, x16, imm
BR x16
BinaryContext.cpp used to use
--Count;
for (auto It = std::prev(Instructions.end()); Count != 0;
It = std::prev(It), --Count) {
...use It...
}
to walk these instructions. The first `--Count` skips the
instruction that's in `Instruction` instead of in `Instructions`.
The loop then walks over `Instructions`.
However, on the last iteration, this calls `std::prev()` on an
iterator that points at the container's begin(), which can blow
up.
Instead, use rbegin(), which sidesteps this issue.
Fixes test/AArch64/veneer-gold.s on a macOS host.
With this, check-bolt passes on macOS.
Differential Revision: https://reviews.llvm.org/D138313
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h')
0 files changed, 0 insertions, 0 deletions