Commit e217fbff authored by Jakob Gruber's avatar Jakob Gruber Committed by Commit Bot

[builtins] Properly handle arbitrary addresses in builtin lookup

TryLookupCode can be passed arbitrary addresses, e.g. by tentative
name lookups during disassembly. This CL makes sure that addresses
within non-builtin-code sections of the embedded blob (metadata or
padding) are handled properly.

Bug: v8:6666, v8:8334
Change-Id: I42eca57062e30eabd7bb1b069786aa809706cd2c
Reviewed-on: https://chromium-review.googlesource.com/c/1292060Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56865}
parent adfe25c0
......@@ -26,12 +26,17 @@ Code* InstructionStream::TryLookupCode(Isolate* isolate, Address address) {
if (!PcIsOffHeap(isolate, address)) return nullptr;
EmbeddedData d = EmbeddedData::FromBlob();
if (address < d.InstructionStartOfBuiltin(0)) return nullptr;
// Note: Addresses within the padding section between builtins (i.e. within
// start + size <= address < start + padded_size) are interpreted as belonging
// to the preceding builtin.
int l = 0, r = Builtins::builtin_count;
while (l < r) {
const int mid = (l + r) / 2;
Address start = d.InstructionStartOfBuiltin(mid);
Address end = start + d.InstructionSizeOfBuiltin(mid);
Address end = start + d.PaddedInstructionSizeOfBuiltin(mid);
if (address < start) {
r = mid;
......
......@@ -96,7 +96,8 @@ class EmbeddedData final {
// Padded with kCodeAlignment.
uint32_t PaddedInstructionSizeOfBuiltin(int i) const {
return PadAndAlign(InstructionSizeOfBuiltin(i));
uint32_t size = InstructionSizeOfBuiltin(i);
return (size == 0) ? 0 : PadAndAlign(size);
}
size_t CreateHash() const;
......
......@@ -453,11 +453,4 @@
'test-dtoa/*': [SKIP],
}], # variant == no_wasm_traps
##############################################################################
['arch == ia32', {
# TODO(v8:8334): Fix code printing.
'test-assembler-ia32/AssemblerIa32JumpTables1': [SKIP],
'test-assembler-ia32/AssemblerIa32JumpTables2': [SKIP],
}], # 'arch == ia32'
]
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