elf: Support __constructor and __destructor
authorMatt Fleming <matt.fleming@intel.com>
Thu, 22 Mar 2012 15:31:43 +0000 (15:31 +0000)
committerMatt Fleming <matt.fleming@intel.com>
Fri, 23 Mar 2012 16:54:47 +0000 (16:54 +0000)
commit8e0ed96bff75801f7430da88d83ea1b52827b123
tree8435f50b9a37407b3591576636d285f012cd39ee
parenta0ff1769893dc47028694ee51824bf681672876c
elf: Support __constructor and __destructor

The old way of specifying functions that need to be run before/after a
main function has never worked for ELF modules. Instead, the only way
to get similiar behaviour was by using the MODULE_INIT() and
MODULE_EXIT() macros, but no one seems to have bothered converting the
old __constructor users over. Anyway, the old way is superior because
it allows multiple functions be specified. Delete the MODULE_* macros
as there's only one user of them in the entire tree.

We can also get rid of the UNKNOWN_MODULE constant because now a
module doesn't need a __module_init_ptr symbol to be classed as a
library - if a module isn't an executable, it's a library, there's no
such thing as an unknown type.

It's no longer necessary to explicitly call
__syslinux_get_ipappend_strings() from ldlinux.c because the
__constructor tag on the version in com32/lib/syslinux will take care
of invoking it before ldlinux.c32's main() is executed.

Also, since we've refactored unload_module() to now run a module's
destructors let's minimise the number of callers by deleting
load_library() and unload_library(), which were only called by the
test module in com32/elflink.

Signed-off-by: Matt Fleming <matt.fleming@intel.com>
12 files changed:
com32/elflink/ldlinux/Makefile
com32/elflink/ldlinux/cli.c
com32/elflink/ldlinux/ipappend.c [deleted file]
com32/elflink/ldlinux/ldlinux.c
com32/include/sys/exec.h
com32/include/sys/module.h
com32/lib/Makefile
com32/lib/elf32.ld
com32/lib/sys/module/common.c
com32/lib/sys/module/elf_module.c
com32/lib/sys/module/exec.c
mk/lib.mk