From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Miv3i-00011o-Ts for qemu-devel@nongnu.org; Wed, 02 Sep 2009 14:59:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Miv3c-0000xa-Sk for qemu-devel@nongnu.org; Wed, 02 Sep 2009 14:59:52 -0400 Received: from [199.232.76.173] (port=33193 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Miv3c-0000xQ-P0 for qemu-devel@nongnu.org; Wed, 02 Sep 2009 14:59:48 -0400 Received: from mail-bw0-f227.google.com ([209.85.218.227]:46050) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Miv3c-0006BD-96 for qemu-devel@nongnu.org; Wed, 02 Sep 2009 14:59:48 -0400 Received: by bwz27 with SMTP id 27so1087074bwz.34 for ; Wed, 02 Sep 2009 11:59:47 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <1251904883-13706-1-git-send-email-kirill@shutemov.name> <1251904883-13706-2-git-send-email-kirill@shutemov.name> Date: Wed, 2 Sep 2009 21:59:46 +0300 Message-ID: From: "Kirill A. Shutemov" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: [PATCH 2/2] Build *-user targets as PIE List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Juan Quintela Cc: qemu-devel@nongnu.org On Wed, Sep 2, 2009 at 8:34 PM, Juan Quintela wrote: > "Kirill A. Shutemov" wrote: >> Now we can drop link hack for i386 and fix text relocations on i386 host= . >> >> Signed-off-by: Kirill A. Shutemov > > Some comments. > > This patch moves files from being compiled only once (in Makefile), > to be compiled for aech target. > >> --- >> =C2=A0Makefile =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A0 10 +--------- >> =C2=A0Makefile.target =C2=A0 | =C2=A0 19 +++++++++++++++---- >> =C2=A0configure =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 17 ++++++----------= - >> =C2=A0linux-user/main.c | =C2=A0 20 -------------------- >> =C2=A04 files changed, 22 insertions(+), 44 deletions(-) >> >> diff --git a/Makefile b/Makefile >> index bdac9b3..634ea81 100644 >> --- a/Makefile >> +++ b/Makefile >> @@ -39,8 +39,6 @@ subdir-%: >> =C2=A0 =C2=A0 =C2=A0 $(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C= $* V=3D"$(V)" TARGET_DIR=3D"$*/" all,) >> >> =C2=A0$(filter %-softmmu,$(SUBDIR_RULES)): libqemu_common.a >> -$(filter %-user,$(SUBDIR_RULES)): libqemu_user.a >> - >> >> =C2=A0ROMSUBDIR_RULES=3D$(patsubst %,romsubdir-%, $(ROMS)) >> =C2=A0romsubdir-%: >> @@ -74,7 +72,7 @@ block-obj-y +=3D =C2=A0$(addprefix block/, $(block-nes= ted-y)) >> =C2=A0# CPUs and machines. >> >> =C2=A0obj-y =3D $(block-obj-y) >> -obj-y +=3D readline.o console.no host-utils.o >> +obj-y +=3D readline.o console.o > > What is the problem here? libqemu_common.o is not used for *-user targets= ? No. We need all object files for *-user built with -fpie. For softmmu they build without it. >> >> +ifdef CONFIG_USER_ONLY >> +# hack to compile with -fpie for *-user targets >> +obj-y +=3D cutils-user.o cache-utils-user.o >> +cutils-user.c cache-utils-user.c: >> + =C2=A0 =C2=A0 @echo " =C2=A0LN =C2=A0 =C2=A0 $(TARGET_DIR)$@" >> + =C2=A0 =C2=A0 @ln -s $(SRC_PATH)/$(@:%-user.c=3D%.c) $@ >> +endif > > Why is this needed? =C2=A0Why cutils.o/cache-utils.o is not enough? > > I thought that: > > obj-$(CONFIG_USER_ONLY) +=3D cutils.o cache-utils.o > > should be enough here. =C2=A0Why is needed the link? We need to build it with -fpie. Without symlink it will be linked with cutils.o and cache-utils.o which was built for softmmu without -fpie and we will get tex= t relocation in executable.