Re: [RFC] Module API Introspection

From: Date: Fri, 24 Jan 2014 15:07:53 +0000
Subject: Re: [RFC] Module API Introspection
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-71507@lists.php.net to get a copy of this message
Hi, On Fri, 2014-01-24 at 15:29 +0100, Julien Pauli wrote: > > I don't have a better idea than something like a shell script doing > > strings xdebug.so | grep API -- which obviously is no good > > idea > > either, but maybe somebody is smarter than me. > > That's what we ended telling to attendees : we have no way in PHP > actually to check the API of an extension, except by trying to load > it. Trying to load it will actually tell the user *exactly* the same as this new option, it will either * load it successfully, * report PHP's and the extensions API numbers or * result in a symbol lookup error Contrary to the patch loading it will mind php.ini's extension dir. Right now php --modinfo=foo.so and php -m -dextension=foo.so will load different files (--modinfo's behavior can be seen as correct, but this difference is confusing) > However, GNU tools playing with ELF format are a global Unix solution > working, but not coming from PHP obviously. > > The only safe thing we could do, is wrapping libelf and play with it. > Somehow dirty and adds a new dependency :-p Another crazy idea I just had was along those lines: #define ZEND_GET_MODULE(name) \ BEGIN_EXTERN_C()\ ZEND_DLEXPORT zend_module_entry *get_module(void) { return &name##_module_entry; }\ + ZEND_DLEXPORT int this_extension_was_compiled_for_ ## PHP_VERSION() {return 1;} \ END_EXTERN_C() and then a shell script greping "this_extension_was_compiled_for" in the ldd output. This exact patch obviously won't work (PHP define in zend header, points in C function name, ...) but maybe somebody has more creativity for that. johannes

« previous php.internals (#71507) next »