Skip to content

Commit 0265981

Browse files
authored
[sanitizers] convert some errant CRLF line endings to LF (#108454)
(nfc) #107899 Added some files with CRLF line endings. Mixed line endings are somewhat gross, so I've converted them all to unix.
1 parent 7586aea commit 0265981

8 files changed

+805
-805
lines changed

compiler-rt/lib/asan/asan_malloc_win_thunk.cpp

Lines changed: 229 additions & 229 deletions
Large diffs are not rendered by default.
Lines changed: 112 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,112 @@
1-
//===-- asan_win_common_runtime_thunk.cpp --------------------------- -----===//
2-
//
3-
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4-
// See https://llvm.org/LICENSE.txt for license information.
5-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6-
//
7-
//===----------------------------------------------------------------------===//
8-
//
9-
// This file is a part of AddressSanitizer, an address sanity checker.
10-
//
11-
// This file defines things that need to be present in the application modules
12-
// to interact with the ASan DLL runtime correctly and can't be implemented
13-
// using the default "import library" generated when linking the DLL.
14-
//
15-
// This includes:
16-
// - Cloning shadow memory dynamic address from ASAN DLL
17-
// - Creating weak aliases to default implementation imported from asan dll
18-
// - Forwarding the detect_stack_use_after_return runtime option
19-
// - installing a custom SEH handler
20-
//
21-
//===----------------------------------------------------------------------===//
22-
23-
#if defined(SANITIZER_DYNAMIC_RUNTIME_THUNK) || \
24-
defined(SANITIZER_STATIC_RUNTIME_THUNK)
25-
# define SANITIZER_IMPORT_INTERFACE 1
26-
# define WIN32_LEAN_AND_MEAN
27-
# include "asan_win_common_runtime_thunk.h"
28-
29-
# include <windows.h>
30-
31-
# include "sanitizer_common/sanitizer_win_defs.h"
32-
# include "sanitizer_common/sanitizer_win_thunk_interception.h"
33-
34-
// Define weak alias for all weak functions imported from asan dll.
35-
# define INTERFACE_FUNCTION(Name)
36-
# define INTERFACE_WEAK_FUNCTION(Name) REGISTER_WEAK_FUNCTION(Name)
37-
# include "asan_interface.inc"
38-
39-
////////////////////////////////////////////////////////////////////////////////
40-
// Define a copy of __asan_option_detect_stack_use_after_return that should be
41-
// used when linking an MD runtime with a set of object files on Windows.
42-
//
43-
// The ASan MD runtime dllexports '__asan_option_detect_stack_use_after_return',
44-
// so normally we would just dllimport it. Unfortunately, the dllimport
45-
// attribute adds __imp_ prefix to the symbol name of a variable.
46-
// Since in general we don't know if a given TU is going to be used
47-
// with a MT or MD runtime and we don't want to use ugly __imp_ names on Windows
48-
// just to work around this issue, let's clone the variable that is constant
49-
// after initialization anyways.
50-
51-
extern "C" {
52-
__declspec(dllimport) int __asan_should_detect_stack_use_after_return();
53-
int __asan_option_detect_stack_use_after_return;
54-
55-
__declspec(dllimport) void *__asan_get_shadow_memory_dynamic_address();
56-
void *__asan_shadow_memory_dynamic_address;
57-
58-
static void __asan_initialize_cloned_variables() {
59-
__asan_option_detect_stack_use_after_return =
60-
__asan_should_detect_stack_use_after_return();
61-
__asan_shadow_memory_dynamic_address =
62-
__asan_get_shadow_memory_dynamic_address();
63-
}
64-
}
65-
66-
static int asan_thunk_init() {
67-
__asan_initialize_cloned_variables();
68-
69-
# ifdef SANITIZER_STATIC_RUNTIME_THUNK
70-
__asan_initialize_static_thunk();
71-
# endif
72-
73-
return 0;
74-
}
75-
76-
static void WINAPI asan_thread_init(void *mod, unsigned long reason,
77-
void *reserved) {
78-
if (reason == DLL_PROCESS_ATTACH) {
79-
asan_thunk_init();
80-
}
81-
}
82-
83-
// Our cloned variables must be initialized before C/C++ constructors. If TLS
84-
// is used, our .CRT$XLAB initializer will run first. If not, our .CRT$XIB
85-
// initializer is needed as a backup.
86-
extern "C" __declspec(allocate(".CRT$XIB")) int (*__asan_thunk_init)() =
87-
asan_thunk_init;
88-
WIN_FORCE_LINK(__asan_thunk_init);
89-
90-
extern "C" __declspec(allocate(".CRT$XLAB")) void(WINAPI *__asan_tls_init)(
91-
void *, unsigned long, void *) = asan_thread_init;
92-
WIN_FORCE_LINK(__asan_tls_init);
93-
94-
////////////////////////////////////////////////////////////////////////////////
95-
// ASan SEH handling.
96-
// We need to set the ASan-specific SEH handler at the end of CRT initialization
97-
// of each module (see also asan_win.cpp).
98-
extern "C" {
99-
__declspec(dllimport) int __asan_set_seh_filter();
100-
static int SetSEHFilter() { return __asan_set_seh_filter(); }
101-
102-
// Unfortunately, putting a pointer to __asan_set_seh_filter into
103-
// __asan_intercept_seh gets optimized out, so we have to use an extra function.
104-
extern "C" __declspec(allocate(".CRT$XCAB")) int (*__asan_seh_interceptor)() =
105-
SetSEHFilter;
106-
WIN_FORCE_LINK(__asan_seh_interceptor);
107-
}
108-
109-
WIN_FORCE_LINK(__asan_dso_reg_hook)
110-
111-
#endif // defined(SANITIZER_DYNAMIC_RUNTIME_THUNK) ||
112-
// defined(SANITIZER_STATIC_RUNTIME_THUNK)
1+
//===-- asan_win_common_runtime_thunk.cpp --------------------------- -----===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file is a part of AddressSanitizer, an address sanity checker.
10+
//
11+
// This file defines things that need to be present in the application modules
12+
// to interact with the ASan DLL runtime correctly and can't be implemented
13+
// using the default "import library" generated when linking the DLL.
14+
//
15+
// This includes:
16+
// - Cloning shadow memory dynamic address from ASAN DLL
17+
// - Creating weak aliases to default implementation imported from asan dll
18+
// - Forwarding the detect_stack_use_after_return runtime option
19+
// - installing a custom SEH handler
20+
//
21+
//===----------------------------------------------------------------------===//
22+
23+
#if defined(SANITIZER_DYNAMIC_RUNTIME_THUNK) || \
24+
defined(SANITIZER_STATIC_RUNTIME_THUNK)
25+
# define SANITIZER_IMPORT_INTERFACE 1
26+
# define WIN32_LEAN_AND_MEAN
27+
# include "asan_win_common_runtime_thunk.h"
28+
29+
# include <windows.h>
30+
31+
# include "sanitizer_common/sanitizer_win_defs.h"
32+
# include "sanitizer_common/sanitizer_win_thunk_interception.h"
33+
34+
// Define weak alias for all weak functions imported from asan dll.
35+
# define INTERFACE_FUNCTION(Name)
36+
# define INTERFACE_WEAK_FUNCTION(Name) REGISTER_WEAK_FUNCTION(Name)
37+
# include "asan_interface.inc"
38+
39+
////////////////////////////////////////////////////////////////////////////////
40+
// Define a copy of __asan_option_detect_stack_use_after_return that should be
41+
// used when linking an MD runtime with a set of object files on Windows.
42+
//
43+
// The ASan MD runtime dllexports '__asan_option_detect_stack_use_after_return',
44+
// so normally we would just dllimport it. Unfortunately, the dllimport
45+
// attribute adds __imp_ prefix to the symbol name of a variable.
46+
// Since in general we don't know if a given TU is going to be used
47+
// with a MT or MD runtime and we don't want to use ugly __imp_ names on Windows
48+
// just to work around this issue, let's clone the variable that is constant
49+
// after initialization anyways.
50+
51+
extern "C" {
52+
__declspec(dllimport) int __asan_should_detect_stack_use_after_return();
53+
int __asan_option_detect_stack_use_after_return;
54+
55+
__declspec(dllimport) void *__asan_get_shadow_memory_dynamic_address();
56+
void *__asan_shadow_memory_dynamic_address;
57+
58+
static void __asan_initialize_cloned_variables() {
59+
__asan_option_detect_stack_use_after_return =
60+
__asan_should_detect_stack_use_after_return();
61+
__asan_shadow_memory_dynamic_address =
62+
__asan_get_shadow_memory_dynamic_address();
63+
}
64+
}
65+
66+
static int asan_thunk_init() {
67+
__asan_initialize_cloned_variables();
68+
69+
# ifdef SANITIZER_STATIC_RUNTIME_THUNK
70+
__asan_initialize_static_thunk();
71+
# endif
72+
73+
return 0;
74+
}
75+
76+
static void WINAPI asan_thread_init(void *mod, unsigned long reason,
77+
void *reserved) {
78+
if (reason == DLL_PROCESS_ATTACH) {
79+
asan_thunk_init();
80+
}
81+
}
82+
83+
// Our cloned variables must be initialized before C/C++ constructors. If TLS
84+
// is used, our .CRT$XLAB initializer will run first. If not, our .CRT$XIB
85+
// initializer is needed as a backup.
86+
extern "C" __declspec(allocate(".CRT$XIB")) int (*__asan_thunk_init)() =
87+
asan_thunk_init;
88+
WIN_FORCE_LINK(__asan_thunk_init);
89+
90+
extern "C" __declspec(allocate(".CRT$XLAB")) void(WINAPI *__asan_tls_init)(
91+
void *, unsigned long, void *) = asan_thread_init;
92+
WIN_FORCE_LINK(__asan_tls_init);
93+
94+
////////////////////////////////////////////////////////////////////////////////
95+
// ASan SEH handling.
96+
// We need to set the ASan-specific SEH handler at the end of CRT initialization
97+
// of each module (see also asan_win.cpp).
98+
extern "C" {
99+
__declspec(dllimport) int __asan_set_seh_filter();
100+
static int SetSEHFilter() { return __asan_set_seh_filter(); }
101+
102+
// Unfortunately, putting a pointer to __asan_set_seh_filter into
103+
// __asan_intercept_seh gets optimized out, so we have to use an extra function.
104+
extern "C" __declspec(allocate(".CRT$XCAB")) int (*__asan_seh_interceptor)() =
105+
SetSEHFilter;
106+
WIN_FORCE_LINK(__asan_seh_interceptor);
107+
}
108+
109+
WIN_FORCE_LINK(__asan_dso_reg_hook)
110+
111+
#endif // defined(SANITIZER_DYNAMIC_RUNTIME_THUNK) ||
112+
// defined(SANITIZER_STATIC_RUNTIME_THUNK)
Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
//===-- asan_win_common_runtime_thunk.h -------------------------*- C++ -*-===//
2-
//
3-
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4-
// See https://llvm.org/LICENSE.txt for license information.
5-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6-
//
7-
//===----------------------------------------------------------------------===//
8-
//
9-
// This file is a part of AddressSanitizer, an address sanity checker.
10-
//
11-
// This file defines things that need to be present in the application modules
12-
// to interact with the ASan DLL runtime correctly and can't be implemented
13-
// using the default "import library" generated when linking the DLL.
14-
//
15-
//===----------------------------------------------------------------------===//
16-
17-
#if defined(SANITIZER_STATIC_RUNTIME_THUNK) || \
18-
defined(SANITIZER_DYNAMIC_RUNTIME_THUNK)
19-
# include "sanitizer_common/sanitizer_win_defs.h"
20-
21-
# pragma section(".CRT$XIB", long, \
22-
read) // C initializer (during C init before dyninit)
23-
# pragma section(".CRT$XID", long, \
24-
read) // First C initializer after CRT initializers
25-
# pragma section(".CRT$XCAB", long, \
26-
read) // First C++ initializer after startup initializers
27-
28-
# pragma section(".CRT$XTW", long, read) // First ASAN globals terminator
29-
# pragma section(".CRT$XTY", long, read) // Last ASAN globals terminator
30-
31-
# pragma section(".CRT$XLAB", long, read) // First TLS initializer
32-
33-
# ifdef SANITIZER_STATIC_RUNTIME_THUNK
34-
extern "C" void __asan_initialize_static_thunk();
35-
# endif
36-
37-
#endif // defined(SANITIZER_STATIC_RUNTIME_THUNK) ||
1+
//===-- asan_win_common_runtime_thunk.h -------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file is a part of AddressSanitizer, an address sanity checker.
10+
//
11+
// This file defines things that need to be present in the application modules
12+
// to interact with the ASan DLL runtime correctly and can't be implemented
13+
// using the default "import library" generated when linking the DLL.
14+
//
15+
//===----------------------------------------------------------------------===//
16+
17+
#if defined(SANITIZER_STATIC_RUNTIME_THUNK) || \
18+
defined(SANITIZER_DYNAMIC_RUNTIME_THUNK)
19+
# include "sanitizer_common/sanitizer_win_defs.h"
20+
21+
# pragma section(".CRT$XIB", long, \
22+
read) // C initializer (during C init before dyninit)
23+
# pragma section(".CRT$XID", long, \
24+
read) // First C initializer after CRT initializers
25+
# pragma section(".CRT$XCAB", long, \
26+
read) // First C++ initializer after startup initializers
27+
28+
# pragma section(".CRT$XTW", long, read) // First ASAN globals terminator
29+
# pragma section(".CRT$XTY", long, read) // Last ASAN globals terminator
30+
31+
# pragma section(".CRT$XLAB", long, read) // First TLS initializer
32+
33+
# ifdef SANITIZER_STATIC_RUNTIME_THUNK
34+
extern "C" void __asan_initialize_static_thunk();
35+
# endif
36+
37+
#endif // defined(SANITIZER_STATIC_RUNTIME_THUNK) ||
3838
// defined(SANITIZER_DYNAMIC_RUNTIME_THUNK)

0 commit comments

Comments
 (0)