Palm OS has a nasty little “habit” of forcing code resources to have a defined maximum size – if that size gets exceeded, the code needs to be “swapped out” into another resource(called segmenting). Creating such multi-segment applications in projects that have Managed Make enabled is difficult – but a reader sent me this tutorial some time ago(which works really well):

In case you need it, here is a copy of my notes on going multisegmented
(including some quoted comments from other list subscribers and things
I found on the net — thanks guys, and sorry I didn’t include credits).
My comments are in square brackets.

================== Multisection/Multisegmented Applications =======

1 – Create a “Managed Make 68 C/C++ Project” (only managed project works
with me)
2 – Create a file named “Sections.def” in the root of your project
3 – In the top of “AppMain.c” or equivalent, include the file “Section.h”
4 – Now, edit the file “Sections.def” and “Sections.h” to define what
sections your project will have.

Sample: “Sections.def”
=======================
application { “_temp_” TEMP }
multiple code { “code1″ “code2″ }
=======================
[You must have at least one segment in the 'multiple code' definition.
The names must match those in Sections.h. Try to minimize the number
of sections you define and use, while making sure none of them grow
too big. In place of "_temp_", use your application's name. In place
of "TEMP", use your Creator ID.]

Sample: “Sections.h”
=======================
#ifndef _SECTIONS_H
#define _SECTIONS_H
#define EXTRA_SECTION_ONE __attribute__ ((section
(“code1″)))
#define EXTRA_SECTION_TWO __attribute__ ((section
(“code2″)))
#endif
=======================
[The names (here code1 and code2) can be whatever you want, but must
match those in Sections.def. You can use whatever you want as the
symbol defined. Here, it's EXTRA_SECTION_*, but could be anything.
You will use it again in #5, just below.]

5 – On the function definition specify what section will be used, the non
specified functions will be redirect to default section code.
[Try to group functions together to minimize the jumps between sections.
Be careful not to miss any, because they will default to your first
section, and possibly make it too big.]
Sample:
=======================
// [Here's where the compiler learns where to put the function:]
static void myfunc() EXTRA_SECTION_ONE;
// [Remember to add the macro every time you add a new function to your
// application!]

static void myfunc() {
// `the code`
}
=======================
If your project have a section defined and don’t use it anywhere, you got a
error. So, you need use the sections defined one time at least, or don’t
define it.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

For a managed project, in your project properties, you need to go to the
build panel and choose the prc-tools-68k-compiler->Symbols section and
add a line:

MULTISECTION_BUILD=true

to make the managed project look for your .def file. If you do everything else
in the prior posting it should then work. (The stock Sections.h file said to use
MULTIPLE_CODE_SECTIONS, but that didn’t work. I found the definition above
by looking at the generated objects.mk file.)
[I tried this and it worked; I didn't try MULTIPLE_CODE_SECTIONS - JT]

NB It also seems to require that some function be in each section or it will
complain about the section not existing at link time.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

[Also, it might help after adding the files to the project, right click
on the project's name in the Navigation window and select Refresh,
before building the project.]

Jay Ts

Thank you very much for sending this in(a few months ago…whew, some things take a LOOONG time). All I can add is that you should clean the project whenever you get ld issues at compile time – there seems to be some kind of weird segmenting cache somewhere in PODS!

Related posts:

  1. pnoJpegLib and PODS – the tutorial – Part 1
  2. The many faces of ‘static’
  3. Renaming a file busts PODS
  4. PODS and variables or standards vs. comfort
  5. PODS preprocessor trickery – raise errors from the preprocessor

2 Responses to “Creating Multi-Segment applications with PODS”

  1. Hi
    I need to segment my application because it is too large.
    Where are placed the global variables? and I do not understand very well that one takes control of the functions

  2. Hi,
    IMHO, global variables are in a DATA segment…

    Best regards
    Tam Hanna

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting

© 2013 TamsPalm - the Palm OS / web OS Blog Suffusion theme by Sayontan Sinha