From patchwork Wed Nov 27 23:15:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brad Smith X-Patchwork-Id: 294693 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CD0A92C0082 for ; Thu, 28 Nov 2013 10:15:58 +1100 (EST) Received: from localhost ([::1]:38258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VloKp-000413-1E for incoming@patchwork.ozlabs.org; Wed, 27 Nov 2013 18:15:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VloKN-00040K-EL for qemu-devel@nongnu.org; Wed, 27 Nov 2013 18:15:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VloKH-0002tE-Hf for qemu-devel@nongnu.org; Wed, 27 Nov 2013 18:15:26 -0500 Received: from speedy.comstyle.com ([2001:470:1d:8c::2]:3291 helo=mail.comstyle.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VloKH-0002t0-DD for qemu-devel@nongnu.org; Wed, 27 Nov 2013 18:15:21 -0500 Received: from rox.home.comstyle.com (d72-39-54-224.home1.cgocable.net [72.39.54.224]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: brad) by mail.comstyle.com (Postfix) with ESMTPSA id 79EFB94833 for ; Wed, 27 Nov 2013 18:15:11 -0500 (EST) Date: Wed, 27 Nov 2013 18:15:05 -0500 From: Brad Smith To: qemu-devel@nongnu.org Message-ID: <20131127230105.GA25600@rox.home.comstyle.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.22 (2013-10-16) X-comstyle-MailScanner-Information: Please contact the ISP for more information X-comstyle-MailScanner-ID: 79EFB94833.ABCE1 X-comstyle-MailScanner: Found to be clean X-comstyle-MailScanner-SpamCheck: not spam (whitelisted), SpamAssassin (not cached, score=-2.9, required 6, autolearn=not spam, ALL_TRUSTED -1.00, BAYES_00 -1.90) X-comstyle-MailScanner-From: brad@comstyle.com X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:470:1d:8c::2 Subject: [Qemu-devel] [PATCH] Fix QEMU build on OpenBSD on x86 archs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This resolves the build issue with building the ROMs on OpenBSD on x86 archs. As of OpenBSD 5.3 the compiler builds PIE binaries by default and thus the whole OS/packages and so forth. The ROMs need to have PIE disabled. This is my initial attempt at trying to get somehting upstream so that QEMU both builds out of the box and to resolve the build issue with the buildbots that has been around for awhile. We have a patch in our ports tree but it is just the flags hardcoded into the Makefile which obviously is not appropriate for upstream. From the OpenBSD buildbots.. Building optionrom/multiboot.img ld: multiboot.o: relocation R_X86_64_16 can not be used when making a shared object; recompile with -fPIC Signed-off by: Brad Smith diff --git a/configure b/configure index 508f6a5..6d84885 100755 --- a/configure +++ b/configure @@ -1342,6 +1342,10 @@ EOF if compile_prog "-fPIE -DPIE" "-pie"; then QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS" LDFLAGS="-pie $LDFLAGS" + if test "$targetos" = OpenBSD; then + CC_NOPIE="-fno-pie" + LD_NOPIE="-nopie" + fi pie="yes" if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS" @@ -4307,6 +4311,8 @@ if test "$gcov" = "yes" ; then echo "CONFIG_GCOV=y" >> $config_host_mak echo "GCOV=$gcov_tool" >> $config_host_mak fi +echo "CC_NOPIE=$CC_NOPIE" >> $config_host_mak +echo "LD_NOPIE=$LD_NOPIE" >> $config_host_mak # use included Linux headers if test "$linux" = "yes" ; then diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile index 57d8bd0..0b35000 100644 --- a/pc-bios/optionrom/Makefile +++ b/pc-bios/optionrom/Makefile @@ -12,6 +12,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom) CFLAGS := -Wall -Wstrict-prototypes -Werror -fomit-frame-pointer -fno-builtin CFLAGS += -I$(SRC_PATH) CFLAGS += $(call cc-option, $(CFLAGS), -fno-stack-protector) +CFLAGS += $(CC_NOPIE) QEMU_CFLAGS = $(CFLAGS) build-all: multiboot.bin linuxboot.bin kvmvapic.bin @@ -20,7 +21,7 @@ build-all: multiboot.bin linuxboot.bin kvmvapic.bin .SECONDARY: %.img: %.o - $(call quiet-command,$(LD) -Ttext 0 -e _start -s -o $@ $<," Building $(TARGET_DIR)$@") + $(call quiet-command,$(LD) $(LD_NOPIE) -Ttext 0 -e _start -s -o $@ $<," Building $(TARGET_DIR)$@") %.raw: %.img $(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@," Building $(TARGET_DIR)$@")