llvm-project/clang/test/CodeGenCXX/externc-ifunc-resolver.cpp
Jon Roelofs acf9aa3c22
[clang] Support __attribute__((ifunc(...))) on Darwin platforms
Unlike ELF targets, MachO does not support the same kind of dynamic symbol
resolution at load time.  Instead, the corresponding MachO feature resolves
symbols lazily on first call.

Reviewers:
JDevlieghere, dmpolukhin, ahmedbougacha, tahonermann, echristo, MaskRay, erichkeane

Reviewed By: MaskRay, echristo, ahmedbougacha

Pull Request: https://github.com/llvm/llvm-project/pull/73687
2023-12-14 14:52:35 -07:00

19 lines
897 B
C++

// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple x86_64-apple-macosx -emit-llvm -o - %s | FileCheck %s
// RUN: %clang_cc1 -triple arm64-apple-macosx -emit-llvm -o - %s | FileCheck %s
extern "C" {
__attribute__((used)) static void *resolve_foo() { return 0; }
__attribute__((ifunc("resolve_foo"))) char *foo();
__attribute__((ifunc("resolve_foo"))) void foo2(int);
__attribute__((ifunc("resolve_foo"))) char foo3(float);
__attribute__((ifunc("resolve_foo"))) char foo4(float);
}
// CHECK: @resolve_foo = internal alias ptr (), ptr @_ZL11resolve_foov
// CHECK: @foo = ifunc ptr (), ptr @_ZL11resolve_foov
// CHECK: @foo2 = ifunc void (i32), ptr @_ZL11resolve_foov
// CHECK: @foo3 = ifunc i8 (float), ptr @_ZL11resolve_foov
// CHECK: @foo4 = ifunc i8 (float), ptr @_ZL11resolve_foov
// CHECK: define internal noundef ptr @_ZL11resolve_foov()