forked from OSchip/llvm-project
parent
4b1f1031e6
commit
cf4d3a027d
|
@ -41,8 +41,6 @@ extern "C" void* _DYNAMIC;
|
||||||
|
|
||||||
namespace __asan {
|
namespace __asan {
|
||||||
|
|
||||||
const uptr kMaxThreadStackSize = 256 * (1 << 20); // 256M
|
|
||||||
|
|
||||||
void *AsanDoesNotSupportStaticLinkage() {
|
void *AsanDoesNotSupportStaticLinkage() {
|
||||||
// This will fail to link with -static.
|
// This will fail to link with -static.
|
||||||
return &_DYNAMIC; // defined in link.h
|
return &_DYNAMIC; // defined in link.h
|
||||||
|
|
|
@ -28,7 +28,7 @@ const uptr kPageSize = 1UL << kPageSizeBits;
|
||||||
|
|
||||||
// Threads
|
// Threads
|
||||||
int GetPid();
|
int GetPid();
|
||||||
void GetThreadStackTopAndBottom(bool is_main_thread, uptr *stack_top,
|
void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,
|
||||||
uptr *stack_bottom);
|
uptr *stack_bottom);
|
||||||
|
|
||||||
// Memory management
|
// Memory management
|
||||||
|
|
|
@ -73,12 +73,12 @@ int internal_dup2(int oldfd, int newfd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------- sanitizer_common.h
|
// ----------------- sanitizer_common.h
|
||||||
void GetThreadStackTopAndBottom(bool is_main_thread, uptr *stack_top,
|
void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,
|
||||||
uptr *stack_bottom) {
|
uptr *stack_bottom) {
|
||||||
static const uptr kMaxThreadStackSize = 256 * (1 << 20); // 256M
|
static const uptr kMaxThreadStackSize = 256 * (1 << 20); // 256M
|
||||||
CHECK(stack_top);
|
CHECK(stack_top);
|
||||||
CHECK(stack_bottom);
|
CHECK(stack_bottom);
|
||||||
if (is_main_thread) {
|
if (at_initialization) {
|
||||||
// This is the main thread. Libpthread may not be initialized yet.
|
// This is the main thread. Libpthread may not be initialized yet.
|
||||||
struct rlimit rl;
|
struct rlimit rl;
|
||||||
CHECK(getrlimit(RLIMIT_STACK, &rl) == 0);
|
CHECK(getrlimit(RLIMIT_STACK, &rl) == 0);
|
||||||
|
|
|
@ -70,14 +70,14 @@ int internal_dup2(int oldfd, int newfd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------- sanitizer_common.h
|
// ----------------- sanitizer_common.h
|
||||||
void GetThreadStackTopAndBottom(bool is_main_thread, uptr *stack_top,
|
void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,
|
||||||
uptr *stack_bottom) {
|
uptr *stack_bottom) {
|
||||||
CHECK(stack_top);
|
CHECK(stack_top);
|
||||||
CHECK(stack_bottom);
|
CHECK(stack_bottom);
|
||||||
uptr stacksize = pthread_get_stacksize_np(pthread_self());
|
uptr stacksize = pthread_get_stacksize_np(pthread_self());
|
||||||
void *stackaddr = pthread_get_stackaddr_np(pthread_self());
|
void *stackaddr = pthread_get_stackaddr_np(pthread_self());
|
||||||
*stack_top = (uptr)stackaddr;
|
*stack_top = (uptr)stackaddr;
|
||||||
*stack_bottom = stack_top_ - stacksize;
|
*stack_bottom = *stack_top - stacksize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ int GetPid() {
|
||||||
return GetProcessId(GetCurrentProcess());
|
return GetProcessId(GetCurrentProcess());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetThreadStackTopAndBottom(bool is_main_thread, uptr *stack_top,
|
void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,
|
||||||
uptr *stack_bottom) {
|
uptr *stack_bottom) {
|
||||||
CHECK(stack_top);
|
CHECK(stack_top);
|
||||||
CHECK(stack_bottom);
|
CHECK(stack_bottom);
|
||||||
|
|
Loading…
Reference in New Issue