[compiler-rt] r372038 - [compiler-rt][crt] make test case nontrivial in check_cxx_section_exists
Jian Cai via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 16 14:47:48 PDT 2019
Author: jcai19
Date: Mon Sep 16 14:47:47 2019
New Revision: 372038
URL: http://llvm.org/viewvc/llvm-project?rev=372038&view=rev
Log:
[compiler-rt][crt] make test case nontrivial in check_cxx_section_exists
Summary:
.init_array gets optimized away when building with -O2 and as a result,
check_cxx_section_exists failed to pass -DCOMPILER_RT_HAS_INITFINI_ARRAY
when building crtbegin.o and crtend.o, which causes binaries linked with
them encounter segmentation fault. See https://crbug.com/855759 for
details. This change prevents .init_array section to be optimized away
even with -O2 or higher optimization level.
Subscribers: dberris, mgorny, #sanitizers, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D67628
Modified:
compiler-rt/trunk/lib/crt/CMakeLists.txt
Modified: compiler-rt/trunk/lib/crt/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/crt/CMakeLists.txt?rev=372038&r1=372037&r2=372038&view=diff
==============================================================================
--- compiler-rt/trunk/lib/crt/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/crt/CMakeLists.txt Mon Sep 16 14:47:47 2019
@@ -70,7 +70,7 @@ function(check_cxx_section_exists sectio
endfunction()
check_cxx_section_exists(".init_array" COMPILER_RT_HAS_INITFINI_ARRAY
- SOURCE "__attribute__((constructor)) void f() {}\nint main() { return 0; }\n")
+ SOURCE "volatile int x;\n__attribute__((constructor)) void f() {x = 0;}\nint main() { return 0; }\n")
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)
More information about the llvm-commits
mailing list