add support for labelling memory regions

This commit is contained in:
Daniel Micay 2018-12-11 12:37:37 -05:00
parent ae96835b94
commit c9df70d934
4 changed files with 31 additions and 0 deletions

View file

@ -1,6 +1,15 @@
#include <errno.h>
#include <sys/mman.h>
#include <sys/prctl.h>
#ifndef PR_SET_VMA
#define PR_SET_VMA 0x53564d41
#endif
#ifndef PR_SET_VMA_ANON_NAME
#define PR_SET_VMA_ANON_NAME 0
#endif
#include "memory.h"
#include "util.h"
@ -80,3 +89,9 @@ int memory_remap_fixed(void *old, size_t old_size, void *new, size_t new_size) {
}
return 0;
}
void memory_set_name(UNUSED void *ptr, UNUSED size_t size, UNUSED const char *name) {
#ifdef LABEL_MEMORY
prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, ptr, size, name);
#endif
}