From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqXzI-0007Xq-Id for qemu-devel@nongnu.org; Tue, 10 Dec 2013 19:49:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VqXzG-00047Z-6t for qemu-devel@nongnu.org; Tue, 10 Dec 2013 19:49:15 -0500 Received: from speedy.comstyle.com ([2001:470:1d:8c::2]:19646 helo=mail.comstyle.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqXzF-00047R-UB for qemu-devel@nongnu.org; Tue, 10 Dec 2013 19:49:14 -0500 Received: from rox.home.comstyle.com (unknown [IPv6:2001:470:b01e:3:c895:fa7c:f3b:2862]) (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 A9769972E9 for ; Tue, 10 Dec 2013 19:49:09 -0500 (EST) Date: Tue, 10 Dec 2013 19:49:08 -0500 From: Brad Smith Message-ID: <20131211004908.GA19241@rox.home.comstyle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH v3] Fix QEMU build on OpenBSD on x86 archs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@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 --- Change in v2: * Fix '==' is not portable syntax. Change in v3: * Rename variables and use compile_prog to detect the presence of the compiler/linker flags, as suggested by Stefan Weil. diff --git a/configure b/configure index 5d82283..89ae89d 100755 --- a/configure +++ b/configure @@ -1365,6 +1365,11 @@ EOF pie="no" fi fi + + if compile_prog "-fno-pie" "-nopie"; then + CFLAGS_NOPIE="-fno-pie" + LDFLAGS_NOPIE="-nopie" + fi fi ########################################## @@ -4320,6 +4325,7 @@ echo "LD=$ld" >> $config_host_mak echo "WINDRES=$windres" >> $config_host_mak echo "LIBTOOL=$libtool" >> $config_host_mak echo "CFLAGS=$CFLAGS" >> $config_host_mak +echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak if test "$sparse" = "yes" ; then @@ -4333,6 +4339,7 @@ else echo "AUTOCONF_HOST := " >> $config_host_mak fi echo "LDFLAGS=$LDFLAGS" >> $config_host_mak +echo "LDFLAGS_NOPIE=$LDFLAGS_NOPIE" >> $config_host_mak echo "LIBTOOLFLAGS=$LIBTOOLFLAGS" >> $config_host_mak echo "LIBS+=$LIBS" >> $config_host_mak echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile index 57d8bd0..ce4852a 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 += $(CFLAGS_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) $(LDFLAGS_NOPIE) -Ttext 0 -e _start -s -o $@ $<," Building $(TARGET_DIR)$@") %.raw: %.img $(call quiet-command,$(OBJCOPY) -O binary -j .text $< $@," Building $(TARGET_DIR)$@") -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.