le 25/06/03 14:22, Roger Stringer � [EMAIL PROTECTED] a �crit�:

> 
>> Subject: Bad executable generation
>> From: "Dave Mottorn" <[EMAIL PROTECTED]>
>> 
>>         I'm using Codewarrior 8.32 to develop a program that now has three
>> segments.  I don't think there are any later updates to version 8. Last
>> night I made a few changes and compiled and linked the program.  I didn't
>> get any error messages but when I tried to install the new version on my PDA
>> it not only didn't install the new version, it removed the application.  I
>> had the same problem once before but that was because one of the segments
>> was a little too large and the linker didn't detect it.  This time I'm sure
>> the segments are all in bounds.  It must be a programming error that
>> CodeWarrior doesn't detect but I haven't been able to find it.  Any Ideas?
> 
> If you are using multiple segments, then you should set your compiler to be
> "Small" as this will maximize performance and minimize program size.   This
> also means your segments should not be greater than 32K and nowhere nearer
> the HotSync-driven 64KB limit.
> ** Actually the segments can creep a little over 32KB, but you'll get link
> errors once they get too big.
> 

Sorry to have to mention this, but you can - and should as much as possible
- grow your segments to the 64k limit.

This is because calling one function from one segment to another is much
more time and space consuming than calling it within the same segment. So if
you can have 2 segments instead of 4, your code will be smaller and more
efficient.

It is true that you may get some link errors when doing this with code model
set to "Small". This is because when set to "Small", a jump address within a
segment uses only 2 bytes (the relative offset) so it is limited to +- 32k.

This can be solved by reordering your code in the 'segment' panel, and
ensuring that calls within a segment are inside this limit. You do this by
changing the files order inside a segment, or the methods order inside a
file.

Sometimes, due to the code itself, this cannot be achieved. In that case, if
you have only 1 or 2 link errors, you can create what is known as an
'island':

For example:

MethodAtBeginningOfSegment()
{
}

MethodAtEndOfSegment()
{
    MethodAtBeginningOfSegment();
}

may lead to an unsolvable link error if your segment size is > 32k. The
'island' technique leads to the following:

MethodAtBeginningOfSegment()
{
}

IslandInMiddleOfSegment()
{
    MethodAtBeginningOfSegment();
}

MethodAtEndOfSegment()
{
    IslandInMiddleOfSegment();
}

Which will solve the link error.

Please note that this technique is only useful when there are only very few
unsolvable link errors, otherwise it leads to lots of space consumption and
overhead, which is exactly what you're fighting against.

-------------------------------
Eric VERGNAUD - JLynx Software
Cutting-edge technologies and
services for software companies
web: http://www.jlynx.com
-------------------------------


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

Reply via email to