aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/WasmObjectFile.cpp
diff options
context:
space:
mode:
authorBrendan Dahl <brendan.dahl@gmail.com>2023-07-11 15:12:26 -0700
committerDerek Schuff <dschuff@chromium.org>2023-07-11 15:17:26 -0700
commit220fe00a7c0f73164711f0d6cdefacef264b85dc (patch)
treea570739a4f329a3363274f3c3a99456c694df424 /llvm/lib/Object/WasmObjectFile.cpp
parent78af051ff0e16db73201b1370e34206a6a4c1b93 (diff)
downloadllvm-220fe00a7c0f73164711f0d6cdefacef264b85dc.zip
llvm-220fe00a7c0f73164711f0d6cdefacef264b85dc.tar.gz
llvm-220fe00a7c0f73164711f0d6cdefacef264b85dc.tar.bz2
[WebAssembly] Support `annotate` clang attributes for marking functions.
Annotation attributes may be attached to a function to mark it with custom data that will be contained in the final Wasm file. The annotation causes a custom section named "func_attr.annotate.<name>.<arg0>.<arg1>..." to be created that will contain each function's index value that was marked with the annotation. A new patchable relocation type for function indexes had to be created so the custom section could be updated during linking. Reviewed By: sbc100 Differential Revision: https://reviews.llvm.org/D150803
Diffstat (limited to 'llvm/lib/Object/WasmObjectFile.cpp')
-rw-r--r--llvm/lib/Object/WasmObjectFile.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index 5dbe685..a72242b 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -948,6 +948,7 @@ Error WasmObjectFile::parseRelocSection(StringRef Name, ReadContext &Ctx) {
Reloc.Index = readVaruint32(Ctx);
switch (type) {
case wasm::R_WASM_FUNCTION_INDEX_LEB:
+ case wasm::R_WASM_FUNCTION_INDEX_I32:
case wasm::R_WASM_TABLE_INDEX_SLEB:
case wasm::R_WASM_TABLE_INDEX_SLEB64:
case wasm::R_WASM_TABLE_INDEX_I32:
@@ -1045,6 +1046,7 @@ Error WasmObjectFile::parseRelocSection(StringRef Name, ReadContext &Ctx) {
Reloc.Type == wasm::R_WASM_MEMORY_ADDR_LOCREL_I32 ||
Reloc.Type == wasm::R_WASM_SECTION_OFFSET_I32 ||
Reloc.Type == wasm::R_WASM_FUNCTION_OFFSET_I32 ||
+ Reloc.Type == wasm::R_WASM_FUNCTION_INDEX_I32 ||
Reloc.Type == wasm::R_WASM_GLOBAL_INDEX_I32)
Size = 4;
if (Reloc.Type == wasm::R_WASM_TABLE_INDEX_I64 ||