[compiler-rt] r346222 - Prioritize the constructor call of __local_xray_dyninit()

Kamil Rytarowski via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 6 02:59:21 PST 2018


Author: kamil
Date: Tue Nov  6 02:59:21 2018
New Revision: 346222

URL: http://llvm.org/viewvc/llvm-project?rev=346222&view=rev
Log:
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

Modified:
    compiler-rt/trunk/lib/xray/xray_init.cc

Modified: compiler-rt/trunk/lib/xray/xray_init.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_init.cc?rev=346222&r1=346221&r2=346222&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_init.cc (original)
+++ compiler-rt/trunk/lib/xray/xray_init.cc Tue Nov  6 02:59:21 2018
@@ -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




More information about the llvm-commits mailing list