02.03.2014 Views

Tornado

Tornado

Tornado

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Tornado</strong> 2.0<br />

User’s Guide<br />

munch<br />

NAME<br />

SYNOPSIS<br />

DESCRIPTION<br />

EXAMPLES<br />

munch – extract initializers and finalizers from C++ object modules<br />

wtxtcl $WIND_BASE/host/src/hutils/munch.tcl [-asm arch]<br />

This tool produces data structures used to call constructors and destructors for static<br />

objects. It is used when compiling C++ modules.<br />

Given an ordered list of C++ object modules, munch produces a C program containing<br />

Ctors/Dtors arrays where the initialization order is the one promised below.<br />

The modules should be ordered on the command line so that a.o is to the left of b.o if any<br />

initializers that appear in a.o but in no module to the right of a.o should be called before<br />

any initializers in b.o. Notice that each initializer is called only once (in its rightmost<br />

position) even though it may appear in more than one module. Finalizers are run in the<br />

reverse order.<br />

If you are using a GNU compiler you should invoke munch with the -asm flag. This<br />

causes munch to output assembly directives which can be compiled without any special<br />

flags. On the other hand, if you do not supply the -asm flag the compiler may have to be<br />

coerced into accepting non-standard characters in identifiers (such as $). On GNU<br />

compilers this is achieved with the -fdollars-in-identifiers option.<br />

Consider a project consisting of two C++ modules, user1.o and user2.o, linked with a user<br />

library myLib.a and a VxWorks library (say libMC68040gnuvx.a). Then the ctors file can<br />

be generated using:<br />

Windows nm68k partialImage.o partialUserImage.o user1.o user2.o \<br />

| wtxtcl %WIND_BASE%\host\src\hutils\munch.tcl -asm 68k > ctdt.c<br />

UNIX nm68k partialImage.o partialUserImage.o user1.o user2.o \<br />

| wtxtcl $WIND_BASE/host/src/hutils/munch.tcl -asm 68k > ctdt.c<br />

Here partialUserImage.o is the result of linking user1.o and user2.o against myLib.a and<br />

partialImage.o is the result of linking partialUserImage.o against libMC68040gnuvx.a.<br />

This will ensure that the VxWorks library is initialized before the user library which in<br />

turn is initialized before any of the project modules. The latter are initialized in the order<br />

they appear on the command line.<br />

The following commands will compile hello.cpp, then munch hello.o, resulting in the<br />

munched file hello.out, suitable for loading by the <strong>Tornado</strong> module loader:<br />

Windows cc68k -I%WIND_BASE%\target\h -DCPU=MC68020 -nostdinc \<br />

-fno-builtin -c hello.cpp<br />

456

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!