OK, I just checked the program headers for the executable. There are
multiple segments in the executable: three in the one that works, and two
in the one that doesn't. In the one that works, the last segment does
include my global variable initialization, but it's not there in the one
that doesn't. Oddly enough, though, the data is in the executable, but just
not in a loadable segment.
So, in summary, it appears that the linker is putting my global
initialization data into the executable, but not including it a loadable
segment in the program headers, so the bootloader isn't loading it, and it
has something to do with ld.script.little.
From: Ralf Baechle <email@example.com>
To: Bradley D. LaRonde <firstname.lastname@example.org>
Cc: email@example.com <firstname.lastname@example.org>;
Date: Wednesday, July 21, 1999 8:54 PM
Subject: Re: Globals not getting initialized
>On Wed, Jul 21, 1999 at 08:01:01PM -0400, Bradley D. LaRonde wrote:
>> It's funny, because they do get initialized properly when I link with the
>> NetBSD (stand.ldscript) linker script, but not when I link with the
>> Linux-MIPS linker script (ld.script.little). It appears that something
>> ld.script.llittle is throwing the bootloader (pbsdboot) off.
>Maybe you're accidently loading only the first ELF segment or so?
>(I'm not shure if an ELF kernel binary usually has multiple segments but
>it's a theory worth to be verified.)