[CRIU] [PATCH 04/44] multiarch: introduced the multiarch support into the build system.
Alexander Kartashov
alekskartashov at parallels.com
Mon Jan 7 10:04:33 EST 2013
* The linker script pie/pie.lds.S is generated from the template
pie/pie.lds.S.in by prepending the output architecture specification.
The output architecture is defined by the variable LDARCH.
* Blobs are generated by objcopy instead of ld because the ARM linker
fails to produce a binary when supplied a script.
(See http://lists.gnu.org/archive/html/bug-binutils/2008-10/msg00091.html).
Signed-off-by: Alexander Kartashov <alekskartashov at parallels.com>
---
Makefile | 12 +++++++-----
pie/Makefile | 12 +++++++++---
pie/pie.lds.S | 25 -------------------------
pie/pie.lds.S.in | 23 +++++++++++++++++++++++
4 files changed, 39 insertions(+), 33 deletions(-)
delete mode 100644 pie/pie.lds.S
create mode 100644 pie/pie.lds.S.in
diff --git a/Makefile b/Makefile
index fff8738..60770cd 100644
--- a/Makefile
+++ b/Makefile
@@ -22,6 +22,7 @@ NM := nm
AWK := awk
SH := bash
MAKE := make
+OBJCOPY := objcopy
# Additional ARCH settings for x86
ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
@@ -38,6 +39,7 @@ endif
ifeq ($(uname_M),x86_64)
ARCH := x86
DEFINES := -DCONFIG_X86_64
+ LDARCH := i386:x86-64
endif
SRC_DIR ?= $(shell pwd)
@@ -71,7 +73,7 @@ CFLAGS += $(WARNINGS) $(DEFINES)
SYSCALL-LIB = $(SRC_DIR)/arch/$(ARCH)/syscalls.o
PROTOBUF-LIB = $(SRC_DIR)/protobuf/protobuf-lib.o
-export E Q CC ECHO MAKE CFLAGS LIBS ARCH DEFINES MAKEFLAGS SRC_DIR SYSCALL-LIB SH ARCH_DIR
+export E Q CC ECHO MAKE CFLAGS LIBS ARCH DEFINES MAKEFLAGS SRC_DIR SYSCALL-LIB SH ARCH_DIR OBJCOPY LDARCH
PROGRAM := crtools
@@ -123,7 +125,7 @@ OBJS += cpu.o
DEPS := $(patsubst %.o,%.d,$(OBJS))
.PHONY: all zdtm test rebuild clean distclean tags cscope \
- docs help pie protobuf x86
+ docs help pie protobuf $(ARCH)
ifeq ($(GCOV),1)
%.o $(PROGRAM): override CFLAGS += --coverage
@@ -138,8 +140,8 @@ pie: protobuf $(ARCH)
protobuf:
$(Q) $(MAKE) -C protobuf/
-x86:
- $(Q) $(MAKE) -C arch/x86/
+$(ARCH):
+ $(Q) $(MAKE) -C arch/$(ARCH)/
%.o: %.c
$(E) " CC " $@
@@ -190,7 +192,7 @@ clean:
$(Q) $(RM) -rf ./test/lib/
$(Q) $(RM) -rf ./test/lib64/
$(Q) $(MAKE) -C protobuf/ clean
- $(Q) $(MAKE) -C arch/x86/ clean
+ $(Q) $(MAKE) -C arch/$(ARCH)/ clean
$(Q) $(MAKE) -C pie/ clean
$(Q) $(MAKE) -C test/zdtm cleandep
$(Q) $(MAKE) -C test/zdtm clean
diff --git a/pie/Makefile b/pie/Makefile
index 49c22d8..197ea4a 100644
--- a/pie/Makefile
+++ b/pie/Makefile
@@ -18,6 +18,11 @@ LIB-OBJS = log-simple.o blob-util-net.o $(SYSCALL-LIB)
$(PARASITE): $(LIB-OBJS) $(PASM-OBJS) $(PIELDS)
$(RESTORER): $(LIB-OBJS) $(PIELDS)
+$(PIELDS): $(PIELDS).in
+ $(E) " GEN " $@
+ $(Q) $(SH) -c "echo 'OUTPUT_ARCH($(LDARCH))' > $(PIELDS)"
+ $(Q) $(SH) -c "cat $(PIELDS).in >> $(PIELDS)"
+
blob-util-net.o: $(SRC_DIR)/util-net.c
$(E) " CC " $@
$(Q) $(CC) $(CFLAGS) $< -o $@
@@ -32,11 +37,11 @@ blob-util-net.o: $(SRC_DIR)/util-net.c
%.bin.o: %.o
$(E) " GEN " $@
- $(Q) $(LD) --oformat=elf64-x86-64 -T $(PIELDS) -o $@ $(^:$(PIELDS)=)
+ $(Q) $(LD) -T $(PIELDS) -o $@ $(^:$(PIELDS)=)
-%.bin: %.o
+%.bin: %.bin.o
$(E) " GEN " $@
- $(Q) $(LD) --oformat=binary -T $(PIELDS) -o $@ $(^:$(PIELDS)=)
+ $(Q) $(OBJCOPY) -O binary $< $@
%-blob.h: %.bin %.bin.o $(GEN-OFFSETS)
$(E) " GEN " $@
@@ -51,6 +56,7 @@ clean:
$(Q) $(RM) -f ./*.d
$(Q) $(RM) -f ./*.bin
$(Q) $(RM) -f ./*.bin.o
+ $(Q) $(RM) -f $(PIELDS)
.PHONY: clean pie
.SECONDARY:
diff --git a/pie/pie.lds.S b/pie/pie.lds.S
deleted file mode 100644
index 1b62941..0000000
--- a/pie/pie.lds.S
+++ /dev/null
@@ -1,25 +0,0 @@
-OUTPUT_ARCH(i386:x86-64)
-
-SECTIONS
-{
- .crblob 0x0 : {
- *(.head.text)
- *(.text*)
- . = ALIGN(32);
- *(.data*)
- . = ALIGN(32);
- *(.rodata*)
- . = ALIGN(32);
- *(.bss*)
- . = ALIGN(32);
- } =0x00000000
-
- /DISCARD/ : {
- *(.debug*)
- *(.comment*)
- *(.note*)
- *(.group*)
- *(.eh_frame*)
- *(*)
- }
-}
diff --git a/pie/pie.lds.S.in b/pie/pie.lds.S.in
new file mode 100644
index 0000000..29fef54
--- /dev/null
+++ b/pie/pie.lds.S.in
@@ -0,0 +1,23 @@
+SECTIONS
+{
+ .crblob 0x0 : {
+ *(.head.text)
+ *(.text*)
+ . = ALIGN(32);
+ *(.data*)
+ . = ALIGN(32);
+ *(.rodata*)
+ . = ALIGN(32);
+ *(.bss*)
+ . = ALIGN(32);
+ } =0x00000000
+
+ /DISCARD/ : {
+ *(.debug*)
+ *(.comment*)
+ *(.note*)
+ *(.group*)
+ *(.eh_frame*)
+ *(*)
+ }
+}
--
1.7.10.4
More information about the CRIU
mailing list