Skip to content

Commit 7ed78a3

Browse files
vitalybukatmsri
authored andcommitted
[NFC][sanitizer] Move InitTlsSize into InitializePlatformEarly (llvm#108921)
1 parent 9759f48 commit 7ed78a3

File tree

14 files changed

+15
-24
lines changed

14 files changed

+15
-24
lines changed

compiler-rt/lib/asan/asan_rtl.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,6 @@ static bool AsanInitInternal() {
478478
if (flags()->start_deactivated)
479479
AsanDeactivate();
480480

481-
// interceptors
482-
InitTlsSize();
483-
484481
// Create main thread.
485482
AsanThread *main_thread = CreateMainThread();
486483
CHECK_EQ(0, main_thread->tid());

compiler-rt/lib/dfsan/dfsan.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,8 @@ static void DFsanInit(int argc, char **argv, char **envp) {
12621262

12631263
CheckASLR();
12641264

1265+
InitializePlatformEarly();
1266+
12651267
if (!InitShadowWithReExec(dfsan_get_track_origins())) {
12661268
Printf("FATAL: DataflowSanitizer can not mmap the shadow memory.\n");
12671269
DumpProcessMap();

compiler-rt/lib/hwasan/hwasan.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,6 @@ __attribute__((constructor(0))) void __hwasan_init() {
357357
hwasan_init_is_running = 1;
358358
SanitizerToolName = "HWAddressSanitizer";
359359

360-
InitTlsSize();
361-
362360
CacheBinaryName();
363361
InitializeFlags();
364362

@@ -367,6 +365,8 @@ __attribute__((constructor(0))) void __hwasan_init() {
367365

368366
__sanitizer_set_report_path(common_flags()->log_path);
369367

368+
InitializePlatformEarly();
369+
370370
AndroidTestTlsSlot();
371371

372372
DisableCoreDumperIfNecessary();

compiler-rt/lib/lsan/lsan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ extern "C" void __lsan_init() {
9292
CacheBinaryName();
9393
AvoidCVE_2016_2143();
9494
InitializeFlags();
95+
InitializePlatformEarly();
9596
InitCommonLsan();
9697
InitializeAllocator();
9798
ReplaceSystemMalloc();
98-
InitTlsSize();
9999
InitializeInterceptors();
100100
InitializeThreads();
101101
InstallDeadlySignalHandlers(LsanOnDeadlySignal);

compiler-rt/lib/memprof/memprof_rtl.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,6 @@ static void MemprofInitInternal() {
213213

214214
InitializeCoverage(common_flags()->coverage, common_flags()->coverage_dir);
215215

216-
// interceptors
217-
InitTlsSize();
218-
219216
// Create main thread.
220217
MemprofThread *main_thread = CreateMainThread();
221218
CHECK_EQ(0, main_thread->tid());

compiler-rt/lib/msan/msan.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,11 @@ void __msan_init() {
457457

458458
__sanitizer_set_report_path(common_flags()->log_path);
459459

460+
InitializePlatformEarly();
461+
460462
InitializeInterceptors();
461463
InstallAtForkHandler();
462464
CheckASLR();
463-
InitTlsSize();
464465
InstallDeadlySignalHandlers(MsanOnDeadlySignal);
465466
InstallAtExitHandler(); // Needs __cxa_atexit interceptor.
466467

compiler-rt/lib/sanitizer_common/sanitizer_common_nolibc.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace __sanitizer {
2222
#if !SANITIZER_WINDOWS
2323
# if SANITIZER_LINUX
2424
void LogMessageOnPrintf(const char *str) {}
25+
void InitTlsSize() {}
2526
# endif
2627
void WriteToSyslog(const char *buffer) {}
2728
void Abort() { internal__exit(1); }

compiler-rt/lib/sanitizer_common/sanitizer_fuchsia.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ void DisableCoreDumperIfNecessary() {}
9494
void InstallDeadlySignalHandlers(SignalHandlerType handler) {}
9595
void SetAlternateSignalStack() {}
9696
void UnsetAlternateSignalStack() {}
97-
void InitTlsSize() {}
9897

9998
bool SignalContext::IsStackOverflow() const { return false; }
10099
void SignalContext::DumpAllRegisters(void *context) { UNIMPLEMENTED(); }

compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,9 +2672,7 @@ static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
26722672

26732673
void SignalContext::InitPcSpBp() { GetPcSpBp(context, &pc, &sp, &bp); }
26742674

2675-
void InitializePlatformEarly() {
2676-
// Do nothing.
2677-
}
2675+
void InitializePlatformEarly() { InitTlsSize(); }
26782676

26792677
void CheckASLR() {
26802678
# if SANITIZER_NETBSD

compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,12 @@ void InitTlsSize() {
228228

229229
# if defined(__aarch64__) || defined(__x86_64__) || \
230230
defined(__powerpc64__) || defined(__loongarch__)
231-
void *get_tls_static_info = dlsym(RTLD_DEFAULT, "_dl_get_tls_static_info");
231+
auto *get_tls_static_info = (void (*)(size_t *, size_t *))dlsym(
232+
RTLD_DEFAULT, "_dl_get_tls_static_info");
232233
size_t tls_align;
233-
((void (*)(size_t *, size_t *))get_tls_static_info)(&g_tls_size, &tls_align);
234+
// Can be null if static link.
235+
if (get_tls_static_info)
236+
get_tls_static_info(&g_tls_size, &tls_align);
234237
# endif
235238
}
236239
# else

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,6 @@ uptr GetTlsSize() {
545545
return 0;
546546
}
547547

548-
void InitTlsSize() {
549-
}
550-
551548
uptr TlsBaseAddr() {
552549
uptr segbase = 0;
553550
#if defined(__x86_64__)

compiler-rt/lib/sanitizer_common/sanitizer_win.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -873,9 +873,6 @@ uptr GetTlsSize() {
873873
return 0;
874874
}
875875

876-
void InitTlsSize() {
877-
}
878-
879876
void GetThreadStackAndTls(bool main, uptr *stk_begin, uptr *stk_end,
880877
uptr *tls_begin, uptr *tls_end) {
881878
# if SANITIZER_GO

compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ void InitializePlatform() {
418418
Die();
419419
}
420420

421-
InitTlsSize();
422421
#endif // !SANITIZER_GO
423422
}
424423

compiler-rt/lib/ubsan/ubsan_init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ static void CommonStandaloneInit() {
4343
SanitizerToolName = GetSanititizerToolName();
4444
CacheBinaryName();
4545
InitializeFlags();
46-
__sanitizer::InitializePlatformEarly();
4746
__sanitizer_set_report_path(common_flags()->log_path);
47+
__sanitizer::InitializePlatformEarly();
4848
AndroidLogInit();
4949
InitializeCoverage(common_flags()->coverage, common_flags()->coverage_dir);
5050
CommonInit();

0 commit comments

Comments
 (0)