qemu-devel
[Top][All Lists]
Advanced

[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: Tue, 27 Nov 2018 12:08:11 -0500
User-agent: Mutt/1.9.4 (2018-02-28)

On Tue, Nov 27, 2018 at 12:11:32 +0000, Alex Bennée wrote:
> 
> Emilio G. Cota <address@hidden> writes:
> 
> > For now only add it for ELF platforms, since we rely on the linker's
> > --dynamic-list flag to pass a list of symbols to be exported to the
> > executable. An alternative would be to use -rdynamic, but that would
> > expose all of QEMU's objects to plugins.
> >
> > I have no experience with non-ELF systems but I suspect adding support
> > for those should be pretty easy.
> >
> > Signed-off-by: Emilio G. Cota <address@hidden>
> 
> As far as the configure logic is concerned:
> 
> Reviewed-by: Alex Bennée <address@hidden>
> 
> I'm not quite following what is so special about the dynamic-list
> symbols compared to the rest of the symbols in the binary. when I do
> readelf -s they are all specified as GLOBAL DEFAULT.
> 
> Perhaps this will become clearer to me once I get to the implementation
> of the plugins later in the series?

You should look at `readelf --dyn-syms's output. There you'll see
that the only defined function symbols are qemu_plugin_* ones (plus
_init and _fini).

The goal is to prevent plugins from accessing symbols outside of
the plugin API. For instance, if from plugin 'foo' I try to call
qht_init (after having added the necessary declarations in foo.c),
at dlopen time I get:
  plugin_load: libfoo.so: undefined symbol: qht_init

The alternative is to export all symbols; we can do this by
passing --export-dynamic to the linker instead of an explicit
--dynamic-list. We can then access *any* global symbol in the
QEMU executable. The previous example now works past dlopen, i.e.
I can call qht_init from my plugin:
  ERROR:/data/src/qemu/util/qht.c:401:qht_init: assertion failed: (cmp)

Thanks,

                Emilio



reply via email to

[Prev in Thread] Current Thread [Next in Thread]