From patchwork Fri May 27 13:38:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Richard W.M. Jones" X-Patchwork-Id: 627196 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rGSYR04Wlz9sf9 for ; Sat, 28 May 2016 00:08:59 +1000 (AEST) Received: from localhost ([::1]:46108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6IRc-0006v8-Lz for incoming@patchwork.ozlabs.org; Fri, 27 May 2016 10:08:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6Hyj-0002zx-1l for qemu-devel@nongnu.org; Fri, 27 May 2016 09:39:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6Hye-0003ge-Qq for qemu-devel@nongnu.org; Fri, 27 May 2016 09:39:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51779) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6Hye-0003gY-Kx for qemu-devel@nongnu.org; Fri, 27 May 2016 09:39:00 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 163FA81103; Fri, 27 May 2016 13:39:00 +0000 (UTC) Received: from localhost (ovpn-204-136.brq.redhat.com [10.40.204.136]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u4RDcw3W015610; Fri, 27 May 2016 09:38:59 -0400 Date: Fri, 27 May 2016 14:38:58 +0100 From: "Richard W.M. Jones" To: Peter Maydell Message-ID: <20160527133858.GR1683@redhat.com> References: <1464343604-517-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-12-10) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 27 May 2016 13:39:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-devel] [PULL 00/31] Misc changes for 2016-05-27 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Marc =?iso-8859-1?Q?Mar=ED?= , QEMU Developers Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" On Fri, May 27, 2016 at 02:04:52PM +0100, Peter Maydell wrote: > With V=1: > > i686-w64-mingw32-ld -m i386pe -Ttext 0 -e _start -s -o > linuxboot_dma.img linuxboot_dma.o > linuxboot_dma.o:linuxboot_dma.c:(.text+0x57): undefined reference to > `load_kernel' > > Building an image for the target using our host compiler seems like > an odd choice, Which compiler should I be using? > but the makefile obviously intends to support it > since it has specific ifdef CONFIG_WIN32 code to adjust the linker > command line. > > I suspect this is a mismatch between the symbol the native asm is > using and the one that the C compiler wants: > > $ nm build/w32-new/pc-bios/optionrom/linuxboot_dma.o |grep load_kernel > 000005dd T _load_kernel > U load_kernel > > since name mangling rules are different for Linux and Windows ABIs. One way to solve this (which works for me) is as below. There are some other approaches, eg. using -fno-leading-underscore, or using a conditional macro to mangle the name. However I have no idea if there is some preferred way. Rich. diff --git a/pc-bios/optionrom/linuxboot_dma.c b/pc-bios/optionrom/linuxboot_dma.c index 86ef1ce..8509b28 100644 --- a/pc-bios/optionrom/linuxboot_dma.c +++ b/pc-bios/optionrom/linuxboot_dma.c @@ -213,6 +213,9 @@ static uint32_t get_e801_addr(void) return ret; } +/* Force the asm name without leading underscore, even on Win32. */ +extern void load_kernel(void) asm("load_kernel"); + void load_kernel(void) { void *setup_addr;