[wasm] Make disassembler more robust for invalid modules
This fixes a segfault encountered when disassembling a particular flavor of invalid module using wami's --full-hexdump mode. Change-Id: I5fbb97c2359d14ce9d4b6830b55a75cc34e964a1 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3919231 Reviewed-by: Matthias Liedtke <mliedtke@chromium.org> Commit-Queue: Matthias Liedtke <mliedtke@chromium.org> Auto-Submit: Jakob Kummerow <jkummerow@chromium.org> Commit-Queue: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/main@{#84912}
This commit is contained in:
parent
f9406a7f4b
commit
c38e2ce46e
@ -313,9 +313,22 @@ class ImmediatesPrinter {
|
||||
owner_->out_->PatchLabel(label_info, out_.start() + label_start_position);
|
||||
}
|
||||
|
||||
void PrintSignature(uint32_t sig_index) {
|
||||
if (owner_->module_->has_signature(sig_index)) {
|
||||
const FunctionSig* sig = owner_->module_->signature(sig_index);
|
||||
PrintSignatureOneLine(out_, sig, 0 /* ignored */, names(), false);
|
||||
} else {
|
||||
out_ << " (signature: " << sig_index << " INVALID)";
|
||||
}
|
||||
}
|
||||
|
||||
void BlockType(BlockTypeImmediate& imm) {
|
||||
if (imm.sig.all().begin() == nullptr) {
|
||||
PrintSignature(imm.sig_index);
|
||||
} else {
|
||||
PrintSignatureOneLine(out_, &imm.sig, 0 /* ignored */, names(), false);
|
||||
}
|
||||
}
|
||||
|
||||
void HeapType(HeapTypeImmediate& imm) {
|
||||
out_ << " ";
|
||||
@ -336,8 +349,7 @@ class ImmediatesPrinter {
|
||||
}
|
||||
|
||||
void CallIndirect(CallIndirectImmediate& imm) {
|
||||
const FunctionSig* sig = owner_->module_->signature(imm.sig_imm.index);
|
||||
PrintSignatureOneLine(out_, sig, 0 /* ignored */, names(), false);
|
||||
PrintSignature(imm.sig_imm.index);
|
||||
if (imm.table_imm.index != 0) TableIndex(imm.table_imm);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user