[CRIU] [PATCH 4/5] vdso: wrap the vDSO ELF identifier and symbol name table definitions into the macro

Alexander Kartashov alekskartashov at parallels.com
Tue Mar 18 10:14:14 PDT 2014


These variables are architecture-specific so they shouldn't appear
in the upcoming generic version of the routine vdso_fill_symtable().

At first glance it seems it's better to make these variables global
and reference them as external in the generic version of the routine.
However experiments with the vDSO restore routine for AArch64 showed
that the AArch64 compiler uses the GOT to access such variables
rendering our blobs unrelocatable.

Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
---
 arch/x86/include/asm/vdso.h |   15 +++++++++++++++
 arch/x86/vdso-pie.c         |   16 +---------------
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/arch/x86/include/asm/vdso.h b/arch/x86/include/asm/vdso.h
index a9173ea..ce3909b 100644
--- a/arch/x86/include/asm/vdso.h
+++ b/arch/x86/include/asm/vdso.h
@@ -25,6 +25,21 @@ enum {
 #define VDSO_SYMBOL_TIME_NAME		"__vdso_time"
 
 
+#define DECLARE_VDSO(ident_name, symtab_name)					\
+										\
+char ident_name[] = {								\
+	0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00,				\
+	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,				\
+};										\
+										\
+char *symtab_name[VDSO_SYMBOL_MAX] = {						\
+	[VDSO_SYMBOL_GETTIMEOFDAY]	= VDSO_SYMBOL_GETTIMEOFDAY_NAME,	\
+	[VDSO_SYMBOL_GETCPU]		= VDSO_SYMBOL_GETCPU_NAME,		\
+	[VDSO_SYMBOL_CLOCK_GETTIME]	= VDSO_SYMBOL_CLOCK_GETTIME_NAME,	\
+	[VDSO_SYMBOL_TIME]		= VDSO_SYMBOL_TIME_NAME,		\
+};
+
+
 struct vdso_symtable;
 struct parasite_ctl;
 struct vm_area_list;
diff --git a/arch/x86/vdso-pie.c b/arch/x86/vdso-pie.c
index 2634e3a..2d957f2 100644
--- a/arch/x86/vdso-pie.c
+++ b/arch/x86/vdso-pie.c
@@ -91,21 +91,7 @@ int vdso_fill_symtable(char *mem, size_t size, struct vdso_symtable *t)
 	unsigned long base = VDSO_BAD_ADDR;
 	unsigned int i, j, k;
 
-	/*
-	 * Elf header bytes. For detailed
-	 * description see Elf specification.
-	 */
-	char vdso_ident[] = {
-		0x7f, 0x45, 0x4c, 0x46, 0x02, 0x01, 0x01, 0x00,
-		0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-	};
-
-	char *vdso_symbols[VDSO_SYMBOL_MAX] = {
-		[VDSO_SYMBOL_GETTIMEOFDAY]	= VDSO_SYMBOL_GETTIMEOFDAY_NAME,
-		[VDSO_SYMBOL_GETCPU]		= VDSO_SYMBOL_GETCPU_NAME,
-		[VDSO_SYMBOL_CLOCK_GETTIME]	= VDSO_SYMBOL_CLOCK_GETTIME_NAME,
-		[VDSO_SYMBOL_TIME]		= VDSO_SYMBOL_TIME_NAME,
-	};
+	DECLARE_VDSO(vdso_ident, vdso_symbols);
 
 	BUILD_BUG_ON(sizeof(vdso_ident) != sizeof(ehdr->e_ident));
 
-- 
1.7.9.5



More information about the CRIU mailing list