diff options
author | SingleAccretion <62474226+SingleAccretion@users.noreply.github.com> | 2024-08-29 19:10:48 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-29 09:10:48 -0700 |
commit | e3b16dae4166b138bbd04bbe67281f4fa47fd4de (patch) | |
tree | 897220a41fef6bcc52ea758b6e610f5a39d95f21 | |
parent | 1edeaf2948b4afd711e50ba2007ee44503cd80fe (diff) | |
download | wabt-e3b16dae4166b138bbd04bbe67281f4fa47fd4de.tar.gz wabt-e3b16dae4166b138bbd04bbe67281f4fa47fd4de.tar.bz2 wabt-e3b16dae4166b138bbd04bbe67281f4fa47fd4de.zip |
Add missing relocation types (and delete a non-existent one) (#2457)
-rw-r--r-- | include/wabt/common.h | 8 | ||||
-rw-r--r-- | src/binary-reader.cc | 6 | ||||
-rw-r--r-- | src/binary-writer.cc | 6 | ||||
-rw-r--r-- | src/common.cc | 41 |
4 files changed, 45 insertions, 16 deletions
diff --git a/include/wabt/common.h b/include/wabt/common.h index f44ad25e..12b2eb09 100644 --- a/include/wabt/common.h +++ b/include/wabt/common.h @@ -277,10 +277,14 @@ enum class RelocType { TableIndexI64 = 19, // Memory64: Like TableIndexI32 TableNumberLEB = 20, // e.g. Immediate of table.get MemoryAddressTLSSLEB = 21, // Address relative to __tls_base - MemoryAddressTLSI32 = 22, // Address relative to __tls_base + FunctionOffsetI64 = 22, // Memory64: Like FunctionOffsetI32 + MemoryAddressLocRelI32 = 23, // Address relative to the relocation's location + TableIndexRelSLEB64 = 24, // Memory64: TableIndexRelSLEB + MemoryAddressTLSSLEB64 = 25, // Memory64: MemoryAddressTLSSLEB + FuncIndexI32 = 26, // Function index as an I32 First = FuncIndexLEB, - Last = MemoryAddressTLSI32, + Last = FuncIndexI32, }; constexpr int kRelocTypeCount = WABT_ENUM_COUNT(RelocType); diff --git a/src/binary-reader.cc b/src/binary-reader.cc index ee8eed49..0fc9f9a9 100644 --- a/src/binary-reader.cc +++ b/src/binary-reader.cc @@ -2036,14 +2036,17 @@ Result BinaryReader::ReadRelocSection(Offset section_size) { case RelocType::MemoryAddressRelSLEB64: case RelocType::MemoryAddressI32: case RelocType::MemoryAddressI64: + case RelocType::MemoryAddressLocRelI32: case RelocType::FunctionOffsetI32: + case RelocType::FunctionOffsetI64: case RelocType::SectionOffsetI32: case RelocType::MemoryAddressTLSSLEB: - case RelocType::MemoryAddressTLSI32: + case RelocType::MemoryAddressTLSSLEB64: CHECK_RESULT(ReadS32Leb128(&addend, "addend")); break; case RelocType::FuncIndexLEB: + case RelocType::FuncIndexI32: case RelocType::TableIndexSLEB: case RelocType::TableIndexSLEB64: case RelocType::TableIndexI32: @@ -2053,6 +2056,7 @@ Result BinaryReader::ReadRelocSection(Offset section_size) { case RelocType::GlobalIndexI32: case RelocType::TagIndexLEB: case RelocType::TableIndexRelSLEB: + case RelocType::TableIndexRelSLEB64: case RelocType::TableNumberLEB: break; diff --git a/src/binary-writer.cc b/src/binary-writer.cc index 19443a44..a94eb147 100644 --- a/src/binary-writer.cc +++ b/src/binary-writer.cc @@ -1197,13 +1197,16 @@ void BinaryWriter::WriteRelocSection(const RelocSection* reloc_section) { case RelocType::MemoryAddressRelSLEB64: case RelocType::MemoryAddressI32: case RelocType::MemoryAddressI64: + case RelocType::MemoryAddressLocRelI32: case RelocType::FunctionOffsetI32: + case RelocType::FunctionOffsetI64: case RelocType::SectionOffsetI32: case RelocType::MemoryAddressTLSSLEB: - case RelocType::MemoryAddressTLSI32: + case RelocType::MemoryAddressTLSSLEB64: WriteU32Leb128(stream_, reloc.addend, "reloc addend"); break; case RelocType::FuncIndexLEB: + case RelocType::FuncIndexI32: case RelocType::TableIndexSLEB: case RelocType::TableIndexSLEB64: case RelocType::TableIndexI32: @@ -1212,6 +1215,7 @@ void BinaryWriter::WriteRelocSection(const RelocSection* reloc_section) { case RelocType::GlobalIndexLEB: case RelocType::TagIndexLEB: case RelocType::TableIndexRelSLEB: + case RelocType::TableIndexRelSLEB64: case RelocType::TableNumberLEB: break; default: diff --git a/src/common.cc b/src/common.cc index d1873c2c..9fe3275b 100644 --- a/src/common.cc +++ b/src/common.cc @@ -43,21 +43,38 @@ Reloc::Reloc(RelocType type, Offset offset, Index index, int32_t addend) const char* g_kind_name[] = {"func", "table", "memory", "global", "tag"}; WABT_STATIC_ASSERT(WABT_ARRAY_SIZE(g_kind_name) == kExternalKindCount); +// clang-format off const char* g_reloc_type_name[] = { - "R_WASM_FUNCTION_INDEX_LEB", "R_WASM_TABLE_INDEX_SLEB", - "R_WASM_TABLE_INDEX_I32", "R_WASM_MEMORY_ADDR_LEB", - "R_WASM_MEMORY_ADDR_SLEB", "R_WASM_MEMORY_ADDR_I32", - "R_WASM_TYPE_INDEX_LEB", "R_WASM_GLOBAL_INDEX_LEB", - "R_WASM_FUNCTION_OFFSET_I32", "R_WASM_SECTION_OFFSET_I32", - "R_WASM_TAG_INDEX_LEB", "R_WASM_MEMORY_ADDR_REL_SLEB", - "R_WASM_TABLE_INDEX_REL_SLEB", "R_WASM_GLOBAL_INDEX_I32", - "R_WASM_MEMORY_ADDR_LEB64", "R_WASM_MEMORY_ADDR_SLEB64", - "R_WASM_MEMORY_ADDR_I64", "R_WASM_MEMORY_ADDR_REL_SLEB64", - "R_WASM_TABLE_INDEX_SLEB64", "R_WASM_TABLE_INDEX_I64", - "R_WASM_TABLE_NUMBER_LEB", "R_WASM_MEMORY_ADDR_TLS_SLEB", - "R_WASM_MEMORY_ADDR_TLS_I32", + "R_WASM_FUNCTION_INDEX_LEB", + "R_WASM_TABLE_INDEX_SLEB", + "R_WASM_TABLE_INDEX_I32", + "R_WASM_MEMORY_ADDR_LEB", + "R_WASM_MEMORY_ADDR_SLEB", + "R_WASM_MEMORY_ADDR_I32", + "R_WASM_TYPE_INDEX_LEB", + "R_WASM_GLOBAL_INDEX_LEB", + "R_WASM_FUNCTION_OFFSET_I32", + "R_WASM_SECTION_OFFSET_I32", + "R_WASM_TAG_INDEX_LEB", + "R_WASM_MEMORY_ADDR_REL_SLEB", + "R_WASM_TABLE_INDEX_REL_SLEB", + "R_WASM_GLOBAL_INDEX_I32", + "R_WASM_MEMORY_ADDR_LEB64", + "R_WASM_MEMORY_ADDR_SLEB64", + "R_WASM_MEMORY_ADDR_I64", + "R_WASM_MEMORY_ADDR_REL_SLEB64", + "R_WASM_TABLE_INDEX_SLEB64", + "R_WASM_TABLE_INDEX_I64", + "R_WASM_TABLE_NUMBER_LEB", + "R_WASM_MEMORY_ADDR_TLS_SLEB", + "R_WASM_FUNCTION_OFFSET_I64", + "R_WASM_MEMORY_ADDR_LOCREL_I32", + "R_WASM_TABLE_INDEX_REL_SLEB64", + "R_WASM_MEMORY_ADDR_TLS_SLEB64", + "R_WASM_FUNCTION_INDEX_I32", }; WABT_STATIC_ASSERT(WABT_ARRAY_SIZE(g_reloc_type_name) == kRelocTypeCount); +// clang-format on static Result ReadAll(FILE* stream, const char* name, |