Subject: Re: Way Off Topic: Patching Running Code
To: Henry B. Hotz <hotz@jpl.nasa.gov>
From: gabriel rosenkoetter <gr@eclipsed.net>
List: port-macppc
Date: 06/10/2001 22:48:56
On Fri, Jun 08, 2001 at 01:39:31PM -0700, Henry B. Hotz wrote:
> On this OS (VxWorks) the loader is active and I can link the new 
> routine in under a new name to resolve its references.  Then I 
> believe I should be able to locate the first instruction in the old 
> routine and replace it with a jump (longjump?) to the beginning of 
> the new routine.

Depends where the original routine is in memory, but you probably
want a long jump.

> I don't know PPC assembly so can anyone comment on the feasibility of 
> this approach?  Pitfalls like jump instruction range?  Side effects 
> of different stack frame size?  Atomicity of writing the jump?  I 
> assume the new routine is constrained to have the same arguments, and 
> it's likely to be very similar, but slightly larger than the original.

I'm definitely not qualified to comment on this. But I have plenty
of macppcs lying around if you'd like one to test this on (remotely
or shipped). Crashing these machines by way of writing over running
code won't cause any problems for me, which it may for people who
are using RS6000-based machines in any kind of production. On the
other hand, I'd guess NASA can probably afford a test version of
their space craft... I do hope you'll try this there before borking
the one out yonder. ;^>

You might get a better audience from port-powerpc, btw.

> For those who want to know the application: it is some possible 
> after-end-of-mission communications technology demonstrations to be 
> done on the DS1 spacecraft.  A reboot would likely use up all 
> remaining hydrazine and kill the spacecraft at this time.  It uses a 
> RAD6000 CPU which is a 40 MHz single-CPU implementation of the IBM 
> RS6000 architecture and therefore very similar to a PPC 601.  128MB 
> of RAM, most of which is taken by various memory file systems.  ROM 
> image of the operating code is about 4MB.

Uh. Wow. That's about all I can say. :^>

       ~ g r @ eclipsed.net