From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUcGi-0004Ge-4a for qemu-devel@nongnu.org; Wed, 26 Aug 2015 11:05:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZUcGc-0002UT-5L for qemu-devel@nongnu.org; Wed, 26 Aug 2015 11:05:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56005) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZUcGc-0002UM-1R for qemu-devel@nongnu.org; Wed, 26 Aug 2015 11:05:34 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id A73F18E379 for ; Wed, 26 Aug 2015 15:05:33 +0000 (UTC) From: "Daniel P. Berrange" Date: Wed, 26 Aug 2015 16:05:17 +0100 Message-Id: <1440601524-30316-3-git-send-email-berrange@redhat.com> In-Reply-To: <1440601524-30316-1-git-send-email-berrange@redhat.com> References: <1440601524-30316-1-git-send-email-berrange@redhat.com> Subject: [Qemu-devel] [PATCH v5 2/9] make: ensure all members of libqemuutil.a are linked List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Gerd Hoffmann The libqemuutil.a archive may contain QOM objects which are only indirectly referenced via __attribute__((constructor)) annotations. Despite the constructor annotation the linker will think these objects are unused by the executable and so drop them when linking, to the system emulator. As a result the objects in question will be missing from QOM. Using the -Wl,--whole-archive flag instructs the linker to pull in everything in libqemuutil.a regardless of whether it thinks it is used or not. Signed-off-by: Daniel P. Berrange --- Makefile.target | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile.target b/Makefile.target index 3e7aafd..5b08f0f 100644 --- a/Makefile.target +++ b/Makefile.target @@ -180,8 +180,13 @@ all-obj-$(CONFIG_SOFTMMU) += $(block-obj-y) $(QEMU_PROG_BUILD): config-devices.mak # build either PROG or PROGW +# We must use --whole-archive with libqemuutil.a otherwise the +# linker will drop any objects from the archive which are only +# indirectly referenced via __attribute__(constructor) annotations $(QEMU_PROG_BUILD): $(all-obj-y) ../libqemuutil.a ../libqemustub.a - $(call LINK, $(filter-out %.mak, $^)) + $(call LINK, $(filter-out %.mak, $(sort $(all-obj-y)))) \ + -Wl,--whole-archive ../libqemuutil.a -Wl,--no-whole-archive \ + ../libqemustub.a ifdef CONFIG_DARWIN $(call quiet-command,Rez -append $(SRC_PATH)/pc-bios/qemu.rsrc -o $@," REZ $(TARGET_DIR)$@") $(call quiet-command,SetFile -a C $@," SETFILE $(TARGET_DIR)$@") -- 2.4.3