diff --git a/compiler-rt/test/cfi/cfi_jt_aliases.c b/compiler-rt/test/cfi/cfi_jt_aliases.c new file mode 100644 --- /dev/null +++ b/compiler-rt/test/cfi/cfi_jt_aliases.c @@ -0,0 +1,29 @@ +// REQUIRES: lld-available, lto + +// RUN: %clang_cfi_non_canon -flto -fvisibility=default -c %s -o lto.o +// RUN: ld.lld -r -o lto.ko lto.o +// RUN: llvm-readelf --symbols lto.ko | grep \.cfi_jt | FileCheck --check-prefix=CHECK-RE %s +// RUN: llvm-objdump -d -r -j .text..L.cfi.jumptable lto.ko | tee XXX.txt | FileCheck --check-prefix=CHECK-OD %s + +// CHECK-RE: FUNC GLOBAL HIDDEN {{[0-9]+}} a.cfi_jt +// CHECK-RE-NEXT: FUNC GLOBAL HIDDEN {{[0-9]+}} b.cfi_jt +// CHECK-RE-NEXT: FUNC GLOBAL HIDDEN {{[0-9]+}} c.cfi_jt + +// CHECK-OD: a.cfi_jt>: +// CHECK-OD: jmp {{.*}} : +// CHECK-OD: jmp {{.*}} : +// CHECK-OD: jmp {{.*}} {ConstantInt::get(IntPtrTy, 0), ConstantInt::get(IntPtrTy, I)}), F->getType()); + + if (!IsJumpTableCanonical) { + GlobalAlias *JtAlias = GlobalAlias::create( + F->getValueType(), 0, GlobalValue::ExternalLinkage, + F->getName() + ".cfi_jt", CombinedGlobalElemPtr, &M); + JtAlias->setVisibility(GlobalValue::HiddenVisibility); + } + if (Functions[I]->isExported()) { - if (IsJumpTableCanonical) { + if (IsJumpTableCanonical) ExportSummary->cfiFunctionDefs().insert(std::string(F->getName())); - } else { - GlobalAlias *JtAlias = GlobalAlias::create( - F->getValueType(), 0, GlobalValue::ExternalLinkage, - F->getName() + ".cfi_jt", CombinedGlobalElemPtr, &M); - JtAlias->setVisibility(GlobalValue::HiddenVisibility); + else ExportSummary->cfiFunctionDecls().insert(std::string(F->getName())); - } } + if (!IsJumpTableCanonical) { if (F->hasExternalWeakLinkage()) replaceWeakDeclarationWithJumpTablePtr(F, CombinedGlobalElemPtr,