[wasm] Avoid manual relocation of target address
In PatchTrampolineAndStubCalls, use a second iterator over the original relocation info, to avoid having to reconstruct the original target of the branch by manually applying the delta between the old and new code. This way, we do not need to make assumptions regarding how code targets are encoded. Change-Id: I551ad8a3a654ead63ea88c8ce1d8c9e1927436b0 Reviewed-on: https://chromium-review.googlesource.com/995442 Reviewed-by: Clemens Hammacher <clemensh@chromium.org> Commit-Queue: Georgia Kouveli <georgia.kouveli@arm.com> Cr-Commit-Position: refs/heads/master@{#52365}
This commit is contained in:
parent
8adb94fc81
commit
125f8c81f5
@ -71,14 +71,15 @@ void PatchTrampolineAndStubCalls(
|
||||
// targets to call the new trampolines and stubs.
|
||||
intptr_t delta =
|
||||
new_code->instructions().start() - original_code->instructions().start();
|
||||
int mask = RelocInfo::kApplyMask | RelocInfo::kCodeTargetMask;
|
||||
RelocIterator orig_it(original_code->instructions(),
|
||||
original_code->reloc_info(),
|
||||
original_code->constant_pool(), mask);
|
||||
for (RelocIterator it(new_code->instructions(), new_code->reloc_info(),
|
||||
new_code->constant_pool(),
|
||||
RelocInfo::kCodeTargetMask | RelocInfo::kApplyMask);
|
||||
!it.done(); it.next()) {
|
||||
bool relocate =
|
||||
RelocInfo::ModeMask(it.rinfo()->rmode()) & RelocInfo::kApplyMask;
|
||||
new_code->constant_pool(), mask);
|
||||
!it.done(); it.next(), orig_it.next()) {
|
||||
if (RelocInfo::IsCodeTarget(it.rinfo()->rmode())) {
|
||||
Address target = it.rinfo()->target_address() - (relocate ? delta : 0);
|
||||
Address target = orig_it.rinfo()->target_address();
|
||||
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_S390X
|
||||
auto found = reverse_lookup.find(target);
|
||||
DCHECK(found != reverse_lookup.end());
|
||||
|
Loading…
Reference in New Issue
Block a user