Commit 397f53ed authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[arm] Fix relative code target relocation

Relative code targets are emitted as pc-relative jumps. The
relocation delta must be subtracted (not added) from the branch
offset.

Before GC:

        |-------- branch offset --->|
 [host code object]                 [target code object]

After GC:

 |- delta ->|      |- new offset -->|
            [host code object]      [target code object]

See also the similar fix for mips in https://crrev.com/c/1581239.

Bug: v8:6666
Change-Id: Ie0867d98906d4a8daa7e335884f7a4d814333872
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1581260Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61121}
parent 61672d9d
......@@ -63,7 +63,7 @@ void RelocInfo::apply(intptr_t delta) {
*p += delta; // relocate entry
} else if (RelocInfo::IsRelativeCodeTarget(rmode_)) {
Instruction* branch = Instruction::At(pc_);
int32_t branch_offset = branch->GetBranchOffset() + delta;
int32_t branch_offset = branch->GetBranchOffset() - delta;
branch->SetBranchOffset(branch_offset);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment