[CRIU] [PATCH 9/9] compel: no -r for ARM ldflags

Kir Kolyshkin kir at openvz.org
Fri Mar 24 15:07:46 PDT 2017


Commit d9486bd720 ("arm/pie/build: do not produce relocatable parasite
object") removed -r from LDFLAGS used to compile criu pie. This
functionality somehow never made it to criu-dev, and was also lost
in master then compel was ported to it.

Make it work with compel.

Unfortunately it was not as simple as I initially thought, as -r flag
to ld was built into nmk. This patch removes it, and adds it to all
places that need intermediate linking.

Cc: Dmitry Safonov <dsafonov at virtuozzo.com>
Cc: Cyrill Gorcunov <gorcunov at openvz.org>
Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 compel/Makefile              | 1 +
 compel/src/main.c            | 4 ++++
 criu/Makefile.crtools        | 1 +
 criu/arch/aarch64/Makefile   | 1 +
 criu/arch/arm/Makefile       | 1 +
 criu/arch/ppc64/Makefile     | 1 +
 criu/arch/x86/Makefile       | 2 +-
 lib/c/Makefile               | 2 +-
 scripts/nmk/scripts/build.mk | 2 +-
 9 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/compel/Makefile b/compel/Makefile
index fee1212..43d27f5 100644
--- a/compel/Makefile
+++ b/compel/Makefile
@@ -11,6 +11,7 @@ ccflags-y		+= -iquote compel/arch/$(ARCH)/src/lib/include
 ccflags-y		+= -iquote compel/include
 ccflags-y		+= -fno-strict-aliasing
 ccflags-y		+= -fPIC
+ldflags-y		+= -r
 
 #
 # UAPI inclusion, referred as <compel/...>
diff --git a/compel/src/main.c b/compel/src/main.c
index e0dcb09..4584ef9 100644
--- a/compel/src/main.c
+++ b/compel/src/main.c
@@ -26,7 +26,11 @@
 #define COMPEL_CFLAGS_PIE	CFLAGS_DEFAULT_SET "-fpie"
 #define COMPEL_CFLAGS_NOPIC	CFLAGS_DEFAULT_SET "-fno-pic"
 
+#ifdef NO_RELOCS
+#define COMPEL_LDFLAGS_COMMON	"-z noexecstack -T "
+#else
 #define COMPEL_LDFLAGS_COMMON	"-r -z noexecstack -T "
+#endif
 
 typedef struct {
 	const char	*arch;		// dir name under arch/
diff --git a/criu/Makefile.crtools b/criu/Makefile.crtools
index fdd14dc..e98837f 100644
--- a/criu/Makefile.crtools
+++ b/criu/Makefile.crtools
@@ -1,6 +1,7 @@
 ccflags-y		+= -iquote criu/$(ARCH)
 ccflags-y		+= $(COMPEL_UAPI_INCLUDES)
 CFLAGS_REMOVE_clone-noasan.o += $(CFLAGS-ASAN)
+ldflags-y		+= -r
 
 obj-y			+= action-scripts.o
 obj-y			+= external.o
diff --git a/criu/arch/aarch64/Makefile b/criu/arch/aarch64/Makefile
index 0dc6350..49ef6a4 100644
--- a/criu/arch/aarch64/Makefile
+++ b/criu/arch/aarch64/Makefile
@@ -4,6 +4,7 @@ ccflags-y		+= -iquote $(obj)/include -iquote criu/include
 ccflags-y		+= -iquote include
 ccflags-y		+= $(COMPEL_UAPI_INCLUDES)
 asflags-y		+= -D__ASSEMBLY__
+ldflags-y		+= -r
 
 obj-y			+= cpu.o
 obj-y			+= crtools.o
diff --git a/criu/arch/arm/Makefile b/criu/arch/arm/Makefile
index 1b0bc56..d79ab62 100644
--- a/criu/arch/arm/Makefile
+++ b/criu/arch/arm/Makefile
@@ -5,6 +5,7 @@ ccflags-y		+= -iquote criu/include -iquote include
 ccflags-y		+= $(COMPEL_UAPI_INCLUDES)
 
 asflags-y		+= -D__ASSEMBLY__
+ldflags-y		+= -r
 
 obj-y			+= cpu.o
 obj-y			+= crtools.o
diff --git a/criu/arch/ppc64/Makefile b/criu/arch/ppc64/Makefile
index 8148dc9..ff0a712 100644
--- a/criu/arch/ppc64/Makefile
+++ b/criu/arch/ppc64/Makefile
@@ -3,6 +3,7 @@ builtin-name		:= crtools.built-in.o
 ccflags-y		+= -iquote $(obj)/include
 ccflags-y		+= -iquote criu/include -iquote include
 ccflags-y		+= $(COMPEL_UAPI_INCLUDES)
+ldflags-y		+= -r
 
 obj-y			+= cpu.o
 obj-y			+= crtools.o
diff --git a/criu/arch/x86/Makefile b/criu/arch/x86/Makefile
index 9ff5994..669dc07 100644
--- a/criu/arch/x86/Makefile
+++ b/criu/arch/x86/Makefile
@@ -7,7 +7,7 @@ ccflags-y		+= $(COMPEL_UAPI_INCLUDES)
 asflags-y		+= -Wstrict-prototypes
 asflags-y		+= -D__ASSEMBLY__ -nostdlib -fomit-frame-pointer
 asflags-y		+= -iquote $(obj)/include
-ldflags-y		+= -z noexecstack
+ldflags-y		+= -r -z noexecstack
 
 obj-y			+= cpu.o
 obj-y			+= crtools.o
diff --git a/lib/c/Makefile b/lib/c/Makefile
index 79a8e69..af01467 100644
--- a/lib/c/Makefile
+++ b/lib/c/Makefile
@@ -5,4 +5,4 @@ ccflags-y		+= -iquote criu/$(ARCH_DIR)/include
 ccflags-y		+= -iquote criu/include
 ccflags-y		+= -iquote images
 ccflags-y		+= -fPIC -fno-stack-protector
-ldflags-y		+= -z noexecstack
+ldflags-y		+= -r -z noexecstack
diff --git a/scripts/nmk/scripts/build.mk b/scripts/nmk/scripts/build.mk
index cd49ace..a6bd47d 100644
--- a/scripts/nmk/scripts/build.mk
+++ b/scripts/nmk/scripts/build.mk
@@ -142,7 +142,7 @@ endif
 define gen-ld-target-rule
 $(1): $(3)
 	$$(call msg-link, $$@)
-	$$(Q) $$(LD) $(2) -r -o $$@ $(4)
+	$$(Q) $$(LD) $(2) -o $$@ $(4)
 endef
 
 define gen-ar-target-rule
-- 
2.9.3



More information about the CRIU mailing list