It has come to my attention that the extension modules may fail to load
when running on older host systems with older compiler/linker versions.
This is due to these crash-6.1.3 changes:
- Update of the extensions/echo.c extension module example, and the
"extend" help page, to utilize a constructor function to call the
register_extension() function. The _init() and _fini() functions
have been designated as obsolete for usage by dlopen() and dlclose().
The echo.c example module has been modified to contain echo_init()
and echo_fini() functions marked as __attribute__((constructor)) and
__attribute__((destructor)) respectively.
(anderson(a)redhat.com)
- Updated extensions/dminfo.c, extensions/snap.c and extensions/trace.c
to replace their _init() and _fini() functions with constructor and
destructor functions.
(anderson(a)redhat.com)
I made the change because the dlopen(3) man page has had this section
for quite some time now:
The obsolete symbols _init and _fini
The linker recognizes special symbols _init and _fini. If a dynamic
library exports a routine named _init, then that code is executed after
the loading, before dlopen() returns. If the dynamic library exports a
routine named _fini, then that routine is called just before the
library is unloaded. In case you need to avoid linking against the
system startup files, this can be done by giving gcc the "-nostart-
files" parameter on the command line.
Using these routines, or the gcc -nostartfiles or -nostdlib options, is
not recommended. Their use may result in undesired behavior, since the
constructor/destructor routines will not be executed (unless special
measures are taken).
Instead, libraries should export routines using the __attribute__((con-
structor)) and __attribute__((destructor)) function attributes. See
the gcc info pages for information on these. Constructor routines are
executed before dlopen() returns, and destructor routines are executed
before dlclose() returns.
But when making the change, I did not take the "recommendation" to remove
the -nostartfiles option, for a couple reasons:
(1) Because of what are now "legacy" extension modules that still use
_init() and _fini() functions. Those extension modules still
require the -nostartfiles option.
(2) It didn't make a difference on Fedora 17 systems, which is where I
did my testing.
However, I do not want to force everybody to update their extension modules.
So instead I'm going to modify the extensions/Makefile to grep the C file
for the ((constructor)) attribute, and use or not-use the -nostartfiles option
based upon that.
It should also be noted that this only applies to extension modules that
do *not* utilize their own "<module>.mk" makefile. Accordingly, I will
be
modifying the "snap.mk" file to remove the -nostartfile option, but on the
other hand, the "eppic.mk" file can remain unchanged until and unless the
owner wants to update it.
Since this is important enough, I'll come out with a crash-6.1.4 version
shortly.
Thanks,
Dave
Show replies by date