Stackdb
Stackdb is a stackable, multi-target and -level source debugger and memory forensics library.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
loadallforever.c
Go to the documentation of this file.
1 #define _GNU_SOURCE
2 
3 #include <sys/mman.h>
4 #include <dlfcn.h>
5 
6 /*
7  * Wrap __libc_start_main so that we mlockall to force all pages, both
8  * now and future, to be loaded into RAM and stay there... unless the
9  * process itself changes that policy down the road. Best-effort, of
10  * course.
11  */
12 int __libc_start_main(int (*main) (int,char **,char **),
13  int argc,char **ubp_av,
14  void (*init) (void),
15  void (*fini)(void),
16  void (*rtld_fini)(void),
17  void (*stack_end)) {
18  int (*original__libc_start_main)(int (*main) (int,char **,char **),
19  int argc,char **ubp_av,
20  void (*init) (void),
21  void (*fini)(void),
22  void (*rtld_fini)(void),
23  void (*stack_end));
24 
25  mlockall(MCL_CURRENT | MCL_FUTURE);
26 
27  original__libc_start_main = dlsym(RTLD_NEXT,"__libc_start_main");
28  return original__libc_start_main(main,argc,ubp_av,
29  init,fini,rtld_fini,stack_end);
30 }
int main(int argc, char **argv)
Definition: debugserver.c:306
int __libc_start_main(int(*main)(int, char **, char **), int argc, char **ubp_av, void(*init)(void), void(*fini)(void), void(*rtld_fini)(void), void(*stack_end))