Whole document tree
    

Whole document tree

Using PRC-Tools: Multiple code tutorial
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2 Breaking up an existing application

To use multiple code resources in an existing application, you need to do the following:

  1. If your Makefile uses obj-res, change it to use build-prc directly on your bfd executable. For example, from an original

     
    myapp.prc: code0000.myapp.grc ...
            build-prc ... *.myapp.grc ...
    
    code0000.myapp.grc: myapp
            m68k-palmos-obj-res myapp
    

    remove references to .grc files, and delete the obj-res rule altogether:

     
    myapp.prc: myapp ...
            build-prc ... myapp ...
    

  2. Choose functions to be placed in other code sections, and annotate their declarations:
     
    #define EDIT_SECTION  __attribute__ ((section ("editfns")))
    
    void EditFormHandler (...) EDIT_SECTION;
    void DrawEditForm () EDIT_SECTION;
    
    (This also demonstrates using a macro to ease moving several functions at once.)

    Make very sure that the relevant annotated declaration is visible when you define such a function, and especially everywhere you call it. If there is a call to a non-default sectioned function from which the annotated declaration is not visible, the call will be generated as a call to the default code section. When such a call is executed, it jumps to effectively a random location in the wrong code section and almost certainly crashes. (Warning options which can detect these mistakes at compile time are noted in the discussion of required visibilities in 1.2 Function attributes.)

    Note that COFF only stores eight character of a section name: if your section names are any longer than this, they will be truncated, leading to trouble.

  3. Add a multiple code clause to your definition file (or write a definition file and use it in your build-prc line if you're not already using one).

     
    multiple code { "editfns" }
    

  4. Add rules to your Makefile to generate and build the assembler stub and linker script.

     
    myapp-sections.o: myapp-sections.s
            m68k-palmos-gcc -c myapp-sections.s
    
    myapp-sections.s myapp-sections.ld: myapp.def
            multigen myapp.def
    

  5. Link the assembler stub into your bfd executable, and use the linker script to place the extra code sections at appropriate addresses.
     
    OBJS = ...list of object files... myapp-sections.o
    
    myapp: $(OBJS) myapp-sections.ld
            m68k-palmos-gcc -o myapp $(OBJS) myapp-sections.ld
    


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by root on January, 30 2002 using texi2html