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
AWK := awk
SH := sh
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 " $@
......@@ -188,7 +190,7 @@ clean:
$(Q) $(RM) -f ./*.gcov ./*.gcda ./*.gcno
$(Q) $(RM) -rf ./gcov
$(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
......
......@@ -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:
OUTPUT_ARCH(i386:x86-64)
SECTIONS
{
.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