From patchwork Fri Oct 25 06:36:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 177628 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3242381ill; Thu, 24 Oct 2019 23:50:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBZybBSlUgWufE3r5qz2dSWQnawGy1VXOmWcEms6JVZkfKyQC/DI+2QQMUA4j4xocFqaJl X-Received: by 2002:a50:9eac:: with SMTP id a41mr2144155edf.237.1571986245945; Thu, 24 Oct 2019 23:50:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571986245; cv=none; d=google.com; s=arc-20160816; b=Irjmx3N558JzSfR/a78C4FQkq9FNEkkW1PrsoiMNg8uB/Jlhpyp9+HsbUt+bvstw16 OSfD3S8aGgCouMv5N9b8FXN74+4QdzSfrvYuBmBz2lPQIWKv9Cra3XrO9scmHzMqLKji aKo6aezcj2l9pN1KCYDXsQqAbM5J0KUKH9NMZga5ndmecSU8oBVXT+PgidRyMl/ua5kb oDm08f45ujIPJvNPQhjVPILLDkZPY8zRKDMrU+2O7dWuBwKLbC7Hwo+S0akDvgrTXJGO HJFQ6A1UO+HzAjrRzPff5cB5Az156IQEG2pdD+cVObgQ33QlAK2ZZxOFARqHNczuAke+ TzXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=44V7jQqOs3ZoLqNrh7jJMlyq1xec1lAdesBPk7eaAP4=; b=HFV0hCNtY1xGG0pGPtNz77qDHX4FM6CL+LmHeVQVETJP8WA+FPgHhNdfo+JjeibUN1 lgnI5IsxwMNxptsi2ChnlyIe10i/jURhu5tkDCiEP2ds83l6JV/NtUiC5Bn7c0HpEEkf e5ja7nXWC0P3lVUWEx8k/FVl3u9HP0dGpapYDIUnd4FHQgrxZ+PVB7MjzegTlx4baGod i4BMxk/XBWmiXef7a7jv86Fyix+gAAB5HxFNywPgz3VjD/uTTUsEp5Oj2duFwQy39Z3i LlD+WorlDQktNKIRo3gFOL3KVcK8J5+w8BDG/d8qwLZM0T/HIUsnNPM8MVdB6lq7rETY mJQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=labMApue; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id i6si611306ejr.430.2019.10.24.23.50.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Oct 2019 23:50:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=labMApue; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:56060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNtQq-0005DZ-4A for patch@linaro.org; Fri, 25 Oct 2019 02:50:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35530) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNtE1-0003Hq-3k for qemu-devel@nongnu.org; Fri, 25 Oct 2019 02:37:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNtDz-0008QK-0K for qemu-devel@nongnu.org; Fri, 25 Oct 2019 02:37:29 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:33275) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNtDy-0008Q5-PR for qemu-devel@nongnu.org; Fri, 25 Oct 2019 02:37:26 -0400 Received: by mail-wm1-x334.google.com with SMTP id 6so3526459wmf.0 for ; Thu, 24 Oct 2019 23:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=44V7jQqOs3ZoLqNrh7jJMlyq1xec1lAdesBPk7eaAP4=; b=labMApuedQHad2h2Hq2Hy+SJhDAUXrp9o0fLu4a67lYCUd3WLNBaVQQ3D8mjKZM9J9 pJAbvSFkPvu4l8c9i24yRHhDePn44MuNVt4Z5YD9Z3vphr8UugLgvbkgDdlt/CC3g/LQ /Q8bj+aDVRyXjX78sgOGCoCLtBfIXUqFmB14sNSsuLeGwT8Cm6IiHCUJv9WNFKGzx6Ho Kx/5qz+4OA2FnVNuEEIVZMy75rirKOu8g6hFBpOxuyXJjLviWZGuDfa3uqwYg9eZmKt5 /C6Xc+zUGYM3SKvKmYWrAUC8XeUN4toof2oIZi8V4HYTjgGeA8WajW16LqSivtktKb+g fqnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=44V7jQqOs3ZoLqNrh7jJMlyq1xec1lAdesBPk7eaAP4=; b=HuFSPL13rLz/S7hKuHTD5tCpYbCaTPxilLl7VXM3nPNpOISnMUAwvRNOrrpuimA7RE MXRMsPJH6EbfhdRG6DTqMa8wgX3xG2W/Wrs7dpzoYlzalU1kDJns7wzj05Yohk501kMt Dhf30ik92iXAPUd5oza8hT8aYXhHcTE4NmtpE+PMMFFBZHJRwtIYNaos1ggHr5GpbvM5 Hy8xGiERPoM6SJxfK1XJ2fZJMT9BAoPDwaNMi6i8QGmBTz5KUiS1q/eVV8krTKaB/QLl Vyx7BZ9nppHWxOiCvCMeXl3cauNtSGLlYjjXb4rHgClTiBY5OUCLDxnTNWsKEXcGjGSE is6Q== X-Gm-Message-State: APjAAAVTX+C1L9zh7KH2g6AuWxOcMYhlwOXZ3bpl5QiDvDH4e0Kosdqy QKyq2sKXx5WRmQr7LRBz3RlDRw== X-Received: by 2002:a05:600c:2487:: with SMTP id 7mr1823283wms.164.1571985445608; Thu, 24 Oct 2019 23:37:25 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id q25sm2598951wra.3.2019.10.24.23.37.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Oct 2019 23:37:24 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AE4101FFCC; Fri, 25 Oct 2019 07:37:18 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL v2 53/73] plugin: add API symbols to qemu-plugins.symbols Date: Fri, 25 Oct 2019 07:36:53 +0100 Message-Id: <20191025063713.23374-54-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191025063713.23374-1-alex.bennee@linaro.org> References: <20191025063713.23374-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::334 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , "Emilio G. Cota" , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: "Emilio G. Cota" Signed-off-by: Emilio G. Cota [AJB: moved into plugins] Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson -- 2.20.1 diff --git a/Makefile b/Makefile index 94d25185511..bd6376d295f 100644 --- a/Makefile +++ b/Makefile @@ -74,6 +74,12 @@ CONFIG_ALL=y config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION @echo $@ is out-of-date, running configure @./config.status + +# Force configure to re-run if the API symbols are updated +ifeq ($(CONFIG_PLUGIN),y) +config-host.mak: $(SRC_PATH)/plugins/qemu-plugins.symbols +endif + else config-host.mak: ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail)) @@ -737,6 +743,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/configure b/configure index 2995559ed21..eabe84af6ed 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 @@ -5476,6 +5477,61 @@ if compile_prog "" "" ; then atomic64=yes fi +######################################### +# See if --dynamic-list is supported by the linker +ld_dynamic_list="no" +if test "$static" = "no" ; then + cat > $TMPTXT < $TMPC < +void foo(void); + +void foo(void) +{ + printf("foo\n"); +} + +int main(void) +{ + foo(); + return 0; +} +EOF + + if compile_prog "" "-Wl,--dynamic-list=$TMPTXT" ; then + ld_dynamic_list="yes" + fi +fi + +######################################### +# See if -exported_symbols_list is supported by the linker + +ld_exported_symbols_list="no" +if test "$static" = "no" ; then + cat > $TMPTXT <> $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/plugins/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/plugins/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 diff --git a/plugins/.gitignore b/plugins/.gitignore new file mode 100644 index 00000000000..7b8aaa1f109 --- /dev/null +++ b/plugins/.gitignore @@ -0,0 +1,2 @@ +qemu-plugins-ld.symbols +qemu-plugins-ld64.symbols diff --git a/plugins/Makefile.objs b/plugins/Makefile.objs index 95baabf3d2f..6f14d91ccb9 100644 --- a/plugins/Makefile.objs +++ b/plugins/Makefile.objs @@ -5,3 +5,17 @@ obj-y += loader.o obj-y += core.o obj-y += api.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 +api.o-libs := -Wl,--dynamic-list=$(BUILD_DIR)/qemu-plugins-ld.symbols +else +ifdef CONFIG_HAS_LD_EXPORTED_SYMBOLS_LIST +api.o-libs := -Wl,-exported_symbols_list,$(BUILD_DIR)/qemu-plugins-ld64.symbols +endif +endif diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols new file mode 100644 index 00000000000..40c0d1abd2f --- /dev/null +++ b/plugins/qemu-plugins.symbols @@ -0,0 +1,38 @@ +{ + qemu_plugin_uninstall; + qemu_plugin_reset; + qemu_plugin_register_vcpu_init_cb; + qemu_plugin_register_vcpu_exit_cb; + qemu_plugin_register_vcpu_idle_cb; + qemu_plugin_register_vcpu_resume_cb; + qemu_plugin_register_vcpu_insn_exec_cb; + qemu_plugin_register_vcpu_insn_exec_inline; + qemu_plugin_register_vcpu_mem_cb; + qemu_plugin_register_vcpu_mem_haddr_cb; + qemu_plugin_register_vcpu_mem_inline; + qemu_plugin_ram_addr_from_host; + qemu_plugin_register_vcpu_tb_trans_cb; + qemu_plugin_register_vcpu_tb_exec_cb; + qemu_plugin_register_vcpu_tb_exec_inline; + qemu_plugin_register_flush_cb; + qemu_plugin_register_vcpu_syscall_cb; + qemu_plugin_register_vcpu_syscall_ret_cb; + qemu_plugin_register_atexit_cb; + qemu_plugin_tb_n_insns; + qemu_plugin_tb_get_insn; + qemu_plugin_tb_vaddr; + qemu_plugin_insn_data; + qemu_plugin_insn_size; + qemu_plugin_insn_vaddr; + qemu_plugin_insn_haddr; + qemu_plugin_mem_size_shift; + qemu_plugin_mem_is_sign_extended; + qemu_plugin_mem_is_big_endian; + qemu_plugin_mem_is_store; + qemu_plugin_get_hwaddr; + qemu_plugin_hwaddr_is_io; + qemu_plugin_hwaddr_to_raddr; + qemu_plugin_vcpu_for_each; + qemu_plugin_n_vcpus; + qemu_plugin_n_max_vcpus; +};