Commit e44b3dbe authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

vdso: Initialize vdso data on startup

During criu startup we need to fill symbol table of own
run-time vdso provided by the kernel. We will need this
data for vdso proxy.

Because this functions are not used in restorer code,
we move them out of PIE (since PIE code must remain
as small as possible).
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 61cc86dd
......@@ -47,6 +47,7 @@ obj-y += page-xfer.o
obj-y += page-read.o
obj-y += kerndat.o
obj-y += stats.o
obj-y += arch/$(ARCH)/vdso.o
ifneq ($(MAKECMDGOALS),clean)
incdeps := y
......
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <elf.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include "asm/string.h"
#include "asm/types.h"
#include "compiler.h"
#include "crtools.h"
#include "vdso.h"
#include "log.h"
......
#include <sys/types.h>
#include "vdso.h"
#include "log.h"
#ifdef LOG_PREFIX
# undef LOG_PREFIX
#endif
#define LOG_PREFIX "vdso: "
struct vdso_symtable vdso_sym_rt = VDSO_SYMTABLE_INIT;
int vdso_init(void)
{
return 0;
}
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <elf.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include "asm/types.h"
#include "compiler.h"
#include "crtools.h"
#include "kerndat.h"
#include "vdso.h"
#include "log.h"
#include "mem.h"
#ifdef LOG_PREFIX
# undef LOG_PREFIX
#endif
#define LOG_PREFIX "vdso: "
struct vdso_symtable vdso_sym_rt = VDSO_SYMTABLE_INIT;
static int vdso_fill_self_symtable(struct vdso_symtable *s)
{
char buf[512];
int ret = -1;
FILE *maps;
VDSO_INIT_SYMTABLE(s);
maps = fopen("/proc/self/maps", "r");
if (!maps) {
pr_perror("Can't open self-vma");
return -1;
}
while (fgets(buf, sizeof(buf), maps)) {
unsigned long start, end;
if (strstr(buf, "[vdso]") == NULL)
continue;
ret = sscanf(buf, "%lx-%lx", &start, &end);
if (ret != 2) {
ret = -1;
pr_err("Can't find vDSO bounds\n");
break;
}
s->vma_start = start;
s->vma_end = end;
ret = vdso_fill_symtable((void *)start, end - start, s);
break;
}
fclose(maps);
return ret;
}
int vdso_init(void)
{
if (vdso_fill_self_symtable(&vdso_sym_rt))
return -1;
return 0;
}
......@@ -62,6 +62,7 @@
#include "stats.h"
#include "mem.h"
#include "page-pipe.h"
#include "vdso.h"
#include "asm/dump.h"
......@@ -1683,6 +1684,9 @@ int cr_dump_tasks(pid_t pid)
if (cpu_init())
goto err;
if (vdso_init())
goto err;
if (write_img_inventory())
goto err;
......
......@@ -57,6 +57,7 @@
#include "file-lock.h"
#include "page-read.h"
#include "sysctl.h"
#include "vdso.h"
#include "protobuf.h"
#include "protobuf/sa.pb-c.h"
......@@ -1315,6 +1316,9 @@ int cr_restore_tasks(struct cr_options *opts)
if (cpu_init() < 0)
return -1;
if (vdso_init())
return -1;
if (prepare_task_entries() < 0)
return -1;
......
......@@ -66,4 +66,7 @@ static inline unsigned long vdso_vma_size(struct vdso_symtable *t)
return t->vma_end - t->vma_start;
}
extern struct vdso_symtable vdso_sym_rt;
extern int vdso_init(void);
#endif /* __CR_VDSO_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment