From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqI3E-0004wj-NX for qemu-devel@nongnu.org; Tue, 10 Dec 2013 02:48:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VqI3D-0004x0-CB for qemu-devel@nongnu.org; Tue, 10 Dec 2013 02:48:16 -0500 Received: from speedy.comstyle.com ([2001:470:1d:8c::2]:43396 helo=mail.comstyle.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VqI3D-0004w9-5p for qemu-devel@nongnu.org; Tue, 10 Dec 2013 02:48:15 -0500 Message-ID: <52A6C733.2030608@comstyle.com> Date: Tue, 10 Dec 2013 02:48:03 -0500 From: Brad Smith MIME-Version: 1.0 References: <20131210012628.GC28299@rox.home.comstyle.com> <52A6BDC8.1000209@weilnetz.de> In-Reply-To: <52A6BDC8.1000209@weilnetz.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] Fix QEMU build on OpenBSD on x86 archs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil , qemu-devel@nongnu.org On 10/12/13 2:07 AM, Stefan Weil wrote: > Am 10.12.2013 02:26, schrieb Brad Smith: >> 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 >> --- >> >> Changes in v2: >> * Fix '==' is not portable syntax. >> >> >> 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) > > Would it be possible to add -fno-pie unconditionally here ... > > >> 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)$@") >> > > > ... and use -nopie here? I tried it in my Linux build environment, and > it seems to work. > > Then no changes to file configure are needed. The linker flag definitely does not exist everywhere so that would break the build on other OS/toolchain combinations; for example stock binutils does not have this flag. I would not have bothered going this route if I didn't see having the flags hard coded as causing a problem. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.