1515#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD || \
1616 SANITIZER_SOLARIS
1717
18- #include " asan_interceptors.h "
19- #include " asan_internal.h "
20- #include " asan_premap_shadow.h "
21- #include " asan_thread.h "
22- #include " sanitizer_common/sanitizer_flags.h "
23- #include " sanitizer_common/sanitizer_freebsd.h "
24- #include " sanitizer_common/sanitizer_libc.h "
25- #include " sanitizer_common/sanitizer_procmaps.h "
26-
27- #include < sys/time .h>
28- #include < sys/resource .h>
29- #include < sys/mman .h>
30- # include < sys/syscall.h >
31- #include < sys/types.h >
32- #include < dlfcn.h >
33- #include < fcntl.h >
34- #include < limits.h >
35- #include < pthread.h >
36- #include < stdio.h >
37- #include < unistd.h >
38- #include < unwind.h >
39-
40- #if SANITIZER_FREEBSD
41- #include < sys/link_elf.h>
42- #endif
43-
44- #if SANITIZER_SOLARIS
45- #include < link.h>
46- #endif
47-
48- #if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS
49- #include < ucontext.h>
50- extern " C" void * _DYNAMIC;
51- #elif SANITIZER_NETBSD
52- #include < link_elf.h>
53- #include < ucontext.h>
18+ # include < dlfcn.h >
19+ # include < fcntl.h >
20+ # include < limits.h >
21+ # include < pthread.h >
22+ # include < stdio.h >
23+ # include < sys/mman.h >
24+ # include < sys/resource.h >
25+ # include < sys/syscall.h >
26+ # include < sys/time.h >
27+ # include < sys/types .h>
28+ # include < unistd .h>
29+ # include < unwind .h>
30+
31+ # include " asan_interceptors.h "
32+ # include " asan_internal.h "
33+ # include " asan_premap_shadow.h "
34+ # include " asan_thread.h "
35+ # include " sanitizer_common/sanitizer_flags.h "
36+ # include " sanitizer_common/sanitizer_freebsd.h "
37+ # include " sanitizer_common/sanitizer_libc.h "
38+ # include " sanitizer_common/sanitizer_procmaps.h "
39+
40+ # if SANITIZER_FREEBSD
41+ # include < sys/link_elf.h>
42+ # endif
43+
44+ # if SANITIZER_SOLARIS
45+ # include < link.h>
46+ # endif
47+
48+ # if SANITIZER_ANDROID || SANITIZER_FREEBSD || SANITIZER_SOLARIS
49+ # include < ucontext.h>
50+ extern " C" void * _DYNAMIC;
51+ # elif SANITIZER_NETBSD
52+ # include < link_elf.h>
53+ # include < ucontext.h>
5454extern Elf_Dyn _DYNAMIC;
55- #else
56- #include < sys/ucontext .h>
57- #include < link .h>
55+ # else
56+ # include < link .h>
57+ # include < sys/ucontext .h>
5858extern ElfW (Dyn) _DYNAMIC[];
59- #endif
59+ # endif
6060
6161// x86-64 FreeBSD 9.2 and older define 'ucontext_t' incorrectly in
6262// 32-bit mode.
63- #if SANITIZER_FREEBSD && (SANITIZER_WORDSIZE == 32) && \
64- __FreeBSD_version <= 902001 // v9.2
65- #define ucontext_t xucontext_t
66- #endif
63+ # if SANITIZER_FREEBSD && (SANITIZER_WORDSIZE == 32) && \
64+ __FreeBSD_version <= 902001 // v9.2
65+ # define ucontext_t xucontext_t
66+ # endif
6767
6868typedef enum {
6969 ASAN_RT_VERSION_UNDEFINED = 0 ,
@@ -74,21 +74,21 @@ typedef enum {
7474// FIXME: perhaps also store abi version here?
7575extern " C" {
7676SANITIZER_INTERFACE_ATTRIBUTE
77- asan_rt_version_t __asan_rt_version;
77+ asan_rt_version_t __asan_rt_version;
7878}
7979
8080namespace __asan {
8181
8282void InitializePlatformInterceptors () {}
8383void InitializePlatformExceptionHandlers () {}
84- bool IsSystemHeapAddress (uptr addr) { return false ; }
84+ bool IsSystemHeapAddress (uptr addr) { return false ; }
8585
8686void *AsanDoesNotSupportStaticLinkage () {
8787 // This will fail to link with -static.
8888 return &_DYNAMIC;
8989}
9090
91- #if ASAN_PREMAP_SHADOW
91+ # if ASAN_PREMAP_SHADOW
9292uptr FindPremappedShadowStart (uptr shadow_size_bytes) {
9393 uptr granularity = GetMmapGranularity ();
9494 uptr shadow_start = reinterpret_cast <uptr>(&__asan_shadow);
@@ -98,14 +98,14 @@ uptr FindPremappedShadowStart(uptr shadow_size_bytes) {
9898 UnmapFromTo (shadow_start + shadow_size, shadow_start + premap_shadow_size);
9999 return shadow_start;
100100}
101- #endif
101+ # endif
102102
103103uptr FindDynamicShadowStart () {
104104 uptr shadow_size_bytes = MemToShadowSize (kHighMemEnd );
105- #if ASAN_PREMAP_SHADOW
105+ # if ASAN_PREMAP_SHADOW
106106 if (!PremapShadowFailed ())
107107 return FindPremappedShadowStart (shadow_size_bytes);
108- #endif
108+ # endif
109109
110110 return MapDynamicShadow (shadow_size_bytes, ASAN_SHADOW_SCALE,
111111 /* min_shadow_base_alignment*/ 0 , kHighMemEnd );
@@ -121,11 +121,11 @@ void FlushUnneededASanShadowMemory(uptr p, uptr size) {
121121 ReleaseMemoryPagesToOS (MemToShadow (p), MemToShadow (p + size));
122122}
123123
124- #if SANITIZER_ANDROID
124+ # if SANITIZER_ANDROID
125125// FIXME: should we do anything for Android?
126126void AsanCheckDynamicRTPrereqs () {}
127127void AsanCheckIncompatibleRT () {}
128- #else
128+ # else
129129static int FindFirstDSOCallback (struct dl_phdr_info *info, size_t size,
130130 void *data) {
131131 VReport (2 , " info->dlpi_name = %s\t info->dlpi_addr = %p\n " , info->dlpi_name ,
@@ -154,7 +154,7 @@ static int FindFirstDSOCallback(struct dl_phdr_info *info, size_t size,
154154
155155static bool IsDynamicRTName (const char *libname) {
156156 return internal_strstr (libname, " libclang_rt.asan" ) ||
157- internal_strstr (libname, " libasan.so" );
157+ internal_strstr (libname, " libasan.so" );
158158}
159159
160160static void ReportIncompatibleRT () {
@@ -170,9 +170,10 @@ void AsanCheckDynamicRTPrereqs() {
170170 const char *first_dso_name = nullptr ;
171171 dl_iterate_phdr (FindFirstDSOCallback, &first_dso_name);
172172 if (first_dso_name && first_dso_name[0 ] && !IsDynamicRTName (first_dso_name)) {
173- Report (" ASan runtime does not come first in initial library list; "
174- " you should either link runtime to your application or "
175- " manually preload it with LD_PRELOAD.\n " );
173+ Report (
174+ " ASan runtime does not come first in initial library list; "
175+ " you should either link runtime to your application or "
176+ " manually preload it with LD_PRELOAD.\n " );
176177 Die ();
177178 }
178179}
@@ -190,13 +191,14 @@ void AsanCheckIncompatibleRT() {
190191 // as early as possible, otherwise ASan interceptors could bind to
191192 // the functions in dynamic ASan runtime instead of the functions in
192193 // system libraries, causing crashes later in ASan initialization.
193- MemoryMappingLayout proc_maps (/* cache_enabled*/ true );
194+ MemoryMappingLayout proc_maps (/* cache_enabled*/ true );
194195 char filename[PATH_MAX];
195196 MemoryMappedSegment segment (filename, sizeof (filename));
196197 while (proc_maps.Next (&segment)) {
197198 if (IsDynamicRTName (segment.filename )) {
198- Report (" Your application is linked against "
199- " incompatible ASan runtimes.\n " );
199+ Report (
200+ " Your application is linked against "
201+ " incompatible ASan runtimes.\n " );
200202 Die ();
201203 }
202204 }
@@ -206,11 +208,11 @@ void AsanCheckIncompatibleRT() {
206208 }
207209 }
208210}
209- #endif // SANITIZER_ANDROID
211+ # endif // SANITIZER_ANDROID
210212
211213# if ASAN_INTERCEPT_SWAPCONTEXT
212214void ReadContextStack (void *context, uptr *stack, uptr *ssize) {
213- ucontext_t *ucp = (ucontext_t *)context;
215+ ucontext_t *ucp = (ucontext_t *)context;
214216 *stack = (uptr)ucp->uc_stack .ss_sp ;
215217 *ssize = ucp->uc_stack .ss_size ;
216218}
@@ -222,9 +224,7 @@ void ResetContextStack(void *context) {
222224}
223225# endif // ASAN_INTERCEPT_SWAPCONTEXT
224226
225- void *AsanDlSymNext (const char *sym) {
226- return dlsym (RTLD_NEXT, sym);
227- }
227+ void *AsanDlSymNext (const char *sym) { return dlsym (RTLD_NEXT, sym); }
228228
229229bool HandleDlopenInit () {
230230 // Not supported on this platform.
@@ -233,7 +233,7 @@ bool HandleDlopenInit() {
233233 return false ;
234234}
235235
236- } // namespace __asan
236+ } // namespace __asan
237237
238238#endif // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD ||
239239 // SANITIZER_SOLARIS
0 commit comments