Skip to content

Commit

Permalink
Fix reading of bad relocation type (#1672)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed May 28, 2021
1 parent 63c3509 commit e808dfe
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ void InitStdio();
extern const char* g_kind_name[];

static WABT_INLINE const char* GetKindName(ExternalKind kind) {
return static_cast<int>(kind) < kExternalKindCount
return static_cast<size_t>(kind) < kExternalKindCount
? g_kind_name[static_cast<size_t>(kind)]
: "<error_kind>";
}
Expand All @@ -430,7 +430,7 @@ static WABT_INLINE const char* GetKindName(ExternalKind kind) {
extern const char* g_reloc_type_name[];

static WABT_INLINE const char* GetRelocTypeName(RelocType reloc) {
return static_cast<int>(reloc) < kRelocTypeCount
return static_cast<size_t>(reloc) < kRelocTypeCount
? g_reloc_type_name[static_cast<size_t>(reloc)]
: "<error_reloc_type>";
}
Expand Down
30 changes: 30 additions & 0 deletions test/binary/bad-reloc-type.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
;;; TOOL: run-objdump-gen-wasm
;;; ARGS: -x
magic
version
section(TYPE) { count[1] function params[0] results[0] }
section("reloc.BAD") {
reloc_section[0]
reloc_count[1]
reloc_type[leb_i32(0xffffffff)]
reloc_offset[0]
reloc_index[0]
}
(;; STDERR ;;;
0000023: warning: unknown reloc type: <error_reloc_type>
;;; STDERR ;;)
(;; STDOUT ;;;
bad-reloc-type.wasm: file format wasm 0x1
Section Details:
Type[1]:
- type[0] () -> nil
Custom:
- name: "reloc.BAD"
- relocations for section: 0 (Type) [1]
Code Disassembly:
;;; STDOUT ;;)

0 comments on commit e808dfe

Please sign in to comment.