From patchwork Sun Dec 9 19:37:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 10720295 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 28D3013BF for ; Sun, 9 Dec 2018 20:08:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1964A2A095 for ; Sun, 9 Dec 2018 20:08:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D8EF2A101; Sun, 9 Dec 2018 20:08:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4A3E22A095 for ; Sun, 9 Dec 2018 20:08:23 +0000 (UTC) Received: from localhost ([::1]:56548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW5NG-0002au-3Y for patchwork-qemu-devel@patchwork.kernel.org; Sun, 09 Dec 2018 15:08:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gW4uT-0001cf-Lt for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gW4uO-0006oC-EC for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:37 -0500 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:48967) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gW4uO-0005sz-1L for qemu-devel@nongnu.org; Sun, 09 Dec 2018 14:38:32 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id E88D8F8A; Sun, 9 Dec 2018 14:38:07 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Sun, 09 Dec 2018 14:38:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=mesmtp; bh=s6tY36AX5rau4107DeJnhmmCwkv2DQ3rCDGJzgycMAY=; b=k/BhhhdFYWMf KutSQhlHJd8i1NKKKrNQKAa92Hwvz0D7IGS/vGhTv6NVSjHWlQ4lGZ8sADkeEERP 67CnOCRyYyoFTOb8f+lxH8J9r21rHk8z7Xa3/GxPoZKvYe1yTEgSfEoSsdpIfRXY qRs4g+gE8SVy/ulApTZcH5GgGkyo1vg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=s6tY36AX5rau4107DeJnhmmCwkv2DQ3rCDGJzgycM AY=; b=ABZHw8rCvNdFRVHkQYSKl6GQzwTkAOVBGyyS4nhhboYdGRgBUNJUxNSbl mvA+rp5brhIuA57YFrLCZRmvsZfX47i8F0KATWyjT7NWvUmrvIFVHUtFyhED2Ofa 7PPaZT5sRslnPw39pFMWXyAPtXuF8Wm5ZgyJRo2Zo1kaN1/8ZjAzKisviAJ72eq8 m1sdE7MgWucgxT4tjBNeWk/zUa5z/P2h3eYX/ovQc3+0rx/VJBcTidrxfXyUPQYy rxQEao2ARfwfp5RrkkTQOtyndnJj/lcS2AarRozxjwMdrhUQh+FvYRvwvu8CuNz7 f8cNeJ/uW+ra/hTpZaRv3MHCBm05g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudegfedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecu fedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkf fojghfgggtgfesthekredtredtjeenucfhrhhomhepfdfgmhhilhhiohcuifdrucevohht rgdfuceotghothgrsegsrhgrrghprdhorhhgqeenucfkphepuddvkedrheelrddvtddrvd duieenucfrrghrrghmpehmrghilhhfrhhomheptghothgrsegsrhgrrghprdhorhhgnecu vehluhhsthgvrhfuihiivgepie X-ME-Proxy: Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 3752F102ED; Sun, 9 Dec 2018 14:38:07 -0500 (EST) From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Sun, 9 Dec 2018 14:37:46 -0500 Message-Id: <20181209193749.12277-36-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181209193749.12277-1-cota@braap.org> References: <20181209193749.12277-1-cota@braap.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 64.147.123.25 Subject: [Qemu-devel] [RFC v2 35/38] configure: add --enable-plugins X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= , Pavel Dovgalyuk Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add support for both ld (using --dynamic-list) and MacOSX's ld64 (-exported_symbols_list). Reviewed-by: Alex Bennée Signed-off-by: Emilio G. Cota --- configure | 82 +++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 1 + Makefile.target | 18 ++++++++++- .gitignore | 2 ++ 4 files changed, 102 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 1c473ce95b..91f9c08ae2 100755 --- a/configure +++ b/configure @@ -30,6 +30,7 @@ TMPO="${TMPDIR1}/${TMPB}.o" TMPCXX="${TMPDIR1}/${TMPB}.cxx" TMPE="${TMPDIR1}/${TMPB}.exe" TMPMO="${TMPDIR1}/${TMPB}.mo" +TMPTXT="${TMPDIR1}/${TMPB}.txt" rm -f config.log @@ -474,6 +475,7 @@ libxml2="" docker="no" debug_mutex="no" libpmem="" +plugins="no" # cross compilers defaults, can be overridden with --cross-cc-ARCH cross_cc_aarch64="aarch64-linux-gnu-gcc" @@ -1444,6 +1446,10 @@ for opt do ;; --disable-libpmem) libpmem=no ;; + --enable-plugins) plugins="yes" + ;; + --disable-plugins) plugins="no" + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1634,6 +1640,8 @@ Advanced options (experts only): xen pv domain builder --enable-debug-stack-usage track the maximum stack usage of stacks created by qemu_alloc_stack + --enable-plugins + enable plugins via shared library loading Optional features, enabled with --enable-FEATURE and disabled with --disable-FEATURE, default is enabled if available: @@ -5143,6 +5151,58 @@ if compile_prog "" "" ; then atomic64=yes fi +######################################### +# See if --dynamic-list is supported by the linker + +cat > $TMPTXT < $TMPC < +void foo(void); + +void foo(void) +{ + printf("foo\n"); +} + +int main(void) +{ + foo(); + return 0; +} +EOF + +ld_dynamic_list="no" +if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then + ld_dynamic_list="yes" +fi + +######################################### +# See if -exported_symbols_list is supported by the linker + +cat > $TMPTXT < Your SDL version is too old - please upgrade to have SDL support" @@ -6779,6 +6840,27 @@ if test "$libpmem" = "yes" ; then echo "CONFIG_LIBPMEM=y" >> $config_host_mak fi +if test "$plugins" = "yes" ; then + echo "CONFIG_PLUGIN=y" >> $config_host_mak + LIBS="-ldl $LIBS" + # Copy the export object list to the build dir + if test "$ld_dynamic_list" = "yes" ; then + echo "CONFIG_HAS_LD_DYNAMIC_LIST=yes" >> $config_host_mak + ld_symbols=qemu-plugins-ld.symbols + cp "$source_path/qemu-plugins.symbols" $ld_symbols + elif test "$ld_exported_symbols_list" = "yes" ; then + echo "CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST=yes" >> $config_host_mak + ld64_symbols=qemu-plugins-ld64.symbols + echo "# Automatically generated by configure - do not modify" > $ld64_symbols + grep 'qemu_' "$source_path/qemu-plugins.symbols" | sed 's/;//g' | \ + sed -E 's/^[[:space:]]*(.*)/_\1/' >> $ld64_symbols + else + error_exit \ + "If \$plugins=yes, either \$ld_dynamic_list or " \ + "\$ld_exported_symbols_list should have been set to 'yes'." + fi +fi + if test "$tcg_interpreter" = "yes"; then QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES" elif test "$ARCH" = "sparc64" ; then diff --git a/Makefile b/Makefile index 9cb3076d84..6fd15b296f 100644 --- a/Makefile +++ b/Makefile @@ -778,6 +778,7 @@ distclean: clean rm -f qemu-doc.fn qemu-doc.fns qemu-doc.info qemu-doc.ky qemu-doc.kys rm -f qemu-doc.log qemu-doc.pdf qemu-doc.pg qemu-doc.toc qemu-doc.tp rm -f qemu-doc.vr qemu-doc.txt + rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols rm -f config.log rm -f linux-headers/asm rm -f docs/version.texi diff --git a/Makefile.target b/Makefile.target index 75637c285c..7dada1f368 100644 --- a/Makefile.target +++ b/Makefile.target @@ -107,7 +107,23 @@ obj-y += target/$(TARGET_BASE_ARCH)/ obj-y += disas.o obj-$(call notempty,$(TARGET_XML_FILES)) += gdbstub-xml.o -obj-$(CONFIG_PLUGINS) += plugin.o +ifdef CONFIG_PLUGIN +obj-y += plugin.o +# Abuse -libs suffix to only link with --dynamic-list/-exported_symbols_list +# when the final binary includes the plugin object. +# +# Note that simply setting LDFLAGS is not enough: we build binaries that +# never link plugin.o, and the linker might fail (at least ld64 does) +# if the symbols in the list are not in the output binary. + ifdef CONFIG_HAS_LD_DYNAMIC_LIST + plugin.o-libs := -Wl,--dynamic-list=$(BUILD_DIR)/qemu-plugins-ld.symbols + else + ifdef CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST + plugin.o-libs := \ + -Wl,-exported_symbols_list,$(BUILD_DIR)/qemu-plugins-ld64.symbols + endif + endif +endif ######################################################### # Linux user emulator target diff --git a/.gitignore b/.gitignore index 64efdfd929..29f6446508 100644 --- a/.gitignore +++ b/.gitignore @@ -213,3 +213,5 @@ trace-dtrace-root.dtrace trace-ust-all.h trace-ust-all.c /target/arm/decode-sve.inc.c +qemu-plugins-ld.symbols +qemu-plugins-ld64.symbols