[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC 41/48] configure: add --enable-plugins
From: |
Emilio G. Cota |
Subject: |
Re: [Qemu-devel] [RFC 41/48] configure: add --enable-plugins |
Date: |
Wed, 28 Nov 2018 12:23:32 -0500 |
User-agent: |
Mutt/1.9.4 (2018-02-28) |
On Wed, Nov 28, 2018 at 13:43:30 +0300, Roman Bolshakov wrote:
> The test of -exported_symbols_list fails:
> Undefined symbols for architecture x86_64:
> "foo", referenced from:
> -exported_symbol[s_list] command line option
> (maybe you meant: _foo)
>
> All functions on macOS are prefixed with underscore [1]:
> "The name of a symbol representing a function that conforms to standard C
> calling conventions is the name of the function with an underscore prefix.
> Thus, the name of the symbol representing the function main would be _main."
>
> So it can be fixed by prepending foo and qemu-plugins-ld64.symbols with
> underscore:
Ah I see, thanks!
(snip)
> qemu-ga fails to link because it doesn't have symbols declared in
> qemu-plugins-ld64.symbols. Perhaps "-Wl,-exported_symbols_list" should
> be applied only to qemu-system?
I just pushed to the same github branch the appended fixup.
The idea is to only add the linker flags when the output
binary links plugin.o.
Can you please test?
Thanks,
Emilio
---
commit 8f45416b79765b66e5ce0fca7db93b97bbcfcfbb
Author: Emilio G. Cota <address@hidden>
Date: Wed Nov 28 12:11:23 2018 -0500
configure: ld64 fixup
And copy the file to the build dir also for !ld64.
Signed-off-by: Emilio G. Cota <address@hidden>
diff --git a/Makefile.target b/Makefile.target
index 719699696d..7ea17d71cb 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_PLUGINS
+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/configure b/configure
index 3dc9c9697b..395acf831e 100755
--- a/configure
+++ b/configure
@@ -5185,7 +5185,7 @@ fi
# See if -exported_symbols_list is supported by the linker
cat > $TMPTXT <<EOF
- foo
+ _foo
EOF
ld_exported_symbols_list="no"
@@ -6843,13 +6843,17 @@ fi
if test "$plugins" = "yes" ; then
echo "CONFIG_PLUGINS=y" >> $config_host_mak
LIBS="-ldl $LIBS"
+ # Copy the export object list to the build dir
if test "$ld_dynamic_list" = "yes" ; then
- LDFLAGS="-Wl,--dynamic-list=\$(SRC_PATH)/qemu-plugins.symbols $LDFLAGS"
+ 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
- cat "$source_path/qemu-plugins.symbols" | grep qemu_ | sed 's/;//g' >>
$ld64_symbols
- LDFLAGS="-Wl,-exported_symbols_list,\$(BUILD_DIR)/$ld64_symbols
$LDFLAGS"
+ grep 'qemu_' "$source_path/qemu-plugins.symbols" | sed 's/;//g' | \
+ sed -E 's/^\s*(.*)/_\1/' >> $ld64_symbols
else
error_exit \
"If \$plugins=yes, either \$ld_dynamic_list or " \
- Re: [Qemu-devel] [RFC 41/48] configure: add --enable-plugins, Alex Bennée, 2018/11/27
- Re: [Qemu-devel] [RFC 41/48] configure: add --enable-plugins, Roman Bolshakov, 2018/11/27
- Re: [Qemu-devel] [RFC 41/48] configure: add --enable-plugins, Emilio G. Cota, 2018/11/27
- Re: [Qemu-devel] [RFC 41/48] configure: add --enable-plugins, Roman Bolshakov, 2018/11/28
- Re: [Qemu-devel] [RFC 41/48] configure: add --enable-plugins,
Emilio G. Cota <=
- Re: [Qemu-devel] [RFC 41/48] configure: add --enable-plugins, Roman Bolshakov, 2018/11/29
- Re: [Qemu-devel] [RFC 41/48] configure: add --enable-plugins, Emilio G. Cota, 2018/11/29
- Re: [Qemu-devel] [RFC 41/48] configure: add --enable-plugins, Emilio G. Cota, 2018/11/29
- Re: [Qemu-devel] [RFC 41/48] configure: add --enable-plugins, Roman Bolshakov, 2018/11/29