diff options
author | Jian Cai <caij2003@gmail.com> | 2019-09-16 21:47:47 +0000 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2019-11-08 12:33:21 -0800 |
commit | 4e858e4ac00b59f064da4e1f7e276916e7d296aa (patch) | |
tree | 15a51c86d583a14f5f1b27f4e73cb9084917288e | |
parent | 8b0167fdee5f6556f18a4d912b679ef0af268e13 (diff) | |
download | llvm-4e858e4ac00b59f064da4e1f7e276916e7d296aa.tar.gz |
Merging r372038:
------------------------------------------------------------------------
r372038 | jcai19 | 2019-09-16 14:47:47 -0700 (Mon, 16 Sep 2019) | 15 lines
[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
------------------------------------------------------------------------
-rw-r--r-- | compiler-rt/lib/crt/CMakeLists.txt | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler-rt/lib/crt/CMakeLists.txt b/compiler-rt/lib/crt/CMakeLists.txt index 03a07f475d7e..03e7b663ec40 100644 --- a/compiler-rt/lib/crt/CMakeLists.txt +++ b/compiler-rt/lib/crt/CMakeLists.txt @@ -69,7 +69,7 @@ function(check_cxx_section_exists section output) 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) |