> The "PC-relative strings" box is checked, and I commented out the entire
> program except:
>
> DWord PilotMain( Word launchCode, Ptr cmdPBP, Word launchFlags)
> {
>  Err err = 0
>  if(launchCode == Normal or SysReset)
>  {
>   char *dbNames[] = {/*bunch of strings*/};
>  }
>  return err;
> }
>
> It still dies :)

Short answer.  Don't initialize a char * array automatically. Do it
piece-by-piece:
char *dbNames[5];
dbNames[0] = "...";
dbNames[1] = "....";
...
dbNames[4] = "...."


Long answer:
Disassembling the following code:
DWord PilotMain( Word launchCode, Ptr cmdPBP, Word launchFlags)
{
#pragma unused(cmdPBP)


  char *foo[2] = {"abc", "def"};
   
   
  foo[0] = "abc";
  foo[1] = "def";
 return 0;
}

gives this result:

Hunk: Kind=HUNK_GLOBAL_CODE  Name="PilotMain"(5)  Size=58
00000000: 4E56 FFF8          link      a6,#-8
00000004: 2D6D 0000 FFF8     move.l    @30,-8(a6)
0000000A: 2D6D 0000 FFFC     move.l    @30+$04,-4(a6)
00000010: 41FA 0020          lea       *+34,a0        ; 0x00000032
00000014: 2D48 FFF8          move.l    a0,-8(a6)
00000018: 41FA 001C          lea       *+30,a0        ; 0x00000036
0000001C: 2D48 FFFC          move.l    a0,-4(a6)
00000020: 7000               moveq     #0,d0
00000022: 4E5E               unlk      a6
00000024: 4E75               rts
00000026: 8950 696C 6F74     dc.b      0x89,'PilotMain'
          4D61 696E
00000030: 0008 6162 6300
00000036: 6465 6600


The two move.l lines referencing @30 are the auto-initalization of the
array.  Unfortunately, the @30 references globals.

The four lines lea, move.l, lea, move.l are the by-hand initialization, and
they are correctly pc-relative.

Note that to find this problem, you could have changed your test code to:
>  if(launchCode == Normal or SysReset or find)
and then done a find from another application.  That way, you could have
used the source-level debugger, and done a single-step.  If you turn on
assembly mode, you could look for any reference to a5 (global vars).

Neil

Reply via email to