Brendan Dahl 220fe00a7c [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
2023-07-11 15:17:26 -07:00

22 lines
806 B
ArmAsm

# RUN: llvm-mc -triple=wasm32-unknown-unknown < %s | FileCheck %s
# Check that it also comiled to object for format.
# RUN: llvm-mc -triple=wasm32-unknown-unknown -filetype=obj -o - < %s | obj2yaml | FileCheck -check-prefix=CHECK-OBJ %s
foo:
.globl foo
.functype foo () -> ()
end_function
.section .custom_section.llvm.func_attr.custom0,"",@
.int32 foo@FUNCINDEX
# CHECK: .section .custom_section.llvm.func_attr.custom0,"",@
# CHECK-NEXT: .int32 foo@FUNCINDEX
# CHECK-OBJ: - Type: CUSTOM
# CHECK-OBJ-NEXT: Relocations:
# CHECK-OBJ-NEXT: - Type: R_WASM_FUNCTION_INDEX_I32
# CHECK-OBJ-NEXT: Index: 0
# CHECK-OBJ-NEXT: Offset: 0x0
# CHECK-OBJ-NEXT: Name: llvm.func_attr.custom0