diff options
author | Kamil Rytarowski <n54@gmx.com> | 2018-11-06 10:59:21 +0000 |
---|---|---|
committer | Kamil Rytarowski <n54@gmx.com> | 2018-11-06 10:59:21 +0000 |
commit | e81e124b0f0e5a5aa8bebc04c47bb0bba92cfcca (patch) | |
tree | 86ca43abcf01d8f7b9aeb59aa6f7d4a109f42871 | |
parent | 4e15ada76fa773cdd745e45d88ccec3325428b4e (diff) | |
download | compiler-rt-e81e124b0f0e5a5aa8bebc04c47bb0bba92cfcca.tar.gz |
Prioritize the constructor call of __local_xray_dyninit()
Summary:
For platforms without preinit support (such as NetBSD/amd64) the
initialization routine __xray_init() was called in non-deterministic order
compared to other constructors. This caused breakage failures
as xray routines attempted to execute code with assumption of
being initialized, which was no always true.
Use GCC/Clang extension to set maximal priority to the constructor
calling __xray_init(). This code switches away from C++ lambda form,
as it did not allow to specify this compiler extension.
Reviewers: dberris, joerg
Reviewed By: dberris
Subscribers: llvm-commits, mgorny, #sanitizers
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D54136
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@346222 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/xray/xray_init.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/xray/xray_init.cc b/lib/xray/xray_init.cc index 8886a600d..d1c750f0c 100644 --- a/lib/xray/xray_init.cc +++ b/lib/xray/xray_init.cc @@ -106,8 +106,8 @@ __attribute__((section(".preinit_array"), #else // If we cannot use the .preinit_array section, we should instead use dynamic // initialisation. -static bool UNUSED __local_xray_dyninit = [] { +__attribute__ ((constructor (0))) +static void __local_xray_dyninit() { __xray_init(); - return true; -}(); +} #endif |