Ladies and gentleman, we have a winner. Thanks, Kevin!
Kevin Schoedel wrote (privately):
OK, having now seen the code, I suspect the problem is
that you have a
function called end(). 'end' has traditionally been used by Unix systems
for the address of the end of program memory. (I'm not sure where you'll
find this documented -- maybe under ld(1).) This would explain the
different results when you compile (and link) in a different order --
different memory is corrupted depending on where your end() appears.
--
Jeffrey Sharp