From mboxrd@z Thu Jan 1 00:00:00 1970 From: Laurent Vivier Subject: [kvm-unit-tests PATCH v2 1/2] powerpc: allow to build big-endian binaries on little-endian host Date: Fri, 26 Feb 2016 18:08:45 +0100 Message-ID: <1456506526-10803-2-git-send-email-lvivier@redhat.com> References: <1456506526-10803-1-git-send-email-lvivier@redhat.com> Cc: drjones@redhat.com, thuth@redhat.com, dgibson@redhat.com, agraf@suse.de, pbonzini@redhat.com, Laurent Vivier To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:45205 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933770AbcBZRI4 (ORCPT ); Fri, 26 Feb 2016 12:08:56 -0500 In-Reply-To: <1456506526-10803-1-git-send-email-lvivier@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: boot_rom will be always big endian (like SLOF is). Make the endianness of the test files configurable with arch_CFLAGS and arch_LDFLAGS. For the moment, this only works with big endian. Of course, once build on a little endian host, these binaries can be used on the little endian host to test the big endian mode of KVM. Signed-off-by: Laurent Vivier --- configure | 2 +- powerpc/Makefile.common | 13 ++++++------- powerpc/Makefile.ppc64 | 3 +++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/configure b/configure index 7d5702e..a685cca 100755 --- a/configure +++ b/configure @@ -7,7 +7,7 @@ ld=ld objcopy=objcopy objdump=objdump ar=ar -arch=`uname -m | sed -e s/i.86/i386/ | sed -e 's/arm.*/arm/'` +arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/'` host=$arch cross_prefix= diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common index cad728e..cc27ac8 100644 --- a/powerpc/Makefile.common +++ b/powerpc/Makefile.common @@ -11,6 +11,7 @@ all: $(TEST_DIR)/boot_rom.bin test_cases ################################################################## +CFLAGS += $(arch_CFLAGS) CFLAGS += -std=gnu99 CFLAGS += -ffreestanding CFLAGS += -Wextra @@ -30,13 +31,11 @@ cflatobjs += lib/powerpc/hcall.o cflatobjs += lib/powerpc/setup.o cflatobjs += lib/powerpc/rtas.o -libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name) - -FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc) -%.elf: LDFLAGS = $(CFLAGS) -nostdlib -pie +FLATLIBS = $(libcflat) $(LIBFDT_archive) +%.elf: LDFLAGS = $(arch_LDFLAGS) -nostdlib -pie %.elf: %.o $(FLATLIBS) powerpc/flat.lds - $(CC) $(LDFLAGS) -o $@ \ - -Wl,-T,powerpc/flat.lds,--build-id=none \ + $(LD) $(LDFLAGS) -o $@ \ + -T powerpc/flat.lds --build-id=none \ $(filter %.o, $^) $(FLATLIBS) @echo -n Checking $@ for unsupported reloc types... @if $(OBJDUMP) -R $@ | grep R_ | grep -v R_PPC64_RELATIVE; then \ @@ -50,7 +49,7 @@ $(TEST_DIR)/boot_rom.bin: $(TEST_DIR)/boot_rom.elf $(OBJCOPY) -O binary $^ >(cat - >>$@) $(TEST_DIR)/boot_rom.elf: $(TEST_DIR)/boot_rom.o - $(LD) -nostdlib -Ttext=0x100 --entry=start --build-id=none -o $@ $< + $(LD) -EB -nostdlib -Ttext=0x100 --entry=start --build-id=none -o $@ $< powerpc_clean: libfdt_clean asm_offsets_clean $(RM) $(TEST_DIR)/*.{o,elf} $(TEST_DIR)/boot_rom.bin \ diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64 index 899dd5e..1cf277e 100644 --- a/powerpc/Makefile.ppc64 +++ b/powerpc/Makefile.ppc64 @@ -6,6 +6,9 @@ bits = 64 ldarch = elf64-powerpc +arch_CFLAGS = -mbig-endian +arch_LDFLAGS = -EB + cstart.o = $(TEST_DIR)/cstart64.o reloc.o = $(TEST_DIR)/reloc64.o cflatobjs += lib/ppc64/spinlock.o -- 2.5.0 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Laurent Vivier Date: Fri, 26 Feb 2016 17:08:45 +0000 Subject: [kvm-unit-tests PATCH v2 1/2] powerpc: allow to build big-endian binaries on little-endian host Message-Id: <1456506526-10803-2-git-send-email-lvivier@redhat.com> List-Id: References: <1456506526-10803-1-git-send-email-lvivier@redhat.com> In-Reply-To: <1456506526-10803-1-git-send-email-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org Cc: drjones@redhat.com, thuth@redhat.com, dgibson@redhat.com, agraf@suse.de, pbonzini@redhat.com, Laurent Vivier boot_rom will be always big endian (like SLOF is). Make the endianness of the test files configurable with arch_CFLAGS and arch_LDFLAGS. For the moment, this only works with big endian. Of course, once build on a little endian host, these binaries can be used on the little endian host to test the big endian mode of KVM. Signed-off-by: Laurent Vivier --- configure | 2 +- powerpc/Makefile.common | 13 ++++++------- powerpc/Makefile.ppc64 | 3 +++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/configure b/configure index 7d5702e..a685cca 100755 --- a/configure +++ b/configure @@ -7,7 +7,7 @@ ld=ld objcopy=objcopy objdump=objdump ar=ar -arch=`uname -m | sed -e s/i.86/i386/ | sed -e 's/arm.*/arm/'` +arch=`uname -m | sed -e 's/i.86/i386/;s/arm.*/arm/;s/ppc64.*/ppc64/'` host=$arch cross_prefix diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common index cad728e..cc27ac8 100644 --- a/powerpc/Makefile.common +++ b/powerpc/Makefile.common @@ -11,6 +11,7 @@ all: $(TEST_DIR)/boot_rom.bin test_cases ################################################################## +CFLAGS += $(arch_CFLAGS) CFLAGS += -std=gnu99 CFLAGS += -ffreestanding CFLAGS += -Wextra @@ -30,13 +31,11 @@ cflatobjs += lib/powerpc/hcall.o cflatobjs += lib/powerpc/setup.o cflatobjs += lib/powerpc/rtas.o -libgcc := $(shell $(CC) $(machine) --print-libgcc-file-name) - -FLATLIBS = $(libcflat) $(LIBFDT_archive) $(libgcc) -%.elf: LDFLAGS = $(CFLAGS) -nostdlib -pie +FLATLIBS = $(libcflat) $(LIBFDT_archive) +%.elf: LDFLAGS = $(arch_LDFLAGS) -nostdlib -pie %.elf: %.o $(FLATLIBS) powerpc/flat.lds - $(CC) $(LDFLAGS) -o $@ \ - -Wl,-T,powerpc/flat.lds,--build-id=none \ + $(LD) $(LDFLAGS) -o $@ \ + -T powerpc/flat.lds --build-id=none \ $(filter %.o, $^) $(FLATLIBS) @echo -n Checking $@ for unsupported reloc types... @if $(OBJDUMP) -R $@ | grep R_ | grep -v R_PPC64_RELATIVE; then \ @@ -50,7 +49,7 @@ $(TEST_DIR)/boot_rom.bin: $(TEST_DIR)/boot_rom.elf $(OBJCOPY) -O binary $^ >(cat - >>$@) $(TEST_DIR)/boot_rom.elf: $(TEST_DIR)/boot_rom.o - $(LD) -nostdlib -Ttext=0x100 --entry=start --build-id=none -o $@ $< + $(LD) -EB -nostdlib -Ttext=0x100 --entry=start --build-id=none -o $@ $< powerpc_clean: libfdt_clean asm_offsets_clean $(RM) $(TEST_DIR)/*.{o,elf} $(TEST_DIR)/boot_rom.bin \ diff --git a/powerpc/Makefile.ppc64 b/powerpc/Makefile.ppc64 index 899dd5e..1cf277e 100644 --- a/powerpc/Makefile.ppc64 +++ b/powerpc/Makefile.ppc64 @@ -6,6 +6,9 @@ bits = 64 ldarch = elf64-powerpc +arch_CFLAGS = -mbig-endian +arch_LDFLAGS = -EB + cstart.o = $(TEST_DIR)/cstart64.o reloc.o = $(TEST_DIR)/reloc64.o cflatobjs += lib/ppc64/spinlock.o -- 2.5.0