On Wed, 24 Mar 2004 20:01:16 -0800 (PST), harish kumar <[EMAIL PROTECTED]> wrote:

Hi All,

I am trying to port a C code from windows to Palm OS
Platform
(Codewarrior 9.0).

The segments info shows the follows details.

Segment 1 : Code 27k DATA 4k
Segment 2 : Code 11k DATA 376
Segment 3 : Code 19k DATA 3k
Segment 4 : Code 34k DATA 2k
Segment 5 : Code 27k DATA 1k
Segment 6 : Code 40 DATA  48k <----- (Problem)
Segment 7 : Code 30k DATA 24k

I am getting the following link errors.

__RuntimeModule__ : Near data segment is greater than
64k
__RuntimeModule__ : Near data segment is greater than
64k
PalmOS_Startup: 'MTWK::__LoadAndRelocate__' 16-bit
data reference is out
of range.

1,2 should be the problem with Segment 6. The 3rd link
error should go
off if I rearrange the code snippet.

Segment 6 : Code 40 DATA 48k <----- (Problem)

As you can see, the code part is almost zero. It has a
constant
definition of a structure with MANY values assigned.

const  Ent EntTable[8192] = {12,1........}.. goes on
and on.

Should I break the file into 3-4 smaller files and get
the value from
the correct table runtime?

Will adding the code in expanded mode help? It will
give us more heap
space.

Hi,


I have had this problem before.

Unless I am seriously confused all you can have is 64KB of static data per application total (not
per segment). So looking at yours you definitely exceed that.


The way I solved was by moving structure initialization to a function e.g.:

Instead of
const  Ent EntTable[8192] = {12,1........}
which ends up in the static data segment

Use:

void InitEntTable(Ent *ent)
{
  const Ent EntTable[8192] = {12, 1........}
  for (int i = 0; i<8192; ++i)
     *(ent+i) = EntTable[i];
}

It is ugly, but in this way the structure (array or whatever) initialization becomes code and not
data (since it is a local variable on the stack be careful not to overflow the stack - better use
MemPtrNew and allocate the temporary variable dynamically if it is too big)


--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to