[PATCH] D25856: [cfi] Test case for weak symbol handling

Evgeniy Stepanov via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 20 17:31:36 PDT 2016


eugenis created this revision.
eugenis added a reviewer: pcc.
eugenis added a subscriber: llvm-commits.
eugenis set the repository for this revision to rL LLVM.

CFI runtime test for https://reviews.llvm.org/D25854

This code used to crash because CFI emits a jump table entry for "does_not_exist" which itself is not weak (it can't be), but it jumps to nullptr.


Repository:
  rL LLVM

https://reviews.llvm.org/D25856

Files:
  test/cfi/icall/weak.c


Index: test/cfi/icall/weak.c
===================================================================
--- /dev/null
+++ test/cfi/icall/weak.c
@@ -0,0 +1,14 @@
+// Test that weak symbols stay weak.
+// RUN: %clang_cfi -lm -o %t1 %s && %t1
+
+__attribute__((weak)) void does_not_exist(void);
+
+__attribute__((noinline))
+void foo(void (*p)(void)) {
+  p();
+}
+
+int main(int argc, char **argv) {
+  if (does_not_exist)
+    foo(does_not_exist);
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25856.75378.patch
Type: text/x-patch
Size: 443 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161021/3c213fd7/attachment.bin>


More information about the llvm-commits mailing list