From patchwork Fri Feb 26 17:08:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 8439941 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 78E139F52D for ; Fri, 26 Feb 2016 17:09:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A3EF3203C3 for ; Fri, 26 Feb 2016 17:09:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A741A203B8 for ; Fri, 26 Feb 2016 17:09:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422650AbcBZRI5 (ORCPT ); Fri, 26 Feb 2016 12:08:57 -0500 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 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 4C078C0A9CE4; Fri, 26 Feb 2016 17:08:56 +0000 (UTC) Received: from thinkpad.redhat.com (ovpn-112-33.ams2.redhat.com [10.36.112.33]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1QH8mKS012694; Fri, 26 Feb 2016 12:08:53 -0500 From: Laurent Vivier 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 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> In-Reply-To: <1456506526-10803-1-git-send-email-lvivier@redhat.com> References: <1456506526-10803-1-git-send-email-lvivier@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Andrew Jones --- 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