Le 05/06/2013 05:38, Jeff Squyres (jsquyres) a écrit :
> On Jun 4, 2013, at 9:55 AM, Brice Goglin <Brice.Goglin_at_[hidden]> wrote:
>>> One option might be to try to lt_dlsym one of the hwloc symbols that you know you'll need in the plugin (or any public hwloc symbol, for that matter). If ltdl_sym gets NULL back for the hwloc global symbol, then the plugin should disqualify itself and have itself unloaded (perhaps with some way of reporting what/why it did that).
>> lt_dlsym doesn't seem to accept special handles such as RTLD_DEFAULT
>> like dlsym does, and we don't have a handle on hwloc. I don't see how to
>> do that with lt_dlsym?
> Can we lt_dlopen(NULL) to get a handle to this process?
Yeah that works! OpenCL doesn't crashes anymore, and normal programs
seem to still load plugins fine.
For the record, we'll have to link plugins with -lltdl and add the
handle = lt_dlopen(NULL);
sym = lt_dlsym(handle, "hwloc_backend_alloc");
Components have an instantiate() callback that is always called first,
so this code could go there. The XML libxml plugin is different, there
are 3 possible entry points (backend init, export_xml and
export_xmlbuffer). So the above code would be needed in all of them (we
don't have a global plugin init() function, everything is in a struct).
This code has to be in the plugin for real, it obviously cannot be
shared in the hwloc core, but putting it in a static inline in
hwloc/plugins.h may still be OK?