Commit 8863d8dd authored by Alexander Kartashov's avatar Alexander Kartashov Committed by Pavel Emelyanov

multiarch: introduced the multiarch support into the build system.

* 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: 's avatarAlexander Kartashov <alekskartashov@parallels.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 6f61488f
...@@ -22,6 +22,7 @@ NM := nm ...@@ -22,6 +22,7 @@ NM := nm
AWK := awk AWK := awk
SH := sh SH := sh
MAKE := make MAKE := make
OBJCOPY := objcopy
# Additional ARCH settings for x86 # Additional ARCH settings for x86
ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
...@@ -38,6 +39,7 @@ endif ...@@ -38,6 +39,7 @@ endif
ifeq ($(uname_M),x86_64) ifeq ($(uname_M),x86_64)
ARCH := x86 ARCH := x86
DEFINES := -DCONFIG_X86_64 DEFINES := -DCONFIG_X86_64
LDARCH := i386:x86-64
endif endif
SRC_DIR ?= $(shell pwd) SRC_DIR ?= $(shell pwd)
...@@ -71,7 +73,7 @@ CFLAGS += $(WARNINGS) $(DEFINES) ...@@ -71,7 +73,7 @@ CFLAGS += $(WARNINGS) $(DEFINES)
SYSCALL-LIB = $(SRC_DIR)/arch/$(ARCH)/syscalls.o SYSCALL-LIB = $(SRC_DIR)/arch/$(ARCH)/syscalls.o
PROTOBUF-LIB = $(SRC_DIR)/protobuf/protobuf-lib.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 PROGRAM := crtools
...@@ -123,7 +125,7 @@ OBJS += cpu.o ...@@ -123,7 +125,7 @@ OBJS += cpu.o
DEPS := $(patsubst %.o,%.d,$(OBJS)) DEPS := $(patsubst %.o,%.d,$(OBJS))
.PHONY: all zdtm test rebuild clean distclean tags cscope \ .PHONY: all zdtm test rebuild clean distclean tags cscope \
docs help pie protobuf x86 docs help pie protobuf $(ARCH)
ifeq ($(GCOV),1) ifeq ($(GCOV),1)
%.o $(PROGRAM): override CFLAGS += --coverage %.o $(PROGRAM): override CFLAGS += --coverage
...@@ -138,8 +140,8 @@ pie: protobuf $(ARCH) ...@@ -138,8 +140,8 @@ pie: protobuf $(ARCH)
protobuf: protobuf:
$(Q) $(MAKE) -C protobuf/ $(Q) $(MAKE) -C protobuf/
x86: $(ARCH):
$(Q) $(MAKE) -C arch/x86/ $(Q) $(MAKE) -C arch/$(ARCH)/
%.o: %.c %.o: %.c
$(E) " CC " $@ $(E) " CC " $@
...@@ -188,7 +190,7 @@ clean: ...@@ -188,7 +190,7 @@ clean:
$(Q) $(RM) -f ./*.gcov ./*.gcda ./*.gcno $(Q) $(RM) -f ./*.gcov ./*.gcda ./*.gcno
$(Q) $(RM) -rf ./gcov $(Q) $(RM) -rf ./gcov
$(Q) $(MAKE) -C protobuf/ clean $(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 pie/ clean
$(Q) $(MAKE) -C test/zdtm cleandep $(Q) $(MAKE) -C test/zdtm cleandep
$(Q) $(MAKE) -C test/zdtm clean $(Q) $(MAKE) -C test/zdtm clean
......
...@@ -18,6 +18,11 @@ LIB-OBJS = log-simple.o blob-util-net.o $(SYSCALL-LIB) ...@@ -18,6 +18,11 @@ LIB-OBJS = log-simple.o blob-util-net.o $(SYSCALL-LIB)
$(PARASITE): $(LIB-OBJS) $(PASM-OBJS) $(PIELDS) $(PARASITE): $(LIB-OBJS) $(PASM-OBJS) $(PIELDS)
$(RESTORER): $(LIB-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 blob-util-net.o: $(SRC_DIR)/util-net.c
$(E) " CC " $@ $(E) " CC " $@
$(Q) $(CC) $(CFLAGS) $< -o $@ $(Q) $(CC) $(CFLAGS) $< -o $@
...@@ -32,11 +37,11 @@ blob-util-net.o: $(SRC_DIR)/util-net.c ...@@ -32,11 +37,11 @@ blob-util-net.o: $(SRC_DIR)/util-net.c
%.bin.o: %.o %.bin.o: %.o
$(E) " GEN " $@ $(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 " $@ $(E) " GEN " $@
$(Q) $(LD) --oformat=binary -T $(PIELDS) -o $@ $(^:$(PIELDS)=) $(Q) $(OBJCOPY) -O binary $< $@
%-blob.h: %.bin %.bin.o $(GEN-OFFSETS) %-blob.h: %.bin %.bin.o $(GEN-OFFSETS)
$(E) " GEN " $@ $(E) " GEN " $@
...@@ -51,6 +56,7 @@ clean: ...@@ -51,6 +56,7 @@ clean:
$(Q) $(RM) -f ./*.d $(Q) $(RM) -f ./*.d
$(Q) $(RM) -f ./*.bin $(Q) $(RM) -f ./*.bin
$(Q) $(RM) -f ./*.bin.o $(Q) $(RM) -f ./*.bin.o
$(Q) $(RM) -f $(PIELDS)
.PHONY: clean pie .PHONY: clean pie
.SECONDARY: .SECONDARY:
OUTPUT_ARCH(i386:x86-64)
SECTIONS SECTIONS
{ {
.crblob 0x0 : { .crblob 0x0 : {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment