Skip to content

Commit 062cfad

Browse files
authored
[builtins] Disable COMPILER_RT_CRT_USE_EH_FRAME_REGISTRY by default (llvm#83201)
Most of GCC's Linux targets have a link spec `%{!static|static-pie:--eh-frame-hdr}` that doesn't pass --eh-frame-hdr for `-static` links. `-static` links are supposed to utilize `__register_frame_info` (called by `crtbeginT.o`, not by crtbegin.o or crtbeginS.o) as a replacement. compiler-rt crtbegin (not used with GCC) has some ehframe code, which is not utilized because Clang driver unconditionally passes --eh-frame-hdr for Linux targets, even for -static. In addition, LLVM libunwind implements `__register_frame_info` as an empty stub. Furthermore, in a non-static link, the `__register_frame_info` references can cause an undesired weak dynamic symbol. For now, just disable the config by default.
1 parent d699d9d commit 062cfad

File tree

2 files changed

+1
-11
lines changed

2 files changed

+1
-11
lines changed

compiler-rt/lib/builtins/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ cmake_dependent_option(COMPILER_RT_BUILD_CRT "Build crtbegin.o/crtend.o" ON "COM
916916
if (COMPILER_RT_BUILD_CRT)
917917
add_compiler_rt_component(crt)
918918

919-
option(COMPILER_RT_CRT_USE_EH_FRAME_REGISTRY "Use eh_frame in crtbegin.o/crtend.o" ON)
919+
option(COMPILER_RT_CRT_USE_EH_FRAME_REGISTRY "Use eh_frame in crtbegin.o/crtend.o" OFF)
920920

921921
include(CheckSectionExists)
922922
check_section_exists(".init_array" COMPILER_RT_HAS_INITFINI_ARRAY

compiler-rt/test/builtins/Unit/ctor_dtor.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,13 @@
99

1010
// Ensure the various startup functions are called in the proper order.
1111

12-
// CHECK: __register_frame_info()
1312
/// ctor() is here if ld.so/libc supports DT_INIT/DT_FINI
1413
// CHECK: main()
1514
/// dtor() is here if ld.so/libc supports DT_INIT/DT_FINI
16-
// CHECK: __deregister_frame_info()
1715

1816
struct object;
1917
static int counter;
2018

21-
void __register_frame_info(const void *fi, struct object *obj) {
22-
printf("__register_frame_info()\n");
23-
}
24-
25-
void __deregister_frame_info(const void *fi) {
26-
printf("__deregister_frame_info()\n");
27-
}
28-
2919
void __attribute__((constructor)) ctor() {
3020
printf("ctor()\n");
3121
++counter;

0 commit comments

Comments
 (0)