Difference between revisions of "HOWTO-Dynamic Modules"

Jump to navigation Jump to search
20 bytes removed ,  07:26, 16 August 2010
m
no edit summary
(Filled out the "making the plugin linker script for your backend")
m
Line 6: Line 6:


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.
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 ===
=== 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.
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 ===
=== Step by step ===
Line 22: Line 24:
# Modify the build system for your backend (See "Necessary Build Modifications" below).
# 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 ;-)
# Cross your fingers and be prepared to work at things for a while if it doesn't immediately function ;-)


==== Example of foobar-provider.h====
==== Example of foobar-provider.h====
Line 45: Line 48:
#endif // defined(DYNAMIC_MODULES) && defined(FOOBAR)
#endif // defined(DYNAMIC_MODULES) && defined(FOOBAR)
</syntax>
</syntax>


==== Making the plugin linker script for your backend ====
==== Making the plugin linker script for your backend ====
Line 59: Line 63:
*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:
*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          :
<syntax type="C++">.ctors          :
  {
{
    ___plugin_ctors = .;
  ___plugin_ctors = .;
    KEEP (*(SORT(.ctors.*)))
  KEEP (*(SORT(.ctors.*)))
    KEEP (*(.ctors))
  KEEP (*(.ctors))
    ___plugin_ctors_end = .;
  ___plugin_ctors_end = .;
  }
}
  .dtors          :
.dtors          :
  {
{
    ___plugin_dtors = .;
  ___plugin_dtors = .;
    KEEP (*(SORT(.dtors.*)))
  KEEP (*(SORT(.dtors.*)))
    KEEP (*(.dtors))
  KEEP (*(.dtors))
    ___plugin_dtors_end = .;
  ___plugin_dtors_end = .;
  }</syntax>
}</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.
*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 ====
==== Necessary Build Modifications ====
Line 90: Line 95:


TODO: Add stuff about "ONE_PLUGIN_AT_A_TIME" once it is working perfectly.
TODO: Add stuff about "ONE_PLUGIN_AT_A_TIME" once it is working perfectly.


==== Subclassing DLObject ====
==== Subclassing DLObject ====
27

edits

Navigation menu