[CRIU] [PATCH 2/2] compel: plugins, std -- Build syscalls and used in CRIU, v2

Cyrill Gorcunov gorcunov at openvz.org
Fri Sep 23 06:14:41 PDT 2016


Instead of building separate syscalls in criu lets move them into compel
and reuse in CRIU. Note the following significant changes are introduced:

 - no compat-mode support in CRIU, it's commented out and needs to be
   implemented on compel level as std-32.built-in.o plugin;

 - travis doesn't pass on non-x86 architectures for some reason,
   not sure yet why and how to resolve the issue.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 Makefile                                           |   6 +-
 compel/arch/aarch64/plugins/include/asm/linkage.h  |   1 +
 compel/arch/aarch64/plugins/include/asm/prologue.h |   1 +
 .../aarch64/plugins/include/asm/syscall-types.h    |  26 ++++
 .../aarch64/plugins/std/syscalls/Makefile.syscalls |   1 +
 .../plugins/std/syscalls/gen-sys-exec-tbl.pl       |   1 +
 .../aarch64/plugins/std/syscalls/gen-syscalls.pl   |   1 +
 .../aarch64/plugins/std/syscalls}/syscall-aux.S    |   0
 .../aarch64/plugins/std/syscalls}/syscall-aux.h    |   0
 .../aarch64/plugins/std}/syscalls/syscall-common.S |   0
 .../arch/aarch64/plugins/std/syscalls/syscall.def  |   1 +
 compel/arch/arm/plugins/include/asm/linkage.h      |   1 +
 compel/arch/arm/plugins/include/asm/prologue.h     |   1 +
 .../arch/arm/plugins/include/asm/syscall-types.h   |  26 ++++
 .../arm/plugins/std/syscalls/Makefile.syscalls     |  59 ++++++++
 .../arm/plugins/std/syscalls}/gen-sys-exec-tbl.pl  |   0
 .../arch/arm/plugins/std/syscalls}/gen-syscalls.pl |   8 +-
 .../arch/arm/plugins/std/syscalls}/syscall-aux.S   |   0
 .../arch/arm/plugins/std/syscalls}/syscall-aux.h   |   0
 .../arm/plugins/std}/syscalls/syscall-common.S     |   0
 .../arch/arm/plugins/std}/syscalls/syscall.def     |   0
 compel/arch/ppc64/plugins/include/asm/linkage.h    |   1 +
 compel/arch/ppc64/plugins/include/asm/prologue.h   |   1 +
 .../arch/ppc64/plugins/include/asm/syscall-types.h |  26 ++++
 .../ppc64/plugins/std/syscalls/Makefile.syscalls   |  57 ++++++++
 .../plugins/std}/syscalls/syscall-common-ppc64.S   |   0
 .../ppc64/plugins/std}/syscalls/syscall-ppc64.tbl  |   0
 .../arch/x86/plugins/include/asm/syscall-types.h   |  10 +-
 .../x86/plugins/std/syscalls/Makefile.syscalls     | 122 ++++++++++++++++
 compel/plugins/Makefile                            | 127 +++--------------
 compel/plugins/include/uapi/std/asm/.gitignore     |   0
 compel/plugins/include/uapi/std/syscall-types.h    |   2 +-
 compel/plugins/std/std.c                           |   4 +-
 compel/plugins/std/string.c                        |   3 +
 criu/Makefile                                      |  26 ++--
 criu/Makefile.config                               |  14 +-
 criu/Makefile.crtools                              |   4 +
 criu/arch/aarch64/Makefile                         |   2 +
 criu/arch/aarch64/Makefile.syscalls                |  52 -------
 criu/arch/aarch64/include/asm/types.h              |  25 +---
 criu/arch/aarch64/restorer.c                       |   2 +-
 criu/arch/aarch64/syscalls/syscall.def             |   1 -
 criu/arch/aarch64/vdso-pie.c                       |   2 +-
 criu/arch/arm/Makefile                             |   2 +
 criu/arch/arm/Makefile.syscalls                    |  52 -------
 criu/arch/arm/include/asm/types.h                  |  24 +---
 criu/arch/arm/restorer.c                           |   2 +-
 criu/arch/ppc64/Makefile                           |   2 +
 criu/arch/ppc64/Makefile.syscalls                  |  57 --------
 criu/arch/ppc64/include/asm/types.h                |  25 +---
 criu/arch/ppc64/restorer.c                         |   2 +-
 criu/arch/ppc64/vdso-pie.c                         |   2 +-
 criu/arch/x86/Makefile                             |   2 +
 criu/arch/x86/Makefile.syscalls                    | 158 ---------------------
 criu/arch/x86/crtools.c                            |   2 +-
 criu/arch/x86/include/asm/restorer.h               |   2 +-
 criu/arch/x86/include/asm/types.h                  |  49 +------
 criu/arch/x86/restorer.c                           |   2 +-
 criu/arch/x86/sigaction_compat.c                   |   2 +-
 criu/arch/x86/syscalls/syscall-common-x86-32.S     |  36 -----
 criu/arch/x86/syscalls/syscall-common-x86-64.S     |  21 ---
 criu/arch/x86/syscalls/syscall32.c                 |  85 -----------
 criu/arch/x86/syscalls/syscall_32.tbl              |  94 ------------
 criu/arch/x86/syscalls/syscall_64.tbl              | 105 --------------
 criu/arch/x86/vdso-pie.c                           |   2 +-
 criu/cr-restore.c                                  |   2 +-
 criu/fsnotify.c                                    |   2 +-
 criu/include/lock.h                                |   2 +-
 criu/kerndat.c                                     |   2 +-
 criu/parasite-syscall.c                            |   2 +-
 criu/pie/Makefile                                  |  13 +-
 criu/pie/Makefile.library                          |   2 +
 criu/pie/log-simple.c                              |   2 +-
 criu/pie/parasite-vdso.c                           |   2 +-
 criu/pie/parasite.c                                |   7 +-
 criu/pie/restorer.c                                |   7 +-
 criu/pie/util-fd.c                                 |   2 +-
 criu/pie/util.c                                    |   2 +-
 criu/shmem.c                                       |   2 +-
 criu/uffd.c                                        |   2 +-
 80 files changed, 446 insertions(+), 947 deletions(-)
 create mode 120000 compel/arch/aarch64/plugins/include/asm/linkage.h
 create mode 120000 compel/arch/aarch64/plugins/include/asm/prologue.h
 create mode 100644 compel/arch/aarch64/plugins/include/asm/syscall-types.h
 create mode 120000 compel/arch/aarch64/plugins/std/syscalls/Makefile.syscalls
 create mode 120000 compel/arch/aarch64/plugins/std/syscalls/gen-sys-exec-tbl.pl
 create mode 120000 compel/arch/aarch64/plugins/std/syscalls/gen-syscalls.pl
 rename {criu/arch/aarch64/include/asm => compel/arch/aarch64/plugins/std/syscalls}/syscall-aux.S (100%)
 rename {criu/arch/aarch64/include/asm => compel/arch/aarch64/plugins/std/syscalls}/syscall-aux.h (100%)
 rename {criu/arch/aarch64 => compel/arch/aarch64/plugins/std}/syscalls/syscall-common.S (100%)
 create mode 120000 compel/arch/aarch64/plugins/std/syscalls/syscall.def
 create mode 120000 compel/arch/arm/plugins/include/asm/linkage.h
 create mode 120000 compel/arch/arm/plugins/include/asm/prologue.h
 create mode 100644 compel/arch/arm/plugins/include/asm/syscall-types.h
 create mode 100644 compel/arch/arm/plugins/std/syscalls/Makefile.syscalls
 rename {criu/arch/scripts/arm => compel/arch/arm/plugins/std/syscalls}/gen-sys-exec-tbl.pl (100%)
 rename {criu/arch/scripts/arm => compel/arch/arm/plugins/std/syscalls}/gen-syscalls.pl (92%)
 rename {criu/arch/arm/include/asm => compel/arch/arm/plugins/std/syscalls}/syscall-aux.S (100%)
 rename {criu/arch/arm/include/asm => compel/arch/arm/plugins/std/syscalls}/syscall-aux.h (100%)
 rename {criu/arch/arm => compel/arch/arm/plugins/std}/syscalls/syscall-common.S (100%)
 rename {criu/arch/arm => compel/arch/arm/plugins/std}/syscalls/syscall.def (100%)
 create mode 120000 compel/arch/ppc64/plugins/include/asm/linkage.h
 create mode 120000 compel/arch/ppc64/plugins/include/asm/prologue.h
 create mode 100644 compel/arch/ppc64/plugins/include/asm/syscall-types.h
 create mode 100644 compel/arch/ppc64/plugins/std/syscalls/Makefile.syscalls
 rename {criu/arch/ppc64 => compel/arch/ppc64/plugins/std}/syscalls/syscall-common-ppc64.S (100%)
 rename {criu/arch/ppc64 => compel/arch/ppc64/plugins/std}/syscalls/syscall-ppc64.tbl (100%)
 create mode 100644 compel/arch/x86/plugins/std/syscalls/Makefile.syscalls
 create mode 100644 compel/plugins/include/uapi/std/asm/.gitignore
 delete mode 100644 criu/arch/aarch64/Makefile.syscalls
 delete mode 120000 criu/arch/aarch64/syscalls/syscall.def
 delete mode 100644 criu/arch/arm/Makefile.syscalls
 delete mode 100644 criu/arch/ppc64/Makefile.syscalls
 delete mode 100644 criu/arch/x86/Makefile.syscalls
 delete mode 100644 criu/arch/x86/syscalls/syscall-common-x86-32.S
 delete mode 100644 criu/arch/x86/syscalls/syscall-common-x86-64.S
 delete mode 100644 criu/arch/x86/syscalls/syscall32.c
 delete mode 100644 criu/arch/x86/syscalls/syscall_32.tbl
 delete mode 100644 criu/arch/x86/syscalls/syscall_64.tbl

diff --git a/Makefile b/Makefile
index 2661dd6923f0..af0b3ca760ab 100644
--- a/Makefile
+++ b/Makefile
@@ -203,9 +203,9 @@ $(SOCCR_A): |soccr/built-in.o
 #
 # But note that we're already included
 # the nmk so we can reuse it there.
-criu/%: images/built-in.o compel/compel-host $(VERSION_HEADER) .FORCE
+criu/%: images/built-in.o compel/plugins/std.built-in.o compel/compel-host $(SOCCR_A) $(VERSION_HEADER) .FORCE
 	$(Q) $(MAKE) $(build)=criu $@
-criu: images/built-in.o compel/compel-host $(SOCCR_A) $(VERSION_HEADER)
+criu: images/built-in.o compel/plugins/std.built-in.o compel/compel-host $(SOCCR_A) $(VERSION_HEADER)
 	$(Q) $(MAKE) $(build)=criu all
 .PHONY: criu
 
@@ -235,6 +235,7 @@ clean: subclean
 	$(Q) $(MAKE) $(build)=criu $@
 	$(Q) $(MAKE) $(build)=compel $@
 	$(Q) $(MAKE) $(build)=soccr $@
+	$(Q) $(MAKE) $(build)=compel/plugins $@
 .PHONY: clean
 
 # mrproper depends on clean in nmk
@@ -243,6 +244,7 @@ mrproper: subclean
 	$(Q) $(MAKE) $(build)=criu $@
 	$(Q) $(MAKE) $(build)=compel $@
 	$(Q) $(MAKE) $(build)=soccr $@
+	$(Q) $(MAKE) $(build)=compel/plugins $@
 	$(Q) $(RM) $(VERSION_HEADER)
 	$(Q) $(RM) $(COMPEL_VERSION_HEADER)
 	$(Q) $(RM) cscope.*
diff --git a/compel/arch/aarch64/plugins/include/asm/linkage.h b/compel/arch/aarch64/plugins/include/asm/linkage.h
new file mode 120000
index 000000000000..efec669844cf
--- /dev/null
+++ b/compel/arch/aarch64/plugins/include/asm/linkage.h
@@ -0,0 +1 @@
+../../../../../../criu/arch/aarch64/include/asm/linkage.h
\ No newline at end of file
diff --git a/compel/arch/aarch64/plugins/include/asm/prologue.h b/compel/arch/aarch64/plugins/include/asm/prologue.h
new file mode 120000
index 000000000000..30e874ba0941
--- /dev/null
+++ b/compel/arch/aarch64/plugins/include/asm/prologue.h
@@ -0,0 +1 @@
+../../../../x86/plugins/include/asm/prologue.h
\ No newline at end of file
diff --git a/compel/arch/aarch64/plugins/include/asm/syscall-types.h b/compel/arch/aarch64/plugins/include/asm/syscall-types.h
new file mode 100644
index 000000000000..e8eeb2e39aa1
--- /dev/null
+++ b/compel/arch/aarch64/plugins/include/asm/syscall-types.h
@@ -0,0 +1,26 @@
+#ifndef COMPEL_ARCH_SYSCALL_TYPES_H__
+#define COMPEL_ARCH_SYSCALL_TYPES_H__
+
+typedef void rt_signalfn_t(int, siginfo_t *, void *);
+typedef rt_signalfn_t *rt_sighandler_t;
+
+typedef void rt_restorefn_t(void);
+typedef rt_restorefn_t *rt_sigrestore_t;
+
+#define _KNSIG		64
+#define _NSIG_BPW	64
+
+#define _KNSIG_WORDS	(_KNSIG / _NSIG_BPW)
+
+typedef struct {
+	unsigned long sig[_KNSIG_WORDS];
+} k_rtsigset_t;
+
+typedef struct {
+	rt_sighandler_t	rt_sa_handler;
+	unsigned long	rt_sa_flags;
+	rt_sigrestore_t	rt_sa_restorer;
+	k_rtsigset_t	rt_sa_mask;
+} rt_sigaction_t;
+
+#endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */
diff --git a/compel/arch/aarch64/plugins/std/syscalls/Makefile.syscalls b/compel/arch/aarch64/plugins/std/syscalls/Makefile.syscalls
new file mode 120000
index 000000000000..eba4d986c977
--- /dev/null
+++ b/compel/arch/aarch64/plugins/std/syscalls/Makefile.syscalls
@@ -0,0 +1 @@
+../../../../arm/plugins/std/syscalls/Makefile.syscalls
\ No newline at end of file
diff --git a/compel/arch/aarch64/plugins/std/syscalls/gen-sys-exec-tbl.pl b/compel/arch/aarch64/plugins/std/syscalls/gen-sys-exec-tbl.pl
new file mode 120000
index 000000000000..8d7e897aea54
--- /dev/null
+++ b/compel/arch/aarch64/plugins/std/syscalls/gen-sys-exec-tbl.pl
@@ -0,0 +1 @@
+../../../../arm/plugins/std/syscalls/gen-sys-exec-tbl.pl
\ No newline at end of file
diff --git a/compel/arch/aarch64/plugins/std/syscalls/gen-syscalls.pl b/compel/arch/aarch64/plugins/std/syscalls/gen-syscalls.pl
new file mode 120000
index 000000000000..5c9563611298
--- /dev/null
+++ b/compel/arch/aarch64/plugins/std/syscalls/gen-syscalls.pl
@@ -0,0 +1 @@
+../../../../arm/plugins/std/syscalls/gen-syscalls.pl
\ No newline at end of file
diff --git a/criu/arch/aarch64/include/asm/syscall-aux.S b/compel/arch/aarch64/plugins/std/syscalls/syscall-aux.S
similarity index 100%
rename from criu/arch/aarch64/include/asm/syscall-aux.S
rename to compel/arch/aarch64/plugins/std/syscalls/syscall-aux.S
diff --git a/criu/arch/aarch64/include/asm/syscall-aux.h b/compel/arch/aarch64/plugins/std/syscalls/syscall-aux.h
similarity index 100%
rename from criu/arch/aarch64/include/asm/syscall-aux.h
rename to compel/arch/aarch64/plugins/std/syscalls/syscall-aux.h
diff --git a/criu/arch/aarch64/syscalls/syscall-common.S b/compel/arch/aarch64/plugins/std/syscalls/syscall-common.S
similarity index 100%
rename from criu/arch/aarch64/syscalls/syscall-common.S
rename to compel/arch/aarch64/plugins/std/syscalls/syscall-common.S
diff --git a/compel/arch/aarch64/plugins/std/syscalls/syscall.def b/compel/arch/aarch64/plugins/std/syscalls/syscall.def
new file mode 120000
index 000000000000..ebecde3cb8f5
--- /dev/null
+++ b/compel/arch/aarch64/plugins/std/syscalls/syscall.def
@@ -0,0 +1 @@
+../../../../arm/plugins/std/syscalls/syscall.def
\ No newline at end of file
diff --git a/compel/arch/arm/plugins/include/asm/linkage.h b/compel/arch/arm/plugins/include/asm/linkage.h
new file mode 120000
index 000000000000..9c421ec776ab
--- /dev/null
+++ b/compel/arch/arm/plugins/include/asm/linkage.h
@@ -0,0 +1 @@
+../../../../../../criu/arch/arm/include/asm/linkage.h
\ No newline at end of file
diff --git a/compel/arch/arm/plugins/include/asm/prologue.h b/compel/arch/arm/plugins/include/asm/prologue.h
new file mode 120000
index 000000000000..30e874ba0941
--- /dev/null
+++ b/compel/arch/arm/plugins/include/asm/prologue.h
@@ -0,0 +1 @@
+../../../../x86/plugins/include/asm/prologue.h
\ No newline at end of file
diff --git a/compel/arch/arm/plugins/include/asm/syscall-types.h b/compel/arch/arm/plugins/include/asm/syscall-types.h
new file mode 100644
index 000000000000..9e0e98b9f817
--- /dev/null
+++ b/compel/arch/arm/plugins/include/asm/syscall-types.h
@@ -0,0 +1,26 @@
+#ifndef COMPEL_ARCH_SYSCALL_TYPES_H__
+#define COMPEL_ARCH_SYSCALL_TYPES_H__
+
+typedef void rt_signalfn_t(int, siginfo_t *, void *);
+typedef rt_signalfn_t *rt_sighandler_t;
+
+typedef void rt_restorefn_t(void);
+typedef rt_restorefn_t *rt_sigrestore_t;
+
+#define _KNSIG		64
+#define _NSIG_BPW	32
+
+#define _KNSIG_WORDS	(_KNSIG / _NSIG_BPW)
+
+typedef struct {
+	unsigned long sig[_KNSIG_WORDS];
+} k_rtsigset_t;
+
+typedef struct {
+	rt_sighandler_t	rt_sa_handler;
+	unsigned long	rt_sa_flags;
+	rt_sigrestore_t	rt_sa_restorer;
+	k_rtsigset_t	rt_sa_mask;
+} rt_sigaction_t;
+
+#endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */
diff --git a/compel/arch/arm/plugins/std/syscalls/Makefile.syscalls b/compel/arch/arm/plugins/std/syscalls/Makefile.syscalls
new file mode 100644
index 000000000000..d5da585ea167
--- /dev/null
+++ b/compel/arch/arm/plugins/std/syscalls/Makefile.syscalls
@@ -0,0 +1,59 @@
+ccflags-y		+= -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
+asflags-y		+= -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
+
+sys-types		:= $(obj)/include/uapi/std/syscall-types.h
+sys-codes		:= $(obj)/include/uapi/std/syscall-codes.h
+sys-proto		:= $(obj)/include/uapi/std/syscall.h
+
+sys-def			:= $(PLUGIN_ARCH_DIR)/std/syscalls/syscall.def
+sys-asm-common-name	:= std/syscalls/syscall-common.S
+sys-asm-common		:= $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
+sys-asm-types		:= $(obj)/include/uapi/std/asm/syscall-types.h
+sys-exec-tbl		 = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl.c
+
+sys-gen			:= $(PLUGIN_ARCH_DIR)/std/syscalls/gen-syscalls.pl
+sys-gen-tbl		:= $(PLUGIN_ARCH_DIR)/std/syscalls/gen-sys-exec-tbl.pl
+
+sys-asm			:= ./$(PLUGIN_ARCH_DIR)/std/syscalls/syscalls.S
+std-obj-y		+= $(sys-asm:.S=).o
+
+ifeq ($(ARCH),arm)
+arch_bits		:= 32
+else
+arch_bits		:= 64
+endif
+
+sys-exec-tbl		:= sys-exec-tbl.c
+
+$(sys-asm) $(sys-types) $(sys-codes) $(sys-proto): $(sys-gen) $(sys-def) $(sys-asm-common)
+	$(E) "  GEN     " $@
+	$(Q) perl				\
+		$(sys-gen)			\
+		$(sys-def)			\
+		$(sys-codes)			\
+		$(sys-proto)			\
+		$(sys-asm)			\
+		$(sys-asm-common-name)		\
+		$(sys-types)			\
+		$(arch_bits)
+
+$(sys-asm:.S=).o: $(sys-asm)
+
+$(sys-exec-tbl): $(sys-gen-tbl) $(sys-def)
+	$(E) "  GEN     " $@
+	$(Q) perl				\
+		$(sys-gen-tbl)			\
+		$(sys-def)			\
+		$(sys-exec-tbl)			\
+		$(arch_bits)
+
+$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
+	$(call msg-gen, $@)
+	$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
+	$(Q) ln -s ../../../../../$(PLUGIN_ARCH_DIR)/std/syscalls/syscall-aux.S $(obj)/include/uapi/std/syscall-aux.S
+	$(Q) ln -s ../../../../../$(PLUGIN_ARCH_DIR)/std/syscalls/syscall-aux.h $(obj)/include/uapi/std/syscall-aux.h
+
+std-headers-deps	+= $(sys-types) $(sys-codes) $(sys-proto) $(sys-asm-types)
+mrproper-y		+= $(std-headers-deps)
+mrproper-y		+= $(obj)/include/uapi/std/syscall-aux.S
+mrproper-y		+= $(obj)/include/uapi/std/syscall-aux.h
diff --git a/criu/arch/scripts/arm/gen-sys-exec-tbl.pl b/compel/arch/arm/plugins/std/syscalls/gen-sys-exec-tbl.pl
similarity index 100%
rename from criu/arch/scripts/arm/gen-sys-exec-tbl.pl
rename to compel/arch/arm/plugins/std/syscalls/gen-sys-exec-tbl.pl
diff --git a/criu/arch/scripts/arm/gen-syscalls.pl b/compel/arch/arm/plugins/std/syscalls/gen-syscalls.pl
similarity index 92%
rename from criu/arch/scripts/arm/gen-syscalls.pl
rename to compel/arch/arm/plugins/std/syscalls/gen-syscalls.pl
index ac524236d8a0..c683e4998b1a 100755
--- a/criu/arch/scripts/arm/gen-syscalls.pl
+++ b/compel/arch/arm/plugins/std/syscalls/gen-syscalls.pl
@@ -17,9 +17,9 @@ $prototypes    =~ s/.*include\///g;
 my $bits       = $ARGV[6];
 
 my $codesdef   = $codes;
-$codesdef      =~ tr/.-/_/;
+$codesdef      =~ tr/.\-\//_/;
 my $protosdef  = $protos;
-$protosdef     =~ tr/.-/_/;
+$protosdef     =~ tr/.\-\//_/;
 my $code       = "code$bits";
 my $need_aux   = 0;
 
@@ -91,8 +91,8 @@ for (<IN>) {
 }
 
 if ($need_aux == 1) {
-	print ASMOUT   "#include \"asm/syscall-aux.S\"\n";
-	print CODESOUT "#include \"asm/syscall-aux.h\"\n";
+	print ASMOUT   "#include \"uapi/std/syscall-aux.S\"\n";
+	print CODESOUT "#include \"uapi/std/syscall-aux.h\"\n";
 }
 
 print CODESOUT  "#endif /* $codesdef */";
diff --git a/criu/arch/arm/include/asm/syscall-aux.S b/compel/arch/arm/plugins/std/syscalls/syscall-aux.S
similarity index 100%
rename from criu/arch/arm/include/asm/syscall-aux.S
rename to compel/arch/arm/plugins/std/syscalls/syscall-aux.S
diff --git a/criu/arch/arm/include/asm/syscall-aux.h b/compel/arch/arm/plugins/std/syscalls/syscall-aux.h
similarity index 100%
rename from criu/arch/arm/include/asm/syscall-aux.h
rename to compel/arch/arm/plugins/std/syscalls/syscall-aux.h
diff --git a/criu/arch/arm/syscalls/syscall-common.S b/compel/arch/arm/plugins/std/syscalls/syscall-common.S
similarity index 100%
rename from criu/arch/arm/syscalls/syscall-common.S
rename to compel/arch/arm/plugins/std/syscalls/syscall-common.S
diff --git a/criu/arch/arm/syscalls/syscall.def b/compel/arch/arm/plugins/std/syscalls/syscall.def
similarity index 100%
rename from criu/arch/arm/syscalls/syscall.def
rename to compel/arch/arm/plugins/std/syscalls/syscall.def
diff --git a/compel/arch/ppc64/plugins/include/asm/linkage.h b/compel/arch/ppc64/plugins/include/asm/linkage.h
new file mode 120000
index 000000000000..da0a6b285afa
--- /dev/null
+++ b/compel/arch/ppc64/plugins/include/asm/linkage.h
@@ -0,0 +1 @@
+../../../../../../criu/arch/ppc64/include/asm/linkage.h
\ No newline at end of file
diff --git a/compel/arch/ppc64/plugins/include/asm/prologue.h b/compel/arch/ppc64/plugins/include/asm/prologue.h
new file mode 120000
index 000000000000..30e874ba0941
--- /dev/null
+++ b/compel/arch/ppc64/plugins/include/asm/prologue.h
@@ -0,0 +1 @@
+../../../../x86/plugins/include/asm/prologue.h
\ No newline at end of file
diff --git a/compel/arch/ppc64/plugins/include/asm/syscall-types.h b/compel/arch/ppc64/plugins/include/asm/syscall-types.h
new file mode 100644
index 000000000000..30580c530480
--- /dev/null
+++ b/compel/arch/ppc64/plugins/include/asm/syscall-types.h
@@ -0,0 +1,26 @@
+#ifndef COMPEL_ARCH_SYSCALL_TYPES_H__
+#define COMPEL_ARCH_SYSCALL_TYPES_H__
+
+typedef void rt_signalfn_t(int, siginfo_t *, void *);
+typedef rt_signalfn_t *rt_sighandler_t;
+
+typedef void rt_restorefn_t(void);
+typedef rt_restorefn_t *rt_sigrestore_t;
+
+#define _KNSIG		64
+#define _NSIG_BPW	64
+
+#define _KNSIG_WORDS	(_KNSIG / _NSIG_BPW)
+
+typedef struct {
+	unsigned long	sig[_KNSIG_WORDS];
+} k_rtsigset_t;
+
+typedef struct {
+	rt_sighandler_t	rt_sa_handler;
+	unsigned long	rt_sa_flags;
+	rt_sigrestore_t	rt_sa_restorer;
+	k_rtsigset_t	rt_sa_mask;
+} rt_sigaction_t;
+
+#endif /* COMPEL_ARCH_SYSCALL_TYPES_H__ */
diff --git a/compel/arch/ppc64/plugins/std/syscalls/Makefile.syscalls b/compel/arch/ppc64/plugins/std/syscalls/Makefile.syscalls
new file mode 100644
index 000000000000..e3584cddc9c3
--- /dev/null
+++ b/compel/arch/ppc64/plugins/std/syscalls/Makefile.syscalls
@@ -0,0 +1,57 @@
+ccflags-y		+= -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
+asflags-y		+= -iquote $(PLUGIN_ARCH_DIR)/std/syscalls/
+
+sys-types		:= $(obj)/include/uapi/std/syscall-types.h
+sys-codes		:= $(obj)/include/uapi/std/syscall-codes.h
+sys-proto		:= $(obj)/include/uapi/std/syscall.h
+
+sys-def			:= $(PLUGIN_ARCH_DIR)/std/syscalls/syscall-ppc64.tbl
+sys-asm-common-name	:= std/syscalls/syscall-common-ppc64.S
+sys-asm-common		:= $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
+sys-asm-types		:= $(obj)/include/uapi/std/asm/syscall-types.h
+sys-exec-tbl		 = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl.c
+
+sys-asm			:= ./$(PLUGIN_ARCH_DIR)/std/syscalls/syscalls.S
+std-obj-y		+= $(sys-asm:.S=).o
+
+$(sys-codes): $(sys-def)
+	$(E) "  GEN     " $@
+	$(Q) echo "/* Autogenerated, don't edit */"							>  $@
+	$(Q) echo "#ifndef __ASM_CR_SYSCALL_CODES_H__"							>> $@
+	$(Q) echo "#define __ASM_CR_SYSCALL_CODES_H__"							>> $@
+	$(Q) cat $< | awk '/^__NR/{SYSN=$$1; sub("^__NR", "SYS", SYSN);'\
+	'print "\n#ifndef ", $$1, "\n#define", $$1, $$2, "\n#endif";'\
+	'print "#ifndef ", SYSN, "\n#define ", SYSN, $$1, "\n#endif"}'					>> $@
+	$(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */"						>> $@
+
+$(sys-proto): $(sys-def)
+	$(E) "  GEN     " $@
+	$(Q) echo "/* Autogenerated, don't edit */"							>  $@
+	$(Q) echo "#ifndef __ASM_CR_SYSCALL_PROTO_H__"							>> $@
+	$(Q) echo "#define __ASM_CR_SYSCALL_PROTO_H__"							>> $@
+	$(Q) echo "#include \"uapi/std/syscall-codes.h\""						>> $@
+	$(Q) echo "#include \"uapi/std/syscall-types.h\""						>> $@
+	$(Q) cat $< | awk  '/^__NR/{print "extern long", $$3, substr($$0, index($$0,$$4)), ";"}'	>> $@
+	$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */"						>> $@
+
+$(sys-asm): $(sys-def) $(sys-asm-common) $(sys-codes) $(sys-proto)
+	$(E) "  GEN     " $@
+	$(Q) echo "/* Autogenerated, don't edit */"							>  $@
+	$(Q) echo "#include \"uapi/std/syscall-codes.h\""						>> $@
+	$(Q) echo "#include \"$(sys-asm-common-name)\""							>> $@
+	$(Q) cat $< | awk '/^__NR/{print "SYSCALL(", $$3, ",", $$2, ")"}'				>> $@
+
+$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto)
+	$(E) "  GEN     " $@
+	$(Q) echo "/* Autogenerated, don't edit */"							>  $@
+	$(Q) echo "static struct syscall_exec_desc sc_exec_table[] = {"					>> $@
+	$(Q) cat $< | awk '/^__NR/{print "SYSCALL(", substr($$3, 5), ",", $$2, ")"}'			>> $@
+	$(Q) echo "	{ }, /* terminator */"								>> $@
+	$(Q) echo "};"											>> $@
+
+$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
+	$(call msg-gen, $@)
+	$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
+
+std-headers-deps	+= $(sys-types) $(sys-codes) $(sys-proto) $(sys-exec-tbl)
+mrproper-y		+= $(std-headers-deps)
diff --git a/criu/arch/ppc64/syscalls/syscall-common-ppc64.S b/compel/arch/ppc64/plugins/std/syscalls/syscall-common-ppc64.S
similarity index 100%
rename from criu/arch/ppc64/syscalls/syscall-common-ppc64.S
rename to compel/arch/ppc64/plugins/std/syscalls/syscall-common-ppc64.S
diff --git a/criu/arch/ppc64/syscalls/syscall-ppc64.tbl b/compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl
similarity index 100%
rename from criu/arch/ppc64/syscalls/syscall-ppc64.tbl
rename to compel/arch/ppc64/plugins/std/syscalls/syscall-ppc64.tbl
diff --git a/compel/arch/x86/plugins/include/asm/syscall-types.h b/compel/arch/x86/plugins/include/asm/syscall-types.h
index 744809d07894..30a15f150608 100644
--- a/compel/arch/x86/plugins/include/asm/syscall-types.h
+++ b/compel/arch/x86/plugins/include/asm/syscall-types.h
@@ -8,13 +8,13 @@ typedef rt_signalfn_t *rt_sighandler_t;
 typedef void rt_restorefn_t(void);
 typedef rt_restorefn_t *rt_sigrestore_t;
 
-#define _KNSIG           64
+#define _KNSIG          64
 # define _NSIG_BPW      64
 
 #define _KNSIG_WORDS     (_KNSIG / _NSIG_BPW)
 
 typedef struct {
-	u64 sig[_KNSIG_WORDS];
+	unsigned long	sig[_KNSIG_WORDS];
 } k_rtsigset_t;
 
 typedef struct {
@@ -30,9 +30,9 @@ typedef struct {
  * with unaligned rt_sa_mask.
  */
 typedef struct __attribute__((packed)) {
-	u32	rt_sa_handler;
-	u32	rt_sa_flags;
-	u32	rt_sa_restorer;
+	unsigned int	rt_sa_handler;
+	unsigned int	rt_sa_flags;
+	unsigned int	rt_sa_restorer;
 	k_rtsigset_t	rt_sa_mask;
 } rt_sigaction_t_compat;
 
diff --git a/compel/arch/x86/plugins/std/syscalls/Makefile.syscalls b/compel/arch/x86/plugins/std/syscalls/Makefile.syscalls
new file mode 100644
index 000000000000..040d1e3b6ff5
--- /dev/null
+++ b/compel/arch/x86/plugins/std/syscalls/Makefile.syscalls
@@ -0,0 +1,122 @@
+std-obj-y		+= ./$(PLUGIN_ARCH_DIR)/std/syscalls-64.o
+
+sys-proto-types		:= $(obj)/include/uapi/std/syscall-types.h
+sys-proto-generic	:= $(obj)/include/uapi/std/syscall.h
+sys-codes-generic	:= $(obj)/include/uapi/std/syscall-codes.h
+sys-codes		 = $(obj)/include/uapi/std/syscall-codes-$(1).h
+sys-proto		 = $(obj)/include/uapi/std/syscall-$(1).h
+sys-def			 = $(PLUGIN_ARCH_DIR)/std/syscalls/syscall_$(1).tbl
+sys-asm			 = $(PLUGIN_ARCH_DIR)/std/syscalls-$(1).S
+sys-asm-common-name	 = std/syscalls/syscall-common-x86-$(1).S
+sys-asm-common		 = $(PLUGIN_ARCH_DIR)/$(sys-asm-common-name)
+sys-asm-types		:= $(obj)/include/uapi/std/asm/syscall-types.h
+sys-exec-tbl		 = $(PLUGIN_ARCH_DIR)/std/sys-exec-tbl-$(1).c
+
+sys-bits		:= 64
+
+AV			:= $$$$
+
+define gen-rule-sys-codes
+$(sys-codes): $(sys-def) $(sys-proto-types)
+	$(call msg-gen, $$@)
+	$(Q) echo "/* Autogenerated, don't edit */"					>  $$@
+	$(Q) echo "#ifndef ASM_SYSCALL_CODES_H_$(1)__"					>> $$@
+	$(Q) echo "#define ASM_SYSCALL_CODES_H_$(1)__"					>> $$@
+	$(Q) cat $$< | awk '/^__NR/{SYSN=$(AV)1;					\
+		sub("^__NR", "SYS", SYSN);						\
+		print "\n#ifndef ", $(AV)1;						\
+		print "#define", $(AV)1, $(AV)2;					\
+		print "#endif";								\
+		print "\n#ifndef ", SYSN;						\
+		print "#define ", SYSN, $(AV)1;						\
+		print "#endif";}'							>> $$@
+	$(Q) echo "#endif /* ASM_SYSCALL_CODES_H_$(1)__ */"				>> $$@
+endef
+
+define gen-rule-sys-proto
+$(sys-proto): $(sys-def) $(sys-proto-types)
+	$(call msg-gen, $$@)
+	$(Q) echo "/* Autogenerated, don't edit */"					>  $$@
+	$(Q) echo "#ifndef ASM_SYSCALL_PROTO_H_$(1)__"					>> $$@
+	$(Q) echo "#define ASM_SYSCALL_PROTO_H_$(1)__"					>> $$@
+	$(Q) echo '#include "uapi/std/syscall-codes-$(1).h"'				>> $$@
+	$(Q) echo '#include "uapi/std/syscall-types.h"'					>> $$@
+ifeq ($(1),32)
+	$(Q) echo '#include "asm/syscall32.h"'						>> $$@
+endif
+	$(Q) cat $$< | awk '/^__NR/{print "extern long", $(AV)3,			\
+			substr($(AV)0, index($(AV)0,$(AV)4)), ";"}'			>> $$@
+	$(Q) echo "#endif /* ASM_SYSCALL_PROTO_H_$(1)__ */"				>> $$@
+endef
+
+define gen-rule-sys-asm
+$(sys-asm): $(sys-def) $(sys-asm-common) $(sys-codes) $(sys-proto) $(sys-proto-types)
+	$(call msg-gen, $$@)
+	$(Q) echo "/* Autogenerated, don't edit */"					>  $$@
+	$(Q) echo '#include "uapi/std/syscall-codes-$(1).h"'				>> $$@
+	$(Q) echo '#include "$(sys-asm-common-name)"'					>> $$@
+	$(Q) cat $$< | awk '/^__NR/{print "SYSCALL(", $(AV)3, ",", $(AV)2, ")"}'	>> $$@
+endef
+
+define gen-rule-sys-exec-tbl
+$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto) $(sys-proto-generic) $(sys-proto-types)
+	$(call msg-gen, $$@)
+	$(Q) echo "/* Autogenerated, don't edit */"					>  $$@
+	$(Q) cat $$< | awk '/^__NR/{print						\
+		"SYSCALL(", substr($(AV)3, 5), ",", $(AV)2, ")"}'			>> $$@
+endef
+
+$(sys-codes-generic): $(PLUGIN_ARCH_DIR)/std/syscalls/syscall_32.tbl $(sys-proto-types)
+	$(call msg-gen, $@)
+	$(Q) echo "/* Autogenerated, don't edit */"			>  $@
+	$(Q) echo "#ifndef __ASM_CR_SYSCALL_CODES_H__"			>> $@
+	$(Q) echo "#define __ASM_CR_SYSCALL_CODES_H__"			>> $@
+	$(Q) echo '#include "uapi/std/syscall-codes-64.h"'		>> $@
+	$(Q) cat $< | awk '/^__NR/{NR32=$$1;				\
+		sub("^__NR", "__NR32", NR32);				\
+		print "\n#ifndef ", NR32;				\
+		print "#define ", NR32, $$2;				\
+		print "#endif";}'					>> $@
+	$(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */"		>> $@
+mrproper-y += $(sys-codes-generic)
+
+$(sys-proto-generic): $(strip $(call map,sys-proto,$(sys-bits))) $(sys-proto-types)
+	$(call msg-gen, $@)
+	$(Q) echo "/* Autogenerated, don't edit */"			>  $@
+	$(Q) echo "#ifndef __ASM_CR_SYSCALL_PROTO_H__"			>> $@
+	$(Q) echo "#define __ASM_CR_SYSCALL_PROTO_H__"			>> $@
+	$(Q) echo ""							>> $@
+	$(Q) echo "#ifdef CONFIG_X86_32"				>> $@
+	$(Q) echo '#include "uapi/std/syscall-32.h"'			>> $@
+	$(Q) echo "#else"						>> $@
+	$(Q) echo '#include "uapi/std/syscall-64.h"'			>> $@
+	$(Q) echo "#endif /* CONFIG_X86_32 */"				>> $@
+	$(Q) echo ""							>> $@
+	$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */"		>> $@
+mrproper-y += $(sys-proto-generic)
+
+define gen-rule-sys-exec-tbl
+$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto) $(sys-proto-generic)
+	$(call msg-gen, $$@)
+	$(Q) echo "/* Autogenerated, don't edit */"			>  $$@
+	$(Q) cat $$< | awk '/^__NR/{print				\
+		"SYSCALL(", substr($(AV)3, 5), ",", $(AV)2, ")"}'	>> $$@
+endef
+
+$(eval $(call map,gen-rule-sys-codes,$(sys-bits)))
+$(eval $(call map,gen-rule-sys-proto,$(sys-bits)))
+$(eval $(call map,gen-rule-sys-asm,$(sys-bits)))
+$(eval $(call map,gen-rule-sys-exec-tbl,$(sys-bits)))
+
+$(sys-asm-types): $(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h
+	$(call msg-gen, $@)
+	$(Q) ln -s ../../../../../../$(PLUGIN_ARCH_DIR)/include/asm/syscall-types.h $(sys-asm-types)
+
+std-headers-deps	+= $(call sys-codes,$(sys-bits))
+std-headers-deps	+= $(call sys-proto,$(sys-bits))
+std-headers-deps	+= $(call sys-asm,$(sys-bits))
+std-headers-deps	+= $(call sys-exec-tbl,$(sys-bits))
+std-headers-deps	+= $(sys-codes-generic)
+std-headers-deps	+= $(sys-proto-generic)
+std-headers-deps	+= $(sys-asm-types)
+mrproper-y		+= $(std-headers-deps)
diff --git a/compel/plugins/Makefile b/compel/plugins/Makefile
index a30597ad80c1..9a54642be667 100644
--- a/compel/plugins/Makefile
+++ b/compel/plugins/Makefile
@@ -1,6 +1,6 @@
 .PHONY: .FORCE
 
-ARCH_DIR		:= compel/arch/$(ARCH)/plugins
+PLUGIN_ARCH_DIR		:= compel/arch/$(ARCH)/plugins
 
 #
 # CFLAGS, ASFLAGS, LDFLAGS
@@ -15,12 +15,12 @@ asflags-y		+= -iquote $(obj)/include
 asflags-y		+= -iquote $(obj)/include/uapi
 
 # Arch compel/plugins includes
-ccflags-y		+= -iquote $(SRC_DIR)/$(ARCH_DIR)/include
-asflags-y		+= -iquote $(SRC_DIR)/$(ARCH_DIR)/include
-asflags-y		+= -iquote $(SRC_DIR)/$(ARCH_DIR)
+ccflags-y		+= -iquote $(SRC_DIR)/$(PLUGIN_ARCH_DIR)/include
+asflags-y		+= -iquote $(SRC_DIR)/$(PLUGIN_ARCH_DIR)/include
+asflags-y		+= -iquote $(SRC_DIR)/$(PLUGIN_ARCH_DIR)
 
 # General flags for assembly
-asflags-y		+= -Wstrict-prototypes -Wa,--noexecstack
+asflags-y		+= -fpie -Wstrict-prototypes -Wa,--noexecstack
 asflags-y		+= -D__ASSEMBLY__ -nostdlib -fomit-frame-pointer
 
 #
@@ -38,111 +38,24 @@ shmem-obj-y		+= shmem/shmem.o
 target			+= std
 std-obj-y		+= std/std.o
 std-obj-y		+= std/string.o
-std-obj-y		+= ./$(ARCH_DIR)/std/syscalls-64.o
-std-obj-y		+= ./$(ARCH_DIR)/std/call32.o
-std-obj-y		+= ./$(ARCH_DIR)/std/prologue.o
 
-sys-proto-generic	:= $(obj)/include/uapi/std/syscall.h
-sys-codes-generic	:= $(obj)/include/uapi/std/syscall-codes.h
-sys-codes		 = $(obj)/include/uapi/std/syscall-codes-$(1).h
-sys-proto		 = $(obj)/include/uapi/std/syscall-$(1).h
-sys-def			 = $(ARCH_DIR)/std/syscalls/syscall_$(1).tbl
-sys-asm			 = $(ARCH_DIR)/std/syscalls-$(1).S
-sys-asm-common-name	 = std/syscalls/syscall-common-x86-$(1).S
-sys-asm-common		 = $(ARCH_DIR)/$(sys-asm-common-name)
+#ARCH := arm
+#PLUGIN_ARCH_DIR := compel/arch/$(ARCH)/plugins
 
-sys-bits		:= 64
+include ./$(PLUGIN_ARCH_DIR)/std/syscalls/Makefile.syscalls
 
-AV			:= $$$$
-
-define gen-rule-sys-codes
-$(sys-codes): $(sys-def)
-	$(call msg-gen, $$@)
-	$(Q) echo "/* Autogenerated, don't edit */"					>  $$@
-	$(Q) echo "#ifndef ASM_SYSCALL_CODES_H_$(1)__"					>> $$@
-	$(Q) echo "#define ASM_SYSCALL_CODES_H_$(1)__"					>> $$@
-	$(Q) cat $$< | awk '/^__NR/{SYSN=$(AV)1;					\
-		sub("^__NR", "SYS", SYSN);						\
-		print "\n#ifndef ", $(AV)1;						\
-		print "#define", $(AV)1, $(AV)2;					\
-		print "#endif";								\
-		print "\n#ifndef ", SYSN;						\
-		print "#define ", SYSN, $(AV)1;						\
-		print "#endif";}'							>> $$@
-	$(Q) echo "#endif /* ASM_SYSCALL_CODES_H_$(1)__ */"				>> $$@
-endef
-
-define gen-rule-sys-proto
-$(sys-proto): $(sys-def)
-	$(call msg-gen, $$@)
-	$(Q) echo "/* Autogenerated, don't edit */"					>  $$@
-	$(Q) echo "#ifndef ASM_SYSCALL_PROTO_H_$(1)__"					>> $$@
-	$(Q) echo "#define ASM_SYSCALL_PROTO_H_$(1)__"					>> $$@
-	$(Q) echo '#include "std/syscall-codes-$(1).h"'					>> $$@
-	$(Q) echo '#include "syscall-types.h"'						>> $$@
-ifeq ($(1),32)
-	$(Q) echo '#include "asm/syscall32.h"'						>> $$@
-endif
-	$(Q) cat $$< | awk '/^__NR/{print "extern long", $(AV)3,			\
-			substr($(AV)0, index($(AV)0,$(AV)4)), ";"}'			>> $$@
-	$(Q) echo "#endif /* ASM_SYSCALL_PROTO_H_$(1)__ */"				>> $$@
+define syscall-priority
+$(addprefix $(obj)/,$($(1):%.o=%.d)): | $($(2))
+$(addprefix $(obj)/,$($(1):%.o=%.i)): | $($(2))
+$(addprefix $(obj)/,$($(1):%.o=%.s)): | $($(2))
+$(addprefix $(obj)/,$($(1))): | $($(2))
 endef
 
-define gen-rule-sys-asm
-$(sys-asm): $(sys-def) $(sys-asm-common) $(sys-codes) $(sys-proto)
-	$(call msg-gen, $$@)
-	$(Q) echo "/* Autogenerated, don't edit */"					>  $$@
-	$(Q) echo '#include "std/syscall-codes-$(1).h"'					>> $$@
-	$(Q) echo '#include "$(sys-asm-common-name)"'					>> $$@
-	$(Q) cat $$< | awk '/^__NR/{print "SYSCALL(", $(AV)3, ",", $(AV)2, ")"}'	>> $$@
-endef
-
-define gen-rule-sys-exec-tbl
-$(sys-exec-tbl): $(sys-def) $(sys-codes) $(sys-proto) $(sys-proto-generic)
-	$(call msg-gen, $$@)
-	$(Q) echo "/* Autogenerated, don't edit */"					>  $$@
-	$(Q) cat $$< | awk '/^__NR/{print						\
-		"SYSCALL(", substr($(AV)3, 5), ",", $(AV)2, ")"}'			>> $$@
-endef
-
-$(sys-codes-generic): $(ARCH_DIR)/std/syscalls/syscall_32.tbl
-	$(call msg-gen, $@)
-	$(Q) echo "/* Autogenerated, don't edit */"			>  $@
-	$(Q) echo "#ifndef __ASM_CR_SYSCALL_CODES_H__"			>> $@
-	$(Q) echo "#define __ASM_CR_SYSCALL_CODES_H__"			>> $@
-	$(Q) echo '#include "std/syscall-codes-64.h"'			>> $@
-	$(Q) cat $< | awk '/^__NR/{NR32=$$1;				\
-		sub("^__NR", "__NR32", NR32);				\
-		print "\n#ifndef ", NR32;				\
-		print "#define ", NR32, $$2;				\
-		print "#endif";}'					>> $@
-	$(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */"		>> $@
-
-$(sys-proto-generic): $(strip $(call map,sys-proto,$(sys-bits)))
-	$(call msg-gen, $@)
-	$(Q) echo "/* Autogenerated, don't edit */"			>  $@
-	$(Q) echo "#ifndef __ASM_CR_SYSCALL_PROTO_H__"			>> $@
-	$(Q) echo "#define __ASM_CR_SYSCALL_PROTO_H__"			>> $@
-	$(Q) echo ""							>> $@
-	$(Q) echo "#ifdef CONFIG_X86_32"				>> $@
-	$(Q) echo '#include "std/syscall-32.h"'				>> $@
-	$(Q) echo "#else"						>> $@
-	$(Q) echo '#include "std/syscall-64.h"'				>> $@
-	$(Q) echo "#endif /* CONFIG_X86_32 */"				>> $@
-	$(Q) echo ""							>> $@
-	$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */"		>> $@
-
-$(eval $(call map,gen-rule-sys-codes,$(sys-bits)))
-$(eval $(call map,gen-rule-sys-proto,$(sys-bits)))
-$(eval $(call map,gen-rule-sys-asm,$(sys-bits)))
-
-std-headers-deps	+= $(call sys-codes,$(sys-bits))
-std-headers-deps	+= $(call sys-proto,$(sys-bits))
-std-headers-deps	+= $(call sys-asm,$(sys-bits))
-std-headers-deps	+= $(sys-codes-generic)
-std-headers-deps	+= $(sys-proto-generic)
+#
+# Almost all plugins depen on syscall headers
+# and definitions so we have to order their
+# generation manually.
+$(foreach t,$(target),$(eval $(call syscall-priority,$(t)-obj-y,std-headers-deps)))
 
-$(addprefix $(obj)/,$(std-obj-y:%.o=%.d)): | $(std-headers-deps)
-$(addprefix $(obj)/,$(std-obj-y:%.o=%.i)): | $(std-headers-deps)
-$(addprefix $(obj)/,$(std-obj-y:%.o=%.s)): | $(std-headers-deps)
-$(addprefix $(obj)/,$(std-obj-y)): | $(std-headers-deps)
+#std-obj-y		+= ./$(ARCH_DIR)/std/call32.o
+#std-obj-y		+= ./$(ARCH_DIR)/std/prologue.o
diff --git a/compel/plugins/include/uapi/std/asm/.gitignore b/compel/plugins/include/uapi/std/asm/.gitignore
new file mode 100644
index 000000000000..e69de29bb2d1
diff --git a/compel/plugins/include/uapi/std/syscall-types.h b/compel/plugins/include/uapi/std/syscall-types.h
index 564d027f206d..3296153b39a0 100644
--- a/compel/plugins/include/uapi/std/syscall-types.h
+++ b/compel/plugins/include/uapi/std/syscall-types.h
@@ -52,6 +52,6 @@ struct krlimit {
 /* Type of timers in the kernel.  */
 typedef int kernel_timer_t;
 
-#include "asm/syscall-types.h"
+#include "uapi/std/asm/syscall-types.h"
 
 #endif /* COMPEL_SYSCALL_TYPES_H__ */
diff --git a/compel/plugins/std/std.c b/compel/plugins/std/std.c
index 6894a6921336..ada3f09d21a3 100644
--- a/compel/plugins/std/std.c
+++ b/compel/plugins/std/std.c
@@ -6,7 +6,7 @@
 
 #include "asm/prologue.h"
 
-extern int main(void *arg_p, unsigned int arg_s);
+extern int compel_main(void *arg_p, unsigned int arg_s);
 
 static struct prologue_init_args *init_args;
 static int ctl_socket = -1;
@@ -75,7 +75,7 @@ int __export_std_compel_start(struct prologue_init_args *args,
 	}
 
 	if (!ret)
-		ret = main(args->arg_p, args->arg_s);
+		ret = compel_main(args->arg_p, args->arg_s);
 
 	for (; i > 0; i--) {
 		const plugin_init_t *d = init_array[i - 1];
diff --git a/compel/plugins/std/string.c b/compel/plugins/std/string.c
index f4181f92a903..dee1daddf108 100644
--- a/compel/plugins/std/string.c
+++ b/compel/plugins/std/string.c
@@ -222,6 +222,8 @@ fin:
 
 void *std_memcpy(void *to, const void *from, unsigned int n)
 {
+	// FIXME Support archs
+#if 0
 	int d0, d1, d2;
 	asm volatile("rep ; movsl		\n"
 		     "movl %4,%%ecx		\n"
@@ -232,6 +234,7 @@ void *std_memcpy(void *to, const void *from, unsigned int n)
 		     : "=&c" (d0), "=&D" (d1), "=&S" (d2)
 		     : "0" (n / 4), "g" (n), "1" ((long)to), "2" ((long)from)
 		     : "memory");
+#endif
 	return to;
 }
 
diff --git a/criu/Makefile b/criu/Makefile
index 7bcd55d9bac0..9fdd13496024 100644
--- a/criu/Makefile
+++ b/criu/Makefile
@@ -16,6 +16,9 @@ ccflags-y		+= -iquote $(SRC_DIR)/$(ARCH_DIR)
 ccflags-y		+= -iquote $(SRC_DIR)/$(ARCH_DIR)/include
 ccflags-y		+= -iquote $(SRC_DIR)/
 ccflags-y		+= -I/usr/include/libnl3
+ccflags-y		+= -iquote compel/plugins/include
+ccflags-y		+= -iquote compel/include
+ccflags-y		+= -iquote compel/arch/$(ARCH)/plugins/std
 
 export ccflags-y
 
@@ -48,16 +51,17 @@ ifneq ($(filter-out clean mrproper,$(MAKECMDGOALS)),)
 include $(SRC_DIR)/criu/Makefile.config
 endif
 
-#
-# System calls library.
-ifeq ($(ARCH),x86)
-# Do not need 32-bit compatible syscall lib compiled in criu
-SYSCALL-LIB		:= $(ARCH_DIR)/syscalls-64.built-in.o
-else
-SYSCALL-LIB		:= $(ARCH_DIR)/syscalls.built-in.o
-endif
-syscalls_lib: $(CONFIG_HEADER)
-	$(Q) $(MAKE) $(call build-as,Makefile.syscalls,$(ARCH_DIR)) all
+##
+## System calls library.
+#ifeq ($(ARCH),x86)
+## Do not need 32-bit compatible syscall lib compiled in criu
+#SYSCALL-LIB		:= $(ARCH_DIR)/syscalls-64.built-in.o
+#else
+#SYSCALL-LIB		:= $(ARCH_DIR)/syscalls.built-in.o
+#endif
+SYSCALL-LIB		:= $(SRC_DIR)/compel/plugins/std.built-in.o
+syscalls_lib: $(SYSCALL-LIB) $(CONFIG_HEADER)
+#	$(Q) $(MAKE) $(call build-as,Makefile.syscalls,$(ARCH_DIR)) all
 .PHONY: syscalls_lib
 
 #
@@ -107,7 +111,6 @@ subclean:
 	$(Q) $(RM) $(obj)/*.{gcda,gcno,gcov}
 	$(Q) $(RM) $(obj)/pie/*.{gcda,gcno,gcov}
 	$(Q) $(RM) -r $(obj)/gcov
-	$(Q) $(MAKE) $(call build-as,Makefile.syscalls,$(ARCH_DIR)) clean
 	$(Q) $(MAKE) $(build)=$(ARCH_DIR) clean
 	$(Q) $(MAKE) $(call build-as,Makefile.library,$(PIE_DIR)) clean
 	$(Q) $(MAKE) $(call build-as,Makefile.crtools,criu) clean
@@ -119,7 +122,6 @@ clean: subclean
 #
 # Delete all generated files
 subproper:
-	$(Q) $(MAKE) $(call build-as,Makefile.syscalls,$(ARCH_DIR)) mrproper
 	$(Q) $(MAKE) $(build)=$(ARCH_DIR) mrproper
 	$(Q) $(MAKE) $(call build-as,Makefile.library,$(PIE_DIR)) mrproper
 	$(Q) $(MAKE) $(call build-as,Makefile.crtools,criu) mrproper
diff --git a/criu/Makefile.config b/criu/Makefile.config
index 7bcecb380e7a..82f4f05a6276 100644
--- a/criu/Makefile.config
+++ b/criu/Makefile.config
@@ -12,13 +12,13 @@ ifeq ($(call pkg-config-check,libselinux),y)
         FEATURE_DEFINES	+= -DCONFIG_HAS_SELINUX
 endif
 
-ifeq ($(SRCARCH),x86)
-# CONFIG_COMPAT is only for x86 now, no need for compile-test other archs
-ifeq ($(call try-cc,$(FEATURE_TEST_X86_COMPAT),-m32),true)
-        export CONFIG_COMPAT := y
-        FEATURE_DEFINES	+= -DCONFIG_COMPAT
-endif
-endif
+#ifeq ($(SRCARCH),x86)
+## CONFIG_COMPAT is only for x86 now, no need for compile-test other archs
+#ifeq ($(call try-cc,$(FEATURE_TEST_X86_COMPAT),-m32),true)
+#        export CONFIG_COMPAT := y
+#        FEATURE_DEFINES	+= -DCONFIG_COMPAT
+#endif
+#endif
 
 export DEFINES += $(FEATURE_DEFINES)
 export CFLAGS += $(FEATURE_DEFINES)
diff --git a/criu/Makefile.crtools b/criu/Makefile.crtools
index 52c00ecd776a..47ab056e99ae 100644
--- a/criu/Makefile.crtools
+++ b/criu/Makefile.crtools
@@ -1,4 +1,8 @@
 ccflags-y		+= -iquote criu/$(ARCH)
+ccflags-y		+= -iquote compel/plugins/include
+ccflags-y		+= -iquote compel/include
+ccflags-y		+= -iquote compel/arch/$(ARCH)/plugins/std
+
 obj-y			+= action-scripts.o
 obj-y			+= aio.o
 obj-y			+= bfd.o
diff --git a/criu/arch/aarch64/Makefile b/criu/arch/aarch64/Makefile
index 652d4821bdfd..943546a9ff73 100644
--- a/criu/arch/aarch64/Makefile
+++ b/criu/arch/aarch64/Makefile
@@ -2,6 +2,8 @@ builtin-name		:= crtools.built-in.o
 
 ccflags-y		+= -iquote $(obj) -iquote $(SRC_DIR)
 ccflags-y		+= -iquote $(obj)/include -iquote $(SRC_DIR)/criu/include
+ccflags-y		+= -iquote $(SRC_DIR)/compel/plugins/include
+ccflags-y		+= -iquote $(SRC_DIR)/compel/include
 
 obj-y			+= cpu.o
 obj-y			+= crtools.o
diff --git a/criu/arch/aarch64/Makefile.syscalls b/criu/arch/aarch64/Makefile.syscalls
deleted file mode 100644
index cef3f95dcce8..000000000000
--- a/criu/arch/aarch64/Makefile.syscalls
+++ /dev/null
@@ -1,52 +0,0 @@
-builtin-name		:= syscalls.built-in.o
-
-CFLAGS			:= $(filter-out -pg $(CFLAGS-GCOV),$(CFLAGS))
-
-SYS-TYPES		:= ../../include/syscall-types.h
-SYS-CODES		:= ../../include/syscall-codes.h
-SYS-PROTO		:= ../../include/syscall.h
-
-SYS-DEF			:= syscall.def
-SYS-ASM-COMMON		:= syscall-common.S
-
-SYS-GEN			:= ../scripts/arm/gen-syscalls.pl
-SYS-GEN-TBL		:= ../scripts/arm/gen-sys-exec-tbl.pl
-
-asflags-y		+= -D__ASSEMBLY__ -nostdlib -fomit-frame-pointer
-asflags-y		+= -fpie -Wstrict-prototypes -Wa,--noexecstack
-asflags-y		+= -iquote $(obj) -iquote $(obj)/include -iquote $(SRC_DIR)/criu/include
-
-SYS-ASM			:= syscalls.S
-obj-y			+= $(SYS-ASM:.S=).o
-
-ARCH_BITS		:= 64
-
-SYS-EXEC-TBL		:= sys-exec-tbl.c
-
-$(obj)/$(SYS-ASM): $(obj)/$(SYS-GEN) $(obj)/syscalls/$(SYS-DEF) $(obj)/syscalls/$(SYS-ASM-COMMON)
-	$(E) "  GEN     " $@
-	$(Q) perl				\
-		$(obj)/$(SYS-GEN)		\
-		$(obj)/syscalls/$(SYS-DEF)	\
-		$(obj)/$(SYS-CODES)		\
-		$(obj)/$(SYS-PROTO)		\
-		$(obj)/$(SYS-ASM)		\
-		syscalls/$(SYS-ASM-COMMON)	\
-		$(obj)/$(SYS-TYPES)		\
-		$(ARCH_BITS)
-
-$(obj)/syscalls.o: $(obj)/$(SYS-ASM)
-
-$(obj)/$(SYS-EXEC-TBL): $(obj)/$(SYS-GEN-TBL) $(obj)/syscalls/$(SYS-DEF)
-	$(E) "  GEN     " $@
-	$(Q) perl				\
-		$(obj)/$(SYS-GEN-TBL)		\
-		$(obj)/syscalls/$(SYS-DEF)	\
-		$(obj)/$(SYS-EXEC-TBL)		\
-		$(ARCH_BITS)
-
-all-y += $(obj)/$(SYS-EXEC-TBL)
-
-mrproper-y += $(obj)/$(SYS-EXEC-TBL) $(obj)/$(SYS-ASM)
-mrproper-y += $(obj)/$(SYS-CODES)
-mrproper-y += $(obj)/$(SYS-PROTO)
diff --git a/criu/arch/aarch64/include/asm/types.h b/criu/arch/aarch64/include/asm/types.h
index 078a8f2fb3c3..dfd289820950 100644
--- a/criu/arch/aarch64/include/asm/types.h
+++ b/criu/arch/aarch64/include/asm/types.h
@@ -10,34 +10,11 @@
 #include "asm/bitops.h"
 #include "asm/int.h"
 
+#include "uapi/std/asm/syscall-types.h"
 
 #define SIGMAX			64
 #define SIGMAX_OLD		31
 
-typedef void rt_signalfn_t(int, siginfo_t *, void *);
-typedef rt_signalfn_t *rt_sighandler_t;
-
-typedef void rt_restorefn_t(void);
-typedef rt_restorefn_t *rt_sigrestore_t;
-
-#define _KNSIG		64
-#define _NSIG_BPW	64
-
-#define _KNSIG_WORDS	(_KNSIG / _NSIG_BPW)
-
-typedef struct {
-	unsigned long sig[_KNSIG_WORDS];
-} k_rtsigset_t;
-
-#define SA_RESTORER	0x00000000
-
-typedef struct {
-	rt_sighandler_t	rt_sa_handler;
-	unsigned long	rt_sa_flags;
-	rt_sigrestore_t	rt_sa_restorer;
-	k_rtsigset_t	rt_sa_mask;
-} rt_sigaction_t;
-
 /*
  * Copied from the Linux kernel header arch/arm64/include/uapi/asm/ptrace.h
  *
diff --git a/criu/arch/aarch64/restorer.c b/criu/arch/aarch64/restorer.c
index 2c61e2d03109..8a206315ddc0 100644
--- a/criu/arch/aarch64/restorer.c
+++ b/criu/arch/aarch64/restorer.c
@@ -4,7 +4,7 @@
 #include "asm/restorer.h"
 #include "asm/string.h"
 
-#include "syscall.h"
+#include "uapi/std/syscall.h"
 #include "log.h"
 #include "asm/fpu.h"
 #include "cpu.h"
diff --git a/criu/arch/aarch64/syscalls/syscall.def b/criu/arch/aarch64/syscalls/syscall.def
deleted file mode 120000
index e9370a6e5485..000000000000
--- a/criu/arch/aarch64/syscalls/syscall.def
+++ /dev/null
@@ -1 +0,0 @@
-../../arm/syscalls/syscall.def
\ No newline at end of file
diff --git a/criu/arch/aarch64/vdso-pie.c b/criu/arch/aarch64/vdso-pie.c
index 0f06c2d191d1..6967b5cf644c 100644
--- a/criu/arch/aarch64/vdso-pie.c
+++ b/criu/arch/aarch64/vdso-pie.c
@@ -3,7 +3,7 @@
 #include "asm/string.h"
 #include "asm/types.h"
 
-#include "syscall.h"
+#include "uapi/std/syscall.h"
 #include "parasite-vdso.h"
 #include "log.h"
 #include "bug.h"
diff --git a/criu/arch/arm/Makefile b/criu/arch/arm/Makefile
index 5db577340a7d..a5df78dc35a9 100644
--- a/criu/arch/arm/Makefile
+++ b/criu/arch/arm/Makefile
@@ -1,6 +1,8 @@
 builtin-name		:= crtools.built-in.o
 
 ccflags-y		+= -iquote $(obj) -iquote $(SRC_DIR) -iquote $(obj)/include -iquote $(SRC_DIR)/criu/include
+ccflags-y		+= -iquote $(SRC_DIR)/compel/plugins/include
+ccflags-y		+= -iquote $(SRC_DIR)/compel/include
 
 obj-y			+= cpu.o
 obj-y			+= crtools.o
diff --git a/criu/arch/arm/Makefile.syscalls b/criu/arch/arm/Makefile.syscalls
deleted file mode 100644
index c5d1178fb028..000000000000
--- a/criu/arch/arm/Makefile.syscalls
+++ /dev/null
@@ -1,52 +0,0 @@
-builtin-name		:= syscalls.built-in.o
-
-CFLAGS			:= $(filter-out -pg $(CFLAGS-GCOV),$(CFLAGS))
-
-SYS-TYPES		:= ../../include/syscall-types.h
-SYS-CODES		:= ../../include/syscall-codes.h
-SYS-PROTO		:= ../../include/syscall.h
-
-SYS-DEF			:= syscall.def
-SYS-ASM-COMMON		:= syscall-common.S
-
-SYS-GEN			:= ../scripts/arm/gen-syscalls.pl
-SYS-GEN-TBL		:= ../scripts/arm/gen-sys-exec-tbl.pl
-
-asflags-y		+= -D__ASSEMBLY__ -nostdlib -fomit-frame-pointer
-asflags-y		+= -fpie -Wstrict-prototypes -Wa,--noexecstack
-asflags-y		+= -iquote $(obj) -iquote $(obj)/include -iquote $(SRC_DIR)/criu/include
-
-SYS-ASM			:= syscalls.S
-obj-y			+= $(SYS-ASM:.S=).o
-
-ARCH_BITS		:= 32
-
-SYS-EXEC-TBL		:= sys-exec-tbl.c
-
-$(obj)/$(SYS-ASM): $(obj)/$(SYS-GEN) $(obj)/syscalls/$(SYS-DEF) $(obj)/syscalls/$(SYS-ASM-COMMON)
-	$(E) "  GEN     " $@
-	$(Q) perl				\
-		$(obj)/$(SYS-GEN)		\
-		$(obj)/syscalls/$(SYS-DEF)	\
-		$(obj)/$(SYS-CODES)		\
-		$(obj)/$(SYS-PROTO)		\
-		$(obj)/$(SYS-ASM)		\
-		syscalls/$(SYS-ASM-COMMON)	\
-		$(obj)/$(SYS-TYPES)		\
-		$(ARCH_BITS)
-
-$(obj)/syscalls.o: $(obj)/$(SYS-ASM)
-
-$(obj)/$(SYS-EXEC-TBL): $(obj)/$(SYS-GEN-TBL) $(obj)/syscalls/$(SYS-DEF)
-	$(E) "  GEN     " $@
-	$(Q) perl				\
-		$(obj)/$(SYS-GEN-TBL)		\
-		$(obj)/syscalls/$(SYS-DEF)	\
-		$(obj)/$(SYS-EXEC-TBL)		\
-		$(ARCH_BITS)
-
-all-y += $(obj)/$(SYS-EXEC-TBL)
-
-mrproper-y += $(obj)/$(SYS-EXEC-TBL) $(obj)/$(SYS-ASM)
-mrproper-y += $(obj)/$(SYS-CODES)
-mrproper-y += $(obj)/$(SYS-PROTO)
diff --git a/criu/arch/arm/include/asm/types.h b/criu/arch/arm/include/asm/types.h
index aafc4bb5362b..d0d849155127 100644
--- a/criu/arch/arm/include/asm/types.h
+++ b/criu/arch/arm/include/asm/types.h
@@ -9,36 +9,16 @@
 #include "asm/bitops.h"
 #include "asm/int.h"
 
+#include "uapi/std/asm/syscall-types.h"
+
 #define SIGMAX			64
 #define SIGMAX_OLD		31
 
 #define MAJOR(dev)		((dev)>>8)
 #define MINOR(dev)		((dev) & 0xff)
 
-typedef void rt_signalfn_t(int, siginfo_t *, void *);
-typedef rt_signalfn_t *rt_sighandler_t;
-
-typedef void rt_restorefn_t(void);
-typedef rt_restorefn_t *rt_sigrestore_t;
-
-#define _KNSIG		64
-#define _NSIG_BPW	32
-
-#define _KNSIG_WORDS	(_KNSIG / _NSIG_BPW)
-
-typedef struct {
-	unsigned long sig[_KNSIG_WORDS];
-} k_rtsigset_t;
-
 #define SA_RESTORER	0x04000000
 
-typedef struct {
-	rt_sighandler_t	rt_sa_handler;
-	unsigned long	rt_sa_flags;
-	rt_sigrestore_t	rt_sa_restorer;
-	k_rtsigset_t	rt_sa_mask;
-} rt_sigaction_t;
-
 /*
  * Copied from the Linux kernel header arch/arm/include/asm/ptrace.h
  *
diff --git a/criu/arch/arm/restorer.c b/criu/arch/arm/restorer.c
index 786feeeb31bd..ea9ae680547a 100644
--- a/criu/arch/arm/restorer.c
+++ b/criu/arch/arm/restorer.c
@@ -4,7 +4,7 @@
 #include "asm/restorer.h"
 #include "asm/string.h"
 
-#include "syscall.h"
+#include "uapi/std/syscall.h"
 #include "log.h"
 #include "asm/fpu.h"
 #include "cpu.h"
diff --git a/criu/arch/ppc64/Makefile b/criu/arch/ppc64/Makefile
index 5db577340a7d..a5df78dc35a9 100644
--- a/criu/arch/ppc64/Makefile
+++ b/criu/arch/ppc64/Makefile
@@ -1,6 +1,8 @@
 builtin-name		:= crtools.built-in.o
 
 ccflags-y		+= -iquote $(obj) -iquote $(SRC_DIR) -iquote $(obj)/include -iquote $(SRC_DIR)/criu/include
+ccflags-y		+= -iquote $(SRC_DIR)/compel/plugins/include
+ccflags-y		+= -iquote $(SRC_DIR)/compel/include
 
 obj-y			+= cpu.o
 obj-y			+= crtools.o
diff --git a/criu/arch/ppc64/Makefile.syscalls b/criu/arch/ppc64/Makefile.syscalls
deleted file mode 100644
index d115978210af..000000000000
--- a/criu/arch/ppc64/Makefile.syscalls
+++ /dev/null
@@ -1,57 +0,0 @@
-builtin-name		:= syscalls.built-in.o
-
-CFLAGS			:= $(filter-out -pg $(CFLAGS-GCOV),$(CFLAGS))
-
-SYS-TYPES		:= ../../include/syscall-types.h
-SYS-CODES		:= ../../include/syscall-codes.h
-SYS-PROTO		:= ../../include/syscall.h
-SYS-DEF			:= syscall-ppc64.tbl
-SYS-ASM-COMMON		:= syscall-common-ppc64.S
-
-asflags-y		+= -D__ASSEMBLY__ -nostdlib -fomit-frame-pointer
-asflags-y		+= -fpie -Wstrict-prototypes -Wa,--noexecstack
-asflags-y		+= -iquote $(obj) -iquote $(obj)/include -iquote $(SRC_DIR)/criu/include
-
-SYS-ASM			:= syscalls.S
-obj-y			+= $(SYS-ASM:.S=).o
-
-$(obj)/$(SYS-CODES): $(obj)/syscalls/$(SYS-DEF)
-	$(E) "  GEN     " $@
-	$(Q) echo "/* Autogenerated, don't edit */"							>  $@
-	$(Q) echo "#ifndef __ASM_CR_SYSCALL_CODES_H__"							>> $@
-	$(Q) echo "#define __ASM_CR_SYSCALL_CODES_H__"							>> $@
-	$(Q) cat $< | awk '/^__NR/{SYSN=$$1; sub("^__NR", "SYS", SYSN);'\
-	'print "\n#ifndef ", $$1, "\n#define", $$1, $$2, "\n#endif";'\
-	'print "#ifndef ", SYSN, "\n#define ", SYSN, $$1, "\n#endif"}'					>> $@
-	$(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */"						>> $@
-mrproper-y		+= $(obj)/$(SYS-CODES)
-
-$(obj)/$(SYS-PROTO): $(obj)/syscalls/$(SYS-DEF)
-	$(E) "  GEN     " $@
-	$(Q) echo "/* Autogenerated, don't edit */"							>  $@
-	$(Q) echo "#ifndef __ASM_CR_SYSCALL_PROTO_H__"							>> $@
-	$(Q) echo "#define __ASM_CR_SYSCALL_PROTO_H__"							>> $@
-	$(Q) echo "#include \"syscall-codes.h\""							>> $@
-	$(Q) echo "#include \"syscall-types.h\""							>> $@
-	$(Q) cat $< | awk  '/^__NR/{print "extern long", $$3, substr($$0, index($$0,$$4)), ";"}'	>> $@
-	$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */"						>> $@
-mrproper-y		+= $(obj)/$(SYS-PROTO)
-
-$(obj)/$(SYS-ASM): $(obj)/syscalls/$(SYS-DEF) $(obj)/syscalls/$(SYS-ASM-COMMON) $(obj)/$(SYS-CODES) $(obj)/$(SYS-PROTO)
-	$(E) "  GEN     " $@
-	$(Q) echo "/* Autogenerated, don't edit */"							>  $@
-	$(Q) echo "#include \"syscall-codes.h\""							>> $@
-	$(Q) echo "#include \"syscalls/$(SYS-ASM-COMMON)\""						>> $@
-	$(Q) cat $< | awk '/^__NR/{print "SYSCALL(", $$3, ",", $$2, ")"}'				>> $@
-mrproper-y		+= $(obj)/$(SYS-ASM)
-
-SYS-EXEC-TBL		:= sys-exec-tbl.c
-$(obj)/$(SYS-EXEC-TBL): $(obj)/syscalls/$(SYS-DEF) $(obj)/$(SYS-CODES) $(obj)/$(SYS-PROTO)
-	$(E) "  GEN     " $@
-	$(Q) echo "/* Autogenerated, don't edit */"							>  $@
-	$(Q) echo "static struct syscall_exec_desc sc_exec_table[] = {"					>>  $@
-	$(Q) cat $< | awk '/^__NR/{print "SYSCALL(", substr($$3, 5), ",", $$2, ")"}'			>> $@
-	$(Q) echo "	{ }, /* terminator */"								>>  $@
-	$(Q) echo "};"					>>  $@
-mrproper-y		+= $(obj)/$(SYS-EXEC-TBL)
-all-y			+= $(obj)/$(SYS-EXEC-TBL)
diff --git a/criu/arch/ppc64/include/asm/types.h b/criu/arch/ppc64/include/asm/types.h
index 82a09e051c88..bf054d2dae30 100644
--- a/criu/arch/ppc64/include/asm/types.h
+++ b/criu/arch/ppc64/include/asm/types.h
@@ -9,37 +9,14 @@
 #include "asm/bitops.h"
 #include "asm/int.h"
 
-/*
- * Copied from kernel header include/uapi/asm-generic/signal-defs.h
- */
-typedef void rt_signalfn_t(int, siginfo_t *, void *);
-typedef rt_signalfn_t *rt_sighandler_t;
-
-typedef void rt_restorefn_t(void);
-typedef rt_restorefn_t *rt_sigrestore_t;
+#include "uapi/std/asm/syscall-types.h"
 
 #define SIGMAX_OLD	31
 #define SIGMAX		64
 
-/*Copied from the Linux kernel arch/powerpc/include/uapi/asm/signal.h */
-#define _KNSIG		64
-#define _NSIG_BPW       64
-#define _KNSIG_WORDS     (_KNSIG / _NSIG_BPW)
-
-typedef struct {
-        uint64_t sig[_KNSIG_WORDS];
-} k_rtsigset_t;
-
 /* Copied from the Linux kernel arch/powerpc/include/uapi/asm/signal.h */
 #define SA_RESTORER     0x04000000U
 
-typedef struct {
-        rt_sighandler_t rt_sa_handler;
-        unsigned long rt_sa_flags;
-        rt_sigrestore_t rt_sa_restorer;
-        k_rtsigset_t rt_sa_mask;               /* mask last for extensibility */
-} rt_sigaction_t;
-
 /*
  * Copied from kernel header arch/powerpc/include/uapi/asm/ptrace.h
  */
diff --git a/criu/arch/ppc64/restorer.c b/criu/arch/ppc64/restorer.c
index 5379e60182b8..3f0aff87a5d4 100644
--- a/criu/arch/ppc64/restorer.c
+++ b/criu/arch/ppc64/restorer.c
@@ -4,7 +4,7 @@
 #include "asm/restorer.h"
 #include "asm/fpu.h"
 
-#include "syscall.h"
+#include "uapi/std/syscall.h"
 #include "log.h"
 
 int restore_nonsigframe_gpregs(UserPpc64RegsEntry *r)
diff --git a/criu/arch/ppc64/vdso-pie.c b/criu/arch/ppc64/vdso-pie.c
index db4aadb494ce..b3994f11e0d0 100644
--- a/criu/arch/ppc64/vdso-pie.c
+++ b/criu/arch/ppc64/vdso-pie.c
@@ -3,7 +3,7 @@
 #include "asm/string.h"
 #include "asm/types.h"
 
-#include "syscall.h"
+#include "uapi/std/syscall.h"
 #include "parasite-vdso.h"
 #include "log.h"
 #include "bug.h"
diff --git a/criu/arch/x86/Makefile b/criu/arch/x86/Makefile
index fb8608211ab5..841aa9ca882e 100644
--- a/criu/arch/x86/Makefile
+++ b/criu/arch/x86/Makefile
@@ -1,6 +1,8 @@
 builtin-name		:= crtools.built-in.o
 
 ccflags-y		+= -iquote $(obj) -iquote $(SRC_DIR) -iquote $(obj)/include -iquote $(SRC_DIR)/criu/include
+ccflags-y		+= -iquote $(SRC_DIR)/compel/plugins/include
+ccflags-y		+= -iquote $(SRC_DIR)/compel/include
 
 asflags-y		+= -Wstrict-prototypes -Wa,--noexecstack
 asflags-y		+= -D__ASSEMBLY__ -nostdlib -fomit-frame-pointer
diff --git a/criu/arch/x86/Makefile.syscalls b/criu/arch/x86/Makefile.syscalls
deleted file mode 100644
index 839f24c1b385..000000000000
--- a/criu/arch/x86/Makefile.syscalls
+++ /dev/null
@@ -1,158 +0,0 @@
-include $(__nmk_dir)msg.mk
-
-CFLAGS			:= $(filter-out -pg $(CFLAGS-GCOV),$(CFLAGS))
-CFLAGS			:= $(filter-out -DCONFIG_X86_64,$(CFLAGS))
-
-SYS-PROTO-GENERIC	:= $(obj)/../../include/syscall.h
-
-SYS-CODES-GENERIC	= $(obj)/../../include/syscall-codes.h
-SYS-CODES		= $(obj)/../../include/syscall-codes-$(1).h
-SYS-PROTO		= $(obj)/../../include/syscall-$(1).h
-SYS-DEF			= $(obj)/syscalls/syscall_$(1).tbl
-SYS-ASM			= syscalls-$(1).S
-SYS-ASM-COMMON		= syscall-common-x86-$(1).S
-SYS-EXEC-TBL		= $(obj)/sys-exec-tbl-$(1).c
-
-target			:=
-target_32		:= syscalls-32
-target_64		:= syscalls-64
-
-SYS-BITS		:= 64
-ifeq ($(CONFIG_COMPAT),y)
-        SYS-BITS	+= 32
-endif
-
-# targets
-define gen-targets
-target			+= $(target_$(1))
-endef
-
-$(eval $(call map,gen-targets,$(SYS-BITS)))
-
-# AFLAGS, LDFLAGS
-asflags-y		+= -Wstrict-prototypes -Wa,--noexecstack
-asflags-y		+= -D__ASSEMBLY__ -nostdlib -fomit-frame-pointer
-asflags-y		+= -iquote $(obj) -iquote $(obj)/include
-asflags-y		+= -iquote $(SRC_DIR)/criu/include
-
-AFLAGS_$(target_32)	+= -fno-pic -m32
-AFLAGS_$(target_64)	+= -fpie
-LDFLAGS_$(target_32)	+= -m elf_i386
-
-$(target_32)-obj-y		+= syscalls/syscall32.o
-$(obj)/syscalls/syscall32.d: $(obj)/../../include/syscall-codes-32.h	\
-				$(obj)/../../include/syscall-32.h
-
-CFLAGS_syscall32.o += -fno-pic -m32 -DCR_NOGLIBC -DCONFIG_X86_32
-CFLAGS_syscall32.d += -fno-pic -m32 -DCR_NOGLIBC -DCONFIG_X86_32
-cleanup-y		+= $(obj)/syscalls/syscall32.o
-
-# Here are rules for 32/64-bit platforms. For compat mode we need both
-# 32 and 64 bit syscalls, so generate the rules with SYS-BIT being
-# $1 parameter in all gen-rule-*
-
-# awk variable should be escaped twice
-AV			:= $$$$
-
-define gen-rule-sys-codes
-$(SYS-CODES): $(SYS-DEF)
-	$(call msg-gen, $$@)
-	$(Q) echo "/* Autogenerated, don't edit */"			>  $$@
-	$(Q) echo "#ifndef __ASM_CR_SYSCALL_CODES_H_$(1)__"		>> $$@
-	$(Q) echo "#define __ASM_CR_SYSCALL_CODES_H_$(1)__"		>> $$@
-	$(Q) cat $$< | awk '/^__NR/{SYSN=$(AV)1;			\
-		sub("^__NR", "SYS", SYSN);				\
-		print "\n#ifndef ", $(AV)1;				\
-		print "#define", $(AV)1, $(AV)2;			\
-		print "#endif";						\
-		print "\n#ifndef ", SYSN;				\
-		print "#define ", SYSN, $(AV)1;				\
-		print "#endif";}'					>> $$@
-	$(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H_$(1)__ */"	>> $$@
-mrproper-y		+= $(SYS-CODES)
-endef
-
-define gen-rule-sys-proto
-$(SYS-PROTO): $(SYS-DEF)
-	$(call msg-gen, $$@)
-	$(Q) echo "/* Autogenerated, don't edit */"			>  $$@
-	$(Q) echo "#ifndef __ASM_CR_SYSCALL_PROTO_H_$(1)__"		>> $$@
-	$(Q) echo "#define __ASM_CR_SYSCALL_PROTO_H_$(1)__"		>> $$@
-	$(Q) echo "#ifndef CR_NOGLIBC"					>> $$@
-	$(Q) echo "# error This file should only be used in the parasite code"	\
-									>> $$@
-	$(Q) echo "#endif"						>> $$@
-	$(Q) echo '#include "syscall-codes-$(1).h"'			>> $$@
-	$(Q) echo '#include "syscall-types.h"'				>> $$@
-ifeq ($(1),32)
-	$(Q) echo '#include "asm/syscall32.h"'				>> $$@
-endif
-	$(Q) cat $$< | awk '/^__NR/{print "extern long", $(AV)3,	\
-			substr($(AV)0, index($(AV)0,$(AV)4)), ";"}'	>> $$@
-	$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H_$(1)__ */"	>> $$@
-mrproper-y		+= $(SYS-PROTO)
-endef
-
-define gen-rule-sys-asm
-$(obj)/$(SYS-ASM): $(SYS-DEF) $(obj)/syscalls/$(SYS-ASM-COMMON) \
-					$(SYS-CODES) $(SYS-PROTO)
-	$(call msg-gen, $$@)
-	$(Q) echo "/* Autogenerated, don't edit */"			>  $$@
-	$(Q) echo '#include "syscall-codes-$(1).h"'			>> $$@
-	$(Q) echo '#include "syscalls/$(SYS-ASM-COMMON)"'		>> $$@
-	$(Q) cat $$< | awk '/^__NR/{print "SYSCALL(", $(AV)3, ",", $(AV)2, ")"}'\
-									>> $$@
-mrproper-y		+= $(obj)/$(SYS-ASM)
-$(target_$(1))-obj-y	+= $(SYS-ASM:.S=).o
-endef
-
-# for 32-bit $(SYS-ASM)
-AFLAGS_syscalls-32.o	+= -fno-pic -m32
-
-define gen-rule-sys-exec-tbl
-$(SYS-EXEC-TBL): $(SYS-DEF) $(SYS-CODES) $(SYS-PROTO) $(SYS-PROTO-GENERIC)
-	$(call msg-gen, $$@)
-	$(Q) echo "/* Autogenerated, don't edit */"			>  $$@
-	$(Q) cat $$< | awk '/^__NR/{print				\
-		"SYSCALL(", substr($(AV)3, 5), ",", $(AV)2, ")"}'	>> $$@
-mrproper-y		+= $(SYS-EXEC-TBL)
-all-y			+= $(SYS-EXEC-TBL)
-endef
-
-# Some parts of criu need SYS_memfd_create and other ifndef/define syscalls
-# Use 64-bit, native syscalls as-is, add __NR32_*/SYS32_* defines
-# to generic file
-$(SYS-CODES-GENERIC): $(obj)/syscalls/syscall_32.tbl
-	$(call msg-gen, $@)
-	$(Q) echo "/* Autogenerated, don't edit */"			>  $@
-	$(Q) echo "#ifndef __ASM_CR_SYSCALL_CODES_H__"			>> $@
-	$(Q) echo "#define __ASM_CR_SYSCALL_CODES_H__"			>> $@
-	$(Q) echo '#include "syscall-codes-64.h"'			>> $@
-	$(Q) cat $< | awk '/^__NR/{NR32=$$1;				\
-		sub("^__NR", "__NR32", NR32);				\
-		print "\n#ifndef ", NR32;				\
-		print "#define ", NR32, $$2;				\
-		print "#endif";}'					>> $@
-	$(Q) echo "#endif /* __ASM_CR_SYSCALL_CODES_H__ */"		>> $@
-mrproper-y		+= $(SYS-CODES-GENERIC)
-all-y			+= $(SYS-CODES-GENERIC)
-
-$(SYS-PROTO-GENERIC): $(strip $(call map,SYS-PROTO,$(SYS-BITS)))
-	$(call msg-gen, $@)
-	$(Q) echo "/* Autogenerated, don't edit */"			>  $@
-	$(Q) echo "#ifndef __ASM_CR_SYSCALL_PROTO_H__"			>> $@
-	$(Q) echo "#define __ASM_CR_SYSCALL_PROTO_H__"			>> $@
-	$(Q) echo ""							>> $@
-	$(Q) echo "#ifdef CONFIG_X86_32"				>> $@
-	$(Q) echo '#include "syscall-32.h"'				>> $@
-	$(Q) echo "#else"						>> $@
-	$(Q) echo '#include "syscall-64.h"'				>> $@
-	$(Q) echo "#endif /* CONFIG_X86_32 */"				>> $@
-	$(Q) echo ""							>> $@
-	$(Q) echo "#endif /* __ASM_CR_SYSCALL_PROTO_H__ */"		>> $@
-mrproper-y		+= $(SYS-PROTO-GENERIC)
-
-$(eval $(call map,gen-rule-sys-codes,$(SYS-BITS)))
-$(eval $(call map,gen-rule-sys-proto,$(SYS-BITS)))
-$(eval $(call map,gen-rule-sys-asm,$(SYS-BITS)))
-$(eval $(call map,gen-rule-sys-exec-tbl,$(SYS-BITS)))
diff --git a/criu/arch/x86/crtools.c b/criu/arch/x86/crtools.c
index f222b5511249..6c196420c793 100644
--- a/criu/arch/x86/crtools.c
+++ b/criu/arch/x86/crtools.c
@@ -21,7 +21,7 @@
 #include "util.h"
 #include "cpu.h"
 #include "errno.h"
-#include "syscall-codes.h"
+#include "uapi/std/syscall-codes.h"
 #include "kerndat.h"
 
 #include "protobuf.h"
diff --git a/criu/arch/x86/include/asm/restorer.h b/criu/arch/x86/include/asm/restorer.h
index 27503e858b8f..a10f3c9d9c88 100644
--- a/criu/arch/x86/include/asm/restorer.h
+++ b/criu/arch/x86/include/asm/restorer.h
@@ -4,7 +4,7 @@
 #include "asm/types.h"
 #include "asm/fpu.h"
 #include "images/core.pb-c.h"
-#include "syscall-codes.h"
+#include "uapi/std/syscall-codes.h"
 
 struct rt_sigcontext {
 	unsigned long			r8;
diff --git a/criu/arch/x86/include/asm/types.h b/criu/arch/x86/include/asm/types.h
index 7b38c509f87a..fa475f6e4eae 100644
--- a/criu/arch/x86/include/asm/types.h
+++ b/criu/arch/x86/include/asm/types.h
@@ -8,6 +8,8 @@
 #include "asm/bitops.h"
 #include "asm/int.h"
 
+#include "uapi/std/asm/syscall-types.h"
+
 #include "bug.h"
 #include "images/core.pb-c.h"
 
@@ -17,56 +19,9 @@
 #define MAJOR(dev)		((dev)>>8)
 #define MINOR(dev)		((dev) & 0xff)
 
-typedef void rt_signalfn_t(int, siginfo_t *, void *);
-typedef rt_signalfn_t *rt_sighandler_t;
-
-typedef void rt_restorefn_t(void);
-typedef rt_restorefn_t *rt_sigrestore_t;
-
-#define _KNSIG           64
-# define _NSIG_BPW      64
-
-#define _KNSIG_WORDS     (_KNSIG / _NSIG_BPW)
-
-typedef struct {
-	u64 sig[_KNSIG_WORDS];
-} k_rtsigset_t;
-
 #define SA_RESTORER	0x04000000
 
 typedef struct {
-	rt_sighandler_t	rt_sa_handler;
-	unsigned long	rt_sa_flags;
-	rt_sigrestore_t	rt_sa_restorer;
-	k_rtsigset_t	rt_sa_mask;
-} rt_sigaction_t;
-
-/*
- * Note: there is unaligned access on x86_64 and it's fine.
- * However, when porting this code -- keep in mind about possible issues
- * with unaligned rt_sa_mask.
- */
-typedef struct __attribute__((packed)) {
-	u32	rt_sa_handler;
-	u32	rt_sa_flags;
-	u32	rt_sa_restorer;
-	k_rtsigset_t	rt_sa_mask;
-} rt_sigaction_t_compat;
-
-typedef struct {
-	unsigned int	entry_number;
-	unsigned int	base_addr;
-	unsigned int	limit;
-	unsigned int	seg_32bit:1;
-	unsigned int	contents:2;
-	unsigned int	read_exec_only:1;
-	unsigned int	limit_in_pages:1;
-	unsigned int	seg_not_present:1;
-	unsigned int	useable:1;
-	unsigned int	lm:1;
-} user_desc_t;
-
-typedef struct {
 	uint64_t	r15;
 	uint64_t	r14;
 	uint64_t	r13;
diff --git a/criu/arch/x86/restorer.c b/criu/arch/x86/restorer.c
index 3de0146e816b..0c0725147250 100644
--- a/criu/arch/x86/restorer.c
+++ b/criu/arch/x86/restorer.c
@@ -6,7 +6,7 @@
 #include "asm/fpu.h"
 #include "asm/string.h"
 
-#include "syscall.h"
+#include "uapi/std/syscall.h"
 #include "log.h"
 #include "cpu.h"
 
diff --git a/criu/arch/x86/sigaction_compat.c b/criu/arch/x86/sigaction_compat.c
index ef6d13c9101f..214b2058bf63 100644
--- a/criu/arch/x86/sigaction_compat.c
+++ b/criu/arch/x86/sigaction_compat.c
@@ -5,7 +5,7 @@
 #include <sys/mman.h>
 
 #ifdef CR_NOGLIBC
-# include "syscall.h"
+# include "uapi/std/syscall.h"
 #else
 # define sys_mmap mmap
 # define sys_munmap munmap
diff --git a/criu/arch/x86/syscalls/syscall-common-x86-32.S b/criu/arch/x86/syscalls/syscall-common-x86-32.S
deleted file mode 100644
index ae6d594dc4fe..000000000000
--- a/criu/arch/x86/syscalls/syscall-common-x86-32.S
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "asm/linkage.h"
-
-#define SYSCALL(name, opcode)		\
-	ENTRY(name);			\
-	movl	$opcode, %eax;		\
-	jmp	__syscall_common;	\
-	END(name)
-
-ENTRY(__syscall_common)
-	pushl	%ebx
-	pushl	%esi
-	pushl	%edi
-	pushl	%ebp
-
-#define __arg(n)	(4 * (n) + 20)(%esp)
-	movl	__arg(0),%ebx
-	movl	__arg(1),%ecx
-	movl	__arg(2),%edx
-	movl	__arg(3),%esi
-	movl	__arg(4),%edi
-	movl	__arg(5),%ebp
-#undef __arg
-
-	int	$0x80
-
-	popl	%ebp
-	popl	%edi
-	popl	%esi
-	popl	%ebx
-	ret
-END(__syscall_common)
-
-ENTRY(__cr_restore_rt)
-	movl	$__NR_rt_sigreturn, %eax
-	jmp	__syscall_common
-END(__cr_restore_rt)
diff --git a/criu/arch/x86/syscalls/syscall-common-x86-64.S b/criu/arch/x86/syscalls/syscall-common-x86-64.S
deleted file mode 100644
index b93c31288a20..000000000000
--- a/criu/arch/x86/syscalls/syscall-common-x86-64.S
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "asm/linkage.h"
-
-#define SYSCALL(name, opcode)		\
-	ENTRY(name);			\
-	movl	$opcode, %eax;		\
-	jmp	__syscall_common;	\
-	END(name)
-
-	.text
-	.align	4
-
-ENTRY(__syscall_common)
-	movq	%rcx, %r10
-	syscall
-	ret
-END(__syscall_common)
-
-ENTRY(__cr_restore_rt)
-	movq $__NR_rt_sigreturn, %rax
-	syscall
-END(__cr_restore_rt)
diff --git a/criu/arch/x86/syscalls/syscall32.c b/criu/arch/x86/syscalls/syscall32.c
deleted file mode 100644
index 88af59330adf..000000000000
--- a/criu/arch/x86/syscalls/syscall32.c
+++ /dev/null
@@ -1,85 +0,0 @@
-#include "asm/types.h"
-#include "syscall-32.h"
-
-#define SYS_SOCKET	1		/* sys_socket(2)		*/
-#define SYS_BIND	2		/* sys_bind(2)			*/
-#define SYS_CONNECT	3		/* sys_connect(2)		*/
-#define SYS_SENDTO	11		/* sys_sendto(2)		*/
-#define SYS_RECVFROM	12		/* sys_recvfrom(2)		*/
-#define SYS_SHUTDOWN	13		/* sys_shutdown(2)		*/
-#define SYS_SETSOCKOPT	14		/* sys_setsockopt(2)		*/
-#define SYS_GETSOCKOPT	15		/* sys_getsockopt(2)		*/
-#define SYS_SENDMSG	16		/* sys_sendmsg(2)		*/
-#define SYS_RECVMSG	17		/* sys_recvmsg(2)		*/
-
-long sys_socket(int domain, int type, int protocol)
-{
-	u32 a[] = { (u32)domain, (u32)type, (u32)protocol };
-	return sys_socketcall(SYS_SOCKET, (unsigned long *)a);
-}
-
-long sys_connect(int sockfd, struct sockaddr *addr, int addrlen)
-{
-	u32 a[] = {(u32)sockfd, (u32)addr, (u32)addrlen};
-	return sys_socketcall(SYS_CONNECT, (unsigned long *)a);
-}
-
-long sys_sendto(int sockfd, void *buff, size_t len, unsigned int flags, struct sockaddr *addr, int addr_len)
-{
-	u32 a[] = {(u32)sockfd, (u32)buff, (u32)len, (u32)flags, (u32)addr, (u32)addr_len};
-	return sys_socketcall(SYS_SENDTO, (unsigned long *)a);
-}
-
-long sys_recvfrom(int sockfd, void *ubuf, size_t size, unsigned int flags, struct sockaddr *addr, int *addr_len)
-{
-	u32 a[] = {(u32)sockfd, (u32)ubuf, (u32)size, (u32)flags, (u32)addr, (u32)addr_len};
-	return sys_socketcall(SYS_RECVFROM, (unsigned long *)a);
-}
-
-long sys_sendmsg(int sockfd, const struct msghdr *msg, int flags)
-{
-	u32 a[] = {(u32)sockfd, (u32)msg, (u32)flags};
-	return sys_socketcall(SYS_SENDMSG, (unsigned long *)a);
-}
-
-long sys_recvmsg(int sockfd, struct msghdr *msg, int flags)
-{
-	u32 a[] = {(u32)sockfd, (u32)msg, (u32)flags};
-	return sys_socketcall(SYS_RECVMSG, (unsigned long *)a);
-}
-
-long sys_shutdown(int sockfd, int how)
-{
-	u32 a[] = {(u32)sockfd, (u32)how};
-	return sys_socketcall(SYS_SHUTDOWN, (unsigned long *)a);
-}
-
-long sys_bind(int sockfd, const struct sockaddr *addr, int addrlen)
-{
-	u32 a[] = {(u32)sockfd, (u32)addr, (u32)addrlen};
-	return sys_socketcall(SYS_BIND, (unsigned long *)a);
-}
-
-long sys_setsockopt(int sockfd, int level, int optname, const void *optval, unsigned int optlen)
-{
-	u32 a[] = {(u32)sockfd, (u32)level, (u32)optname, (u32)optval, (u32)optlen};
-	return sys_socketcall(SYS_SETSOCKOPT, (unsigned long *)a);
-}
-
-long sys_getsockopt(int sockfd, int level, int optname, const void *optval, unsigned int *optlen)
-{
-	u32 a[] = {(u32)sockfd, (u32)level, (u32)optname, (u32)optval, (u32)optlen};
-	return sys_socketcall(SYS_GETSOCKOPT, (unsigned long *)a);
-}
-
-#define SHMAT		21
-
-long sys_shmat(int shmid, void *shmaddr, int shmflag)
-{
-	return sys_ipc(SHMAT, shmid, shmflag, 0, shmaddr, 0);
-}
-
-long sys_pread(unsigned int fd, char *ubuf, u32 count, u64 pos)
-{
-	return sys_pread64(fd, ubuf, count, (u32)(pos & 0xffffffffu), (u32)(pos >> 32));
-}
diff --git a/criu/arch/x86/syscalls/syscall_32.tbl b/criu/arch/x86/syscalls/syscall_32.tbl
deleted file mode 100644
index 7c4867c1b3f5..000000000000
--- a/criu/arch/x86/syscalls/syscall_32.tbl
+++ /dev/null
@@ -1,94 +0,0 @@
-#
-# System calls table, please make sure the table consist only the syscalls
-# really used somewhere in project.
-#
-# code		name			arguments
-# -------------------------------------------------------------------------------------------------------------------------------------------------------------
-__NR_restart_syscall	0		sys_restart_syscall	(void)
-__NR_exit		1		sys_exit		(unsigned long error_code)
-__NR_read		3		sys_read		(int fd, void *buf, unsigned long count)
-__NR_write		4		sys_write		(int fd, const void *buf, unsigned long count)
-__NR_open		5		sys_open		(const char *filename, int flags, unsigned int mode)
-__NR_close		6		sys_close		(int fd)
-__NR_unlink		10		sys_unlink		(char *pathname)
-__NR_lseek		19		sys_lseek		(int fd, s32 offset, unsigned int origin)
-__NR_getpid		20		sys_getpid		(void)
-__NR_mount		21		sys_mount		(const char *dev_name, const char *dir_name, const char *type, unsigned long flags, const void *data)
-__NR_ptrace		26		sys_ptrace		(long request, pid_t pid, void *addr, void *data)
-__NR_kill		37		sys_kill		(long pid, int sig)
-__NR_mkdir		39		sys_mkdir		(const char *name, int mode)
-__NR_rmdir		40		sys_rmdir		(const char *name)
-__NR_brk		45		sys_brk			(void *addr)
-__NR_umount2		52		sys_umount2		(char *name, int flags)
-__NR_ioctl		54		sys_ioctl		(unsigned int fd, unsigned int cmd, unsigned long arg)
-__NR_fcntl		55		sys_fcntl		(unsigned int fd, unsigned int cmd, unsigned long arg)
-__NR_umask		60		sys_umask		(int mask)
-__NR_setrlimit		75		sys_setrlimit		(unsigned int resource, struct krlimit *rlim)
-__NR_munmap		91		sys_munmap		(void *addr, unsigned long len)
-__NR_setpriority	97		sys_setpriority		(int which, int who, int nice)
-__NR_socketcall		102		sys_socketcall		(int call, unsigned long *args)
-__NR_setitimer		104		sys_setitimer		(int which, struct itimerval *in, struct itimerval *out)
-__NR_getitimer		105		sys_getitimer		(int which, struct itimerval *it)
-__NR_wait4		114		sys_wait4		(pid_t pid, int *stat_addr, int options, struct rusage *ru)
-__NR_ipc		117		sys_ipc			(unsigned int call, int first, unsigned long second, unsigned long third, void *ptr, long fifth)
-__NR_clone		120		sys_clone		(unsigned long flags, void *child_stack, void *parent_tid, void *child_tid)
-__NR_mprotect		125		sys_mprotect		(const void *addr, unsigned long len, unsigned long prot)
-__NR_getpgid		132		sys_getpgid		(pid_t pid)
-__NR_personality	136		sys_personality		(unsigned int personality)
-__NR_flock		143		sys_flock		(int fd, unsigned long cmd)
-__NR_getsid		147		sys_getsid		(void)
-__NR_sched_setscheduler	156		sys_sched_setscheduler	(int pid, int policy, struct sched_param *p)
-__NR_nanosleep		162		sys_nanosleep		(struct timespec *rqtp, struct timespec *rmtp)
-__NR_mremap		163		sys_mremap		(unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr)
-__NR_prctl		172		sys_prctl		(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5)
-__NR_rt_sigreturn	173		sys_rt_sigreturn	(void)
-__NR_rt_sigaction	174		sys_sigaction		(int signum, const rt_sigaction_t *act, rt_sigaction_t *oldact, size_t sigsetsize)
-__NR_rt_sigprocmask	175		sys_sigprocmask		(int how, k_rtsigset_t *set, k_rtsigset_t *oset, size_t sigsetsize)
-__NR_rt_sigqueueinfo	178		sys_rt_sigqueueinfo	(pid_t pid, int sig, siginfo_t *uinfo)
-__NR_pread64		180		sys_pread64		(unsigned int fd, char *ubuf, u32 count, u32 poslo, u32 poshi)
-__NR_capget		184		sys_capget		(struct cap_header *h, struct cap_data *d)
-__NR_capset		185		sys_capset		(struct cap_header *h, struct cap_data *d)
-__NR_sigaltstack	186		sys_sigaltstack		(const void *uss_ptr, void *uoss_ptr)
-__NR_mmap2		192		sys_mmap		(void *addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long pgoff)
-__NR_getgroups32	205		sys_getgroups		(int gsize, unsigned int *groups)
-__NR_setgroups32	206		sys_setgroups		(int gsize, unsigned int *groups)
-__NR_setresuid32	208		sys_setresuid		(int uid, int euid, int suid)
-__NR_getresuid32	209		sys_getresuid		(int *uid, int *euid, int *suid)
-__NR_setresgid32	210		sys_setresgid		(int gid, int egid, int sgid)
-__NR_getresgid32	211		sys_getresgid		(int *gid, int *egid, int *sgid)
-__NR_setfsuid32		215		sys_setfsuid		(int fsuid)
-__NR_setfsgid32		216		sys_setfsgid		(int fsgid)
-__NR_mincore		218		sys_mincore		(void *addr, unsigned long size, unsigned char *vec)
-__NR_madvise		219		sys_madvise		(unsigned long start, size_t len, int behavior)
-__NR_gettid		224		sys_gettid		(void)
-__NR_futex		240		sys_futex		(u32 *uaddr, int op, u32 val, struct timespec *utime, u32 *uaddr2, u32 val3)
-__NR_set_thread_area	243		sys_set_thread_area	(user_desc_t *info)
-__NR_get_thread_area	244		sys_get_thread_area	(user_desc_t *info)
-__NR_io_setup		245		sys_io_setup		(unsigned nr_reqs, aio_context_t *ctx32p)
-__NR_io_getevents	247		sys_io_getevents	(aio_context_t ctx_id, long min_nr, long nr, struct io_event *events, struct timespec *timeout)
-__NR_io_submit		248		sys_io_submit		(aio_context_t ctx_id, long nr, struct iocb **iocbpp)
-__NR_exit_group		252		sys_exit_group		(int error_code)
-__NR_set_tid_address	258		sys_set_tid_address	(int *tid_addr)
-__NR_timer_create	259		sys_timer_create	(clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id)
-__NR_timer_settime	260		sys_timer_settime	(kernel_timer_t timer_id, int flags, struct itimerspec *new, struct itimerspec *old)
-__NR_timer_gettime	261		sys_timer_gettime	(int timer_id, struct itimerspec *setting)
-__NR_timer_getoverrun	262		sys_timer_getoverrun	(int timer_id)
-__NR_timer_delete	263		sys_timer_delete	(kernel_timer_t timer_id)
-__NR_clock_gettime	265		sys_clock_gettime	(int which_clock, struct timespec *tp)
-__NR_waitid		284		sys_waitid		(int which, pid_t pid, struct siginfo *infop, int options, struct rusage *ru)
-__NR_openat		295		sys_openat		(int dfd, const char *filename, int flags, int mode)
-__NR_readlinkat		305		sys_readlinkat		(int fd, const char *path, char *buf, int bufsize)
-__NR_set_robust_list	311		sys_set_robust_list	(struct robust_list_head *head, size_t len)
-__NR_get_robust_list	312		sys_get_robust_list	(int pid, struct robust_list_head **head_ptr, size_t *len_ptr)
-__NR_vmsplice		316		sys_vmsplice		(int fd, const struct iovec *iov, unsigned int nr_segs, unsigned int flags)
-__NR_signalfd		321		sys_signalfd		(int ufd, const k_rtsigset_t *sigmask, size_t sigsetsize)
-__NR_timerfd_settime	325		sys_timerfd_settime	(int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr)
-__NR_rt_tgsigqueueinfo	335		sys_rt_tgsigqueueinfo	(pid_t tgid, pid_t pid, int sig, siginfo_t *uinfo)
-__NR_fanotify_init	338		sys_fanotify_init	(unsigned int flags, unsigned int event_f_flags)
-__NR_fanotify_mark	339		sys_fanotify_mark	(int fanotify_fd, unsigned int flag, u32 mask, int dfd, const char *pathname)
-__NR_open_by_handle_at	342		sys_open_by_handle_at	(int mountdirfd, struct file_handle *handle, int flags)
-__NR_setns		346		sys_setns		(int fd, int nstype)
-__NR_kcmp		349		sys_kcmp		(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2)
-__NR_seccomp		354		sys_seccomp		(unsigned int op, unsigned int flags, const char *uargs)
-__NR_memfd_create	356		sys_memfd_create	(const char *name, unsigned int flags)
-__NR_userfaultfd	374		sys_userfaultfd		(int flags)
diff --git a/criu/arch/x86/syscalls/syscall_64.tbl b/criu/arch/x86/syscalls/syscall_64.tbl
deleted file mode 100644
index 285874938b38..000000000000
--- a/criu/arch/x86/syscalls/syscall_64.tbl
+++ /dev/null
@@ -1,105 +0,0 @@
-#
-# System calls table, please make sure the table consist only the syscalls
-# really used somewhere in project.
-#
-# __NR_name			code		name			arguments
-# -------------------------------------------------------------------------------------------------------------------------------------------------------------
-__NR_read			0		sys_read		(int fd, void *buf, unsigned long count)
-__NR_write			1		sys_write		(int fd, const void *buf, unsigned long count)
-__NR_open			2		sys_open		(const char *filename, unsigned long flags, unsigned long mode)
-__NR_close			3		sys_close		(int fd)
-__NR_lseek			8		sys_lseek		(int fd, unsigned long offset, unsigned long origin)
-__NR_mmap			9		sys_mmap		(void *addr, unsigned long len, unsigned long prot, unsigned long flags, unsigned long fd, unsigned long offset)
-__NR_mprotect			10		sys_mprotect		(const void *addr, unsigned long len, unsigned long prot)
-__NR_munmap			11		sys_munmap		(void *addr, unsigned long len)
-__NR_brk			12		sys_brk			(void *addr)
-__NR_rt_sigaction		13		sys_sigaction		(int signum, const rt_sigaction_t *act, rt_sigaction_t *oldact, size_t sigsetsize)
-__NR_rt_sigprocmask		14		sys_sigprocmask		(int how, k_rtsigset_t *set, k_rtsigset_t *old, size_t sigsetsize)
-__NR_rt_sigreturn		15		sys_rt_sigreturn	(void)
-__NR_ioctl			16		sys_ioctl		(unsigned int fd, unsigned int cmd, unsigned long arg)
-__NR_pread64			17		sys_pread		(unsigned int fd, char *buf, size_t count, loff_t pos)
-__NR_mremap			25		sys_mremap		(unsigned long addr, unsigned long old_len, unsigned long new_len, unsigned long flags, unsigned long new_addr)
-__NR_mincore			27		sys_mincore		(void *addr, unsigned long size, unsigned char *vec)
-__NR_madvise			28		sys_madvise		(unsigned long start, size_t len, int behavior)
-__NR_shmat			30		sys_shmat		(int shmid, void *shmaddr, int shmflag)
-__NR_dup2			33		sys_dup2		(int oldfd, int newfd)
-__NR_nanosleep			35		sys_nanosleep		(struct timespec *req, struct timespec *rem)
-__NR_getitimer			36		sys_getitimer		(int which, const struct itimerval *val)
-__NR_setitimer			38		sys_setitimer		(int which, const struct itimerval *val, struct itimerval *old)
-__NR_getpid			39		sys_getpid		(void)
-__NR_socket			41		sys_socket		(int domain, int type, int protocol)
-__NR_connect			42		sys_connect		(int sockfd, struct sockaddr *addr, int addrlen)
-__NR_sendto			44		sys_sendto		(int sockfd, void *buff, size_t len, unsigned int flags, struct sockaddr *addr, int addr_len)
-__NR_recvfrom			45		sys_recvfrom		(int sockfd, void *ubuf, size_t size, unsigned int flags, struct sockaddr *addr, int *addr_len)
-__NR_sendmsg			46		sys_sendmsg		(int sockfd, const struct msghdr *msg, int flags)
-__NR_recvmsg			47		sys_recvmsg		(int sockfd, struct msghdr *msg, int flags)
-__NR_shutdown			48		sys_shutdown		(int sockfd, int how)
-__NR_bind			49		sys_bind		(int sockfd, const struct sockaddr *addr, int addrlen)
-__NR_setsockopt			54		sys_setsockopt		(int sockfd, int level, int optname, const void *optval, socklen_t optlen)
-__NR_getsockopt			55		sys_getsockopt		(int sockfd, int level, int optname, const void *optval, socklen_t *optlen)
-__NR_clone			56		sys_clone		(unsigned long flags, void *child_stack, void *parent_tid, void *child_tid)
-__NR_exit			60		sys_exit		(unsigned long error_code)
-__NR_wait4			61		sys_wait4		(int pid, int *status, int options, struct rusage *ru)
-__NR_kill			62		sys_kill		(long pid, int sig)
-__NR_fcntl			72		sys_fcntl		(int fd, int type, long arg)
-__NR_flock			73		sys_flock		(int fd, unsigned long cmd)
-__NR_mkdir			83		sys_mkdir		(const char *name, int mode)
-__NR_rmdir			84		sys_rmdir		(const char *name)
-__NR_unlink			87		sys_unlink		(char *pathname)
-__NR_umask			95		sys_umask		(int mask)
-__NR_ptrace			101		sys_ptrace		(long request, pid_t pid, void *addr, void *data)
-__NR_getgroups			115		sys_getgroups		(int gsize, unsigned int *groups)
-__NR_setgroups			116		sys_setgroups		(int gsize, unsigned int *groups)
-__NR_setresuid			117		sys_setresuid		(int uid, int euid, int suid)
-__NR_getresuid			118		sys_getresuid		(int *uid, int *euid, int *suid)
-__NR_setresgid			119		sys_setresgid		(int gid, int egid, int sgid)
-__NR_getresgid			120		sys_getresgid		(int *gid, int *egid, int *sgid)
-__NR_getpgid			121		sys_getpgid		(pid_t pid)
-__NR_setfsuid			122		sys_setfsuid		(int fsuid)
-__NR_setfsgid			123		sys_setfsgid		(int fsgid)
-__NR_getsid			124		sys_getsid		(void)
-__NR_capget			125		sys_capget		(struct cap_header *h, struct cap_data *d)
-__NR_capset			126		sys_capset		(struct cap_header *h, struct cap_data *d)
-__NR_rt_sigqueueinfo		129		sys_rt_sigqueueinfo	(pid_t pid, int sig, siginfo_t *info)
-__NR_sigaltstack		131		sys_sigaltstack		(const void *uss, void *uoss)
-__NR_personality		135		sys_personality		(unsigned int personality)
-__NR_setpriority		141		sys_setpriority		(int which, int who, int nice)
-__NR_sched_setscheduler		144		sys_sched_setscheduler	(int pid, int policy, struct sched_param *p)
-__NR_prctl			157		sys_prctl		(int option, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5)
-__NR_arch_prctl			158		sys_arch_prctl		(int option, unsigned long addr)
-__NR_setrlimit			160		sys_setrlimit		(int resource, struct krlimit *rlim)
-__NR_mount			165		sys_mount		(char *dev_nmae, char *dir_name, char *type, unsigned long flags, void *data)
-__NR_umount2			166		sys_umount2		(char *name, int flags)
-__NR_gettid			186		sys_gettid		(void)
-__NR_futex			202		sys_futex		(u32 *uaddr, int op, u32 val, struct timespec *utime, u32 *uaddr2, u32 val3)
-__NR_set_thread_area		205		sys_set_thread_area	(user_desc_t *info)
-__NR_io_setup			206		sys_io_setup		(unsigned nr_events, aio_context_t *ctx)
-__NR_io_getevents		208		sys_io_getevents	(aio_context_t ctx, long min_nr, long nr, struct io_event *evs, struct timespec *tmo)
-__NR_io_submit			209		sys_io_submit		(aio_context_t ctx, long nr, struct iocb **iocbpp)
-__NR_get_thread_area		211		sys_get_thread_area	(user_desc_t *info)
-__NR_set_tid_address		218		sys_set_tid_address	(int *tid_addr)
-__NR_restart_syscall		219		sys_restart_syscall	(void)
-__NR_sys_timer_create		222		sys_timer_create	(clockid_t which_clock, struct sigevent *timer_event_spec, kernel_timer_t *created_timer_id)
-__NR_sys_timer_settime		223		sys_timer_settime	(kernel_timer_t timer_id, int flags, const struct itimerspec *new_setting, struct itimerspec *old_setting)
-__NR_sys_timer_gettime		224		sys_timer_gettime	(int timer_id, const struct itimerspec *setting)
-__NR_sys_timer_getoverrun	225		sys_timer_getoverrun	(int timer_id)
-__NR_sys_timer_delete		226		sys_timer_delete	(kernel_timer_t timer_id)
-__NR_clock_gettime		228		sys_clock_gettime	(const clockid_t which_clock, const struct timespec *tp)
-__NR_exit_group			231		sys_exit_group		(int error_code)
-__NR_openat			257		sys_openat		(int dfd, const char *filename, int flags, int mode)
-__NR_waitid			247		sys_waitid		(int which, pid_t pid, struct siginfo *infop, int options, struct rusage *ru)
-__NR_readlinkat			267		sys_readlinkat		(int fd, const char *path, char *buf, int bufsize)
-__NR_set_robust_list		273		sys_set_robust_list	(struct robust_list_head *head, size_t len)
-__NR_get_robust_list		274		sys_get_robust_list	(int pid, struct robust_list_head **head_ptr, size_t *len_ptr)
-__NR_seccomp			317		sys_seccomp		(unsigned int op, unsigned int flags, const char *uargs)
-__NR_vmsplice			278		sys_vmsplice		(int fd, const struct iovec *iov, unsigned long nr_segs, unsigned int flags)
-__NR_timerfd_settime		286		sys_timerfd_settime	(int ufd, int flags, const struct itimerspec *utmr, struct itimerspec *otmr)
-__NR_signalfd4			289		sys_signalfd		(int fd, k_rtsigset_t *mask, size_t sizemask, int flags)
-__NR_rt_tgsigqueueinfo		297		sys_rt_tgsigqueueinfo	(pid_t tgid, pid_t pid, int sig, siginfo_t *info)
-__NR_fanotify_init		300		sys_fanotify_init	(unsigned int flags, unsigned int event_f_flags)
-__NR_fanotify_mark		301		sys_fanotify_mark	(int fanotify_fd, unsigned int flags, u64 mask, int dfd, const char *pathname)
-__NR_open_by_handle_at		304		sys_open_by_handle_at	(int mountdirfd, struct file_handle *handle, int flags)
-__NR_setns			308		sys_setns		(int fd, int nstype)
-__NR_kcmp			312		sys_kcmp		(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2)
-__NR_memfd_create		319		sys_memfd_create	(const char *name, unsigned int flags)
-__NR_userfaultfd		323		sys_userfaultfd		(int flags)
diff --git a/criu/arch/x86/vdso-pie.c b/criu/arch/x86/vdso-pie.c
index 7f13915255a7..1d27716c4da3 100644
--- a/criu/arch/x86/vdso-pie.c
+++ b/criu/arch/x86/vdso-pie.c
@@ -3,7 +3,7 @@
 #include "asm/string.h"
 #include "asm/types.h"
 
-#include "syscall.h"
+#include "uapi/std/syscall.h"
 #include "parasite-vdso.h"
 #include "log.h"
 #include "bug.h"
diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index a0e16ee519c2..784af5d5ae3c 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -80,7 +80,7 @@
 
 #include "parasite-syscall.h"
 #include "files-reg.h"
-#include "syscall-codes.h"
+#include "uapi/std/syscall-codes.h"
 
 #include "protobuf.h"
 #include "images/sa.pb-c.h"
diff --git a/criu/fsnotify.c b/criu/fsnotify.c
index f1e66d001dfa..e302e5bd20be 100644
--- a/criu/fsnotify.c
+++ b/criu/fsnotify.c
@@ -41,7 +41,7 @@
 #include "namespaces.h"
 #include "pstree.h"
 #include "fault-injection.h"
-#include "syscall-codes.h"
+#include "uapi/std/syscall-codes.h"
 
 #include "protobuf.h"
 #include "images/fsnotify.pb-c.h"
diff --git a/criu/include/lock.h b/criu/include/lock.h
index 8a765338bd42..1d2cab00eb7e 100644
--- a/criu/include/lock.h
+++ b/criu/include/lock.h
@@ -11,7 +11,7 @@
 #include "bug.h"
 
 #ifdef CR_NOGLIBC
-# include "syscall.h"
+# include "uapi/std/syscall.h"
 #else
 # include <unistd.h>
 # include <sys/syscall.h>
diff --git a/criu/kerndat.c b/criu/kerndat.c
index 1c0986fe4952..a4ec2f778c90 100644
--- a/criu/kerndat.c
+++ b/criu/kerndat.c
@@ -22,7 +22,7 @@
 #include "lsm.h"
 #include "proc_parse.h"
 #include "config.h"
-#include "syscall-codes.h"
+#include "uapi/std/syscall-codes.h"
 
 struct kerndat_s kdat = {
 };
diff --git a/criu/parasite-syscall.c b/criu/parasite-syscall.c
index ad33098567ec..2e074a914765 100644
--- a/criu/parasite-syscall.c
+++ b/criu/parasite-syscall.c
@@ -29,7 +29,7 @@
 #include "proc_parse.h"
 #include "aio.h"
 #include "fault-injection.h"
-#include "syscall-codes.h"
+#include "uapi/std/syscall-codes.h"
 #include "signal.h"
 
 #include <string.h>
diff --git a/criu/pie/Makefile b/criu/pie/Makefile
index 763500296b8f..420bb42e21ae 100644
--- a/criu/pie/Makefile
+++ b/criu/pie/Makefile
@@ -13,7 +13,7 @@ restorer-obj-y		+= restorer.o
 restorer-obj-y		+= ./$(ARCH_DIR)/restorer.o
 
 ifeq ($(ARCH),x86)
-        restorer-obj-e		+= ./$(ARCH_DIR)/syscalls-64.built-in.o
+        restorer-obj-e		+= ./compel/plugins/std.built-in.o
 
         ifeq ($(CONFIG_COMPAT),y)
                 restorer-obj-y	+= ./$(ARCH_DIR)/call32.o
@@ -21,9 +21,9 @@ ifeq ($(ARCH),x86)
         endif
 
         native-obj-y		+= ./$(ARCH_DIR)/parasite-head-64.o
-        native-obj-e		+= ./$(ARCH_DIR)/syscalls-64.built-in.o
+        native-obj-e		+= ./compel/plugins/std.built-in.o
         compat-obj-y		+= ./$(ARCH_DIR)/parasite-head-32.o
-        compat-obj-e		+= ./$(ARCH_DIR)/syscalls-32.built-in.o
+        compat-obj-e		+= ./compel/plugins/std-32.built-in.o
 
         AFLAGS_parasite-head-64.o += -fpie -DCONFIG_X86_64
         AFLAGS_parasite-head-64.d += -fpie -DCONFIG_X86_64
@@ -32,8 +32,8 @@ ifeq ($(ARCH),x86)
         AFLAGS_parasite-head-32.d += -fno-pic -m32 -DCONFIG_X86_32
 else
         native-obj-y		+= ./$(ARCH_DIR)/parasite-head.o
-        native-obj-e		+= ./$(ARCH_DIR)/syscalls.built-in.o
-        restorer-obj-e		+= ./$(ARCH_DIR)/syscalls.built-in.o
+        native-obj-e		+= ./compel/plugins/std.built-in.o
+        restorer-obj-e		+= ./compel/plugins/std.built-in.o
 endif
 
 target			+= $(parasite_target) restorer
@@ -51,7 +51,8 @@ CFLAGS			+= -iquote $(SRC_DIR)/criu/arch/$(ARCH)/include
 CFLAGS			+= -iquote $(SRC_DIR)/criu/include
 CFLAGS			+= -iquote $(SRC_DIR)
 
-
+ccflags-y		+= -iquote $(SRC_DIR)/compel/plugins/include
+ccflags-y		+= -iquote $(SRC_DIR)/compel/include
 ccflags-y		+= -DCR_NOGLIBC
 ifneq ($(filter-out clean mrproper,$(MAKECMDGOALS)),)
 NATIVE_CFLAGS		:= $(shell $(SRC_DIR)/compel/compel-host --arch=$(ARCH) cflags)
diff --git a/criu/pie/Makefile.library b/criu/pie/Makefile.library
index 331eecd82778..c6c6cdcabd45 100644
--- a/criu/pie/Makefile.library
+++ b/criu/pie/Makefile.library
@@ -59,6 +59,8 @@ iquotes			+= -iquote $(SRC_DIR)/$(ARCH_DIR)/include
 iquotes			+= -iquote $(SRC_DIR) -iquote $(SRC_DIR)/criu/include
 CFLAGS			:= $(filter-out -pg $(CFLAGS-GCOV),$(CFLAGS)) $(iquotes)
 asflags-y		:= -D__ASSEMBLY__ $(iquotes)
+ccflags-y              += -iquote $(SRC_DIR)/compel/plugins/include
+ccflags-y		+= -iquote $(SRC_DIR)/compel/include
 
 ifeq ($(SRCARCH),arm)
 	ccflags-y	+= -marm
diff --git a/criu/pie/log-simple.c b/criu/pie/log-simple.c
index 5d9394683d28..39b95b94d631 100644
--- a/criu/pie/log-simple.c
+++ b/criu/pie/log-simple.c
@@ -2,7 +2,7 @@
 
 #include "asm/bitsperlong.h"
 
-#include "syscall.h"
+#include "uapi/std/syscall.h"
 #include "log.h"
 
 struct simple_buf {
diff --git a/criu/pie/parasite-vdso.c b/criu/pie/parasite-vdso.c
index af969a150fee..ea8a1f2b1d75 100644
--- a/criu/pie/parasite-vdso.c
+++ b/criu/pie/parasite-vdso.c
@@ -13,7 +13,7 @@
 #include "asm/types.h"
 #include "asm/page.h"
 
-#include "syscall.h"
+#include "uapi/std/syscall.h"
 #include "image.h"
 #include "parasite-vdso.h"
 #include "vma.h"
diff --git a/criu/pie/parasite.c b/criu/pie/parasite.c
index 6c556542f6dd..6a633168eeff 100644
--- a/criu/pie/parasite.c
+++ b/criu/pie/parasite.c
@@ -7,7 +7,7 @@
 #include <stdarg.h>
 #include <sys/ioctl.h>
 
-#include "syscall.h"
+#include "uapi/std/syscall.h"
 #include "parasite.h"
 #include "config.h"
 #include "fcntl.h"
@@ -22,6 +22,11 @@
 #include "asm/parasite.h"
 #include "asm/restorer.h"
 
+int compel_main(void *arg_p, unsigned int arg_s)
+{
+	return 0;
+}
+
 static int tsock = -1;
 
 static struct rt_sigframe *sigframe;
diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index 6790118e0ccb..dc48de935a22 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -22,7 +22,7 @@
 #include "compiler.h"
 #include "asm/string.h"
 #include "asm/types.h"
-#include "syscall.h"
+#include "uapi/std/syscall.h"
 #include "signal.h"
 #include "config.h"
 #include "prctl.h"
@@ -63,6 +63,11 @@ static int n_helpers;
 static pid_t *zombies;
 static int n_zombies;
 
+int compel_main(void *arg_p, unsigned int arg_s)
+{
+	return 0;
+}
+
 extern void cr_restore_rt (void) asm ("__cr_restore_rt")
 			__attribute__ ((visibility ("hidden")));
 
diff --git a/criu/pie/util-fd.c b/criu/pie/util-fd.c
index 14d7d14500b2..78252cd22241 100644
--- a/criu/pie/util-fd.c
+++ b/criu/pie/util-fd.c
@@ -10,7 +10,7 @@
 #include "asm/types.h"
 
 #ifdef CR_NOGLIBC
-# include "syscall.h"
+# include "uapi/std/syscall.h"
 # define __sys(foo)	sys_##foo
 #else
 # define __sys(foo)	foo
diff --git a/criu/pie/util.c b/criu/pie/util.c
index 7dcef39a699b..4dace66b03b6 100644
--- a/criu/pie/util.c
+++ b/criu/pie/util.c
@@ -12,7 +12,7 @@
 #include "util-pie.h"
 
 #ifdef CR_NOGLIBC
-# include "syscall.h"
+# include "uapi/std/syscall.h"
 # define __sys(foo)     sys_##foo
 #else
 # define __sys(foo)     foo
diff --git a/criu/shmem.c b/criu/shmem.c
index 341e3bc1375b..bfdaa80654a8 100644
--- a/criu/shmem.c
+++ b/criu/shmem.c
@@ -15,7 +15,7 @@
 #include "vma.h"
 #include "mem.h"
 #include "config.h"
-#include "syscall-codes.h"
+#include "uapi/std/syscall-codes.h"
 #include "asm/bitops.h"
 
 #include "protobuf.h"
diff --git a/criu/uffd.c b/criu/uffd.c
index 81dc7ae5cea3..a280f6a31c8c 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -32,7 +32,7 @@
 #include "crtools.h"
 #include "cr_options.h"
 #include "xmalloc.h"
-#include "syscall-codes.h"
+#include "uapi/std/syscall-codes.h"
 #include "restorer.h"
 #include "page-xfer.h"
 #include "lock.h"
-- 
2.7.4



More information about the CRIU mailing list