On Tue, Nov 27, 2018 at 12:11:32 +0000, Alex Bennée wrote: > > Emilio G. Cota <c...@braap.org> 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 <c...@braap.org> > > As far as the configure logic is concerned: > > Reviewed-by: Alex Bennée <alex.ben...@linaro.org> > > 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