[PATCH] D70034: Fix include guard and properly order __deregister_frame_info.
Sterling Augustine via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 11 12:12:24 PST 2019
saugustine updated this revision to Diff 228753.
saugustine added a comment.
- Make USE_FRAME_REGISTRY completely independent of CRT_HAS_INITFINI_ARRAY,
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70034/new/
https://reviews.llvm.org/D70034
Files:
compiler-rt/lib/crt/CMakeLists.txt
compiler-rt/lib/crt/crtbegin.c
compiler-rt/test/crt/ctor_dtor.c
Index: compiler-rt/test/crt/ctor_dtor.c
===================================================================
--- compiler-rt/test/crt/ctor_dtor.c
+++ compiler-rt/test/crt/ctor_dtor.c
@@ -4,9 +4,23 @@
#include <stdio.h>
-// CHECK: ctor()
+// Ensure the various initialization functions are called in the proper order.
+
+// CHECK: __register_frame_info()
+// CHECK-NEXT: ctor()
// CHECK-NEXT: main()
// CHECK-NEXT: dtor()
+// CHECK-NEXT: __deregister_frame_info()
+
+struct object;
+
+void __register_frame_info(const void* fi, struct object* obj) {
+ printf("__register_frame_info()\n");
+}
+
+void __deregister_frame_info(const void* fi) {
+ printf("__deregister_frame_info()\n");
+}
void __attribute__((constructor)) ctor() {
printf("ctor()\n");
Index: compiler-rt/lib/crt/crtbegin.c
===================================================================
--- compiler-rt/lib/crt/crtbegin.c
+++ compiler-rt/lib/crt/crtbegin.c
@@ -10,8 +10,10 @@
__attribute__((visibility("hidden"))) void *__dso_handle = &__dso_handle;
+#ifdef EH_USE_FRAME_REGISTRY
__extension__ static void *__EH_FRAME_LIST__[]
__attribute__((section(".eh_frame"), aligned(sizeof(void *)))) = {};
+#endif
extern void __register_frame_info(const void *, void *) __attribute__((weak));
extern void *__deregister_frame_info(const void *) __attribute__((weak));
@@ -32,10 +34,11 @@
return;
__initialized = 1;
+#ifdef EH_USE_FRAME_REGISTRY
static struct { void *p[8]; } __object;
if (__register_frame_info)
__register_frame_info(__EH_FRAME_LIST__, &__object);
-
+#endif
#ifndef CRT_HAS_INITFINI_ARRAY
const size_t n = __CTOR_LIST_END__ - __CTOR_LIST__ - 1;
for (size_t i = n; i >= 1; i--) __CTOR_LIST__[i]();
@@ -73,12 +76,13 @@
__cxa_finalize(__dso_handle);
#ifndef CRT_HAS_INITFINI_ARRAY
- if (__deregister_frame_info)
- __deregister_frame_info(__EH_FRAME_LIST__);
-
const size_t n = __DTOR_LIST_END__ - __DTOR_LIST__ - 1;
for (size_t i = 1; i <= n; i++) __DTOR_LIST__[i]();
#endif
+#ifdef EH_USE_FRAME_REGISTRY
+ if (__deregister_frame_info)
+ __deregister_frame_info(__EH_FRAME_LIST__);
+#endif
}
#ifdef CRT_HAS_INITFINI_ARRAY
Index: compiler-rt/lib/crt/CMakeLists.txt
===================================================================
--- compiler-rt/lib/crt/CMakeLists.txt
+++ compiler-rt/lib/crt/CMakeLists.txt
@@ -74,6 +74,7 @@
append_list_if(COMPILER_RT_HAS_STD_C11_FLAG -std=c11 CRT_CFLAGS)
append_list_if(COMPILER_RT_HAS_INITFINI_ARRAY -DCRT_HAS_INITFINI_ARRAY CRT_CFLAGS)
+list(APPEND CRT_FLAGS -DEH_USE_FRAME_REGISTRY)
append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC CRT_CFLAGS)
append_list_if(COMPILER_RT_HAS_WNO_PEDANTIC -Wno-pedantic CRT_CFLAGS)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70034.228753.patch
Type: text/x-patch
Size: 2720 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191111/1d0ee726/attachment.bin>
More information about the llvm-commits
mailing list