[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/+/1581260
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61121}
This commit is contained in:
Jakob Gruber 2019-04-24 10:58:54 +02:00 committed by Commit Bot
parent 61672d9d7d
commit 397f53ed0f

View File

@ -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);
}
}