1 //===-- memprof_linux.cpp ------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file is a part of MemProfiler, a memory profiler.
11 // Linux-specific details.
12 //===----------------------------------------------------------------------===//
14 #include "sanitizer_common/sanitizer_platform.h"
19 #include "memprof_interceptors.h"
20 #include "memprof_internal.h"
21 #include "memprof_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"
34 #include <sys/resource.h>
35 #include <sys/syscall.h>
37 #include <sys/types.h>
38 #include <sys/ucontext.h>
42 extern ElfW(Dyn
) _DYNAMIC
[];
45 MEMPROF_RT_VERSION_UNDEFINED
= 0,
46 MEMPROF_RT_VERSION_DYNAMIC
,
47 MEMPROF_RT_VERSION_STATIC
,
48 } memprof_rt_version_t
;
50 // FIXME: perhaps also store abi version here?
52 SANITIZER_INTERFACE_ATTRIBUTE
53 memprof_rt_version_t __memprof_rt_version
;
58 void InitializePlatformInterceptors() {}
59 void InitializePlatformExceptionHandlers() {}
61 void *MemprofDoesNotSupportStaticLinkage() {
62 // This will fail to link with -static.
66 uptr
FindDynamicShadowStart() {
67 uptr shadow_size_bytes
= MemToShadowSize(kHighMemEnd
);
68 return MapDynamicShadow(shadow_size_bytes
, SHADOW_SCALE
,
69 /*min_shadow_base_alignment*/ 0, kHighMemEnd
);
72 void *MemprofDlSymNext(const char *sym
) { return dlsym(RTLD_NEXT
, sym
); }
74 } // namespace __memprof