Changes

Jump to navigation Jump to search

HOWTO-Dynamic Modules

20 bytes removed, 07:26, 16 August 2010
m
no edit summary
I will assume that you are at least roughly familiar with ScummVM, and have a fresh checkout of our Subversion repository. Note that it's strongly advised to base your work on the current development version of ScummVM, and not on a release version. This will ease integration of your work.
 
=== Overview ===
ScummVM has a PluginManager class that potentially keeps track of multiple plugin providers. As of this writing, a StaticPluginProvider is always added to this PluginManager that keeps track of all statically-linked plugins. Your job will be to add a dynamic plugin provider specific to the backend you're working on that will provide for any dynamic plugins that are enabled on that backend and to tell the backend to use this provider in the case that dynamic modules are enabled.
 
=== Step by step ===
# Modify the build system for your backend (See "Necessary Build Modifications" below).
# Cross your fingers and be prepared to work at things for a while if it doesn't immediately function ;-)
 
==== Example of foobar-provider.h====
#endif // defined(DYNAMIC_MODULES) && defined(FOOBAR)
</syntax>
 
==== Making the plugin linker script for your backend ====
*Find the <tt>.ctors</tt> and <tt>.dtors</tt> sections (constructors and destructors) and delete any output-section-commands within them that reference crtbegin or crtend, i.e <code>KEEP (*crtbegin*.o(.dtors))</code> or <code>KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))</code>. Put <code>___plugin_ctors = .;</code> as the first output-section-command in the <tt>.ctors</tt> section and <code>___plugin_ctors_end = .;</code> as the last output-section-command. Do the same for the <tt>.dtors</tt> section but with <tt>___plugin_dtors</tt>, etc. This gives these symbols values that our run-time loader can use. In the end, <tt>.ctors</tt> and <tt>.dtors</tt> should look something like this:
<syntax type="C++">.ctors :
{ ___plugin_ctors = .; KEEP (*(SORT(.ctors.*))) KEEP (*(.ctors)) ___plugin_ctors_end = .; } .dtors : { ___plugin_dtors = .; KEEP (*(SORT(.dtors.*))) KEEP (*(.dtors)) ___plugin_dtors_end = .; }</syntax>
*That's it! If you have trouble with any of these instructions or need to further modify the linker script for something specific to your platform, see [http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/gnu-linker/scripts.html] for linker script documentation and peruse the various <tt>plugin.ld</tt> files in the subdirectories of <tt>backends/plugins/</tt>. TODO: Add stuff about MIPS-specific linker script modifications, namely the "shorts" segment.
 
==== Necessary Build Modifications ====
TODO: Add stuff about "ONE_PLUGIN_AT_A_TIME" once it is working perfectly.
 
==== Subclassing DLObject ====
27

edits

Navigation menu