Re: How does setpatch work?



<a1_nocrap_exh@xxxxxxxxxxx> wrote:
> Anyone here know how setpatch actually works?
>
> I dont mean what are the command line options etc. But how does it
> work?
>
> Kickstart is in ROM, the Amiga hardware is designed to boot off
> kickstart. I'm guessing it loads as usual, enough drivers to access the
> hard disk and run the set-patch command.
>
> I guess the Kickstart ROM code loads some function jump table into RAM.
> Set-patch loads OS patches into RAM also and then modifies this jump
> table.

That is pretty much correct.

> What I am curious about is the structure of this table (if there is
> one) and approximately how it works.
<snip>

When a shared library is first opened, it generates a jump table in
RAM. Usually this is done from an array of function entry points. On
a 68000 system, each entry in the jump table takes up 6 bytes and
normally consists of a JMP absolute instruction. (There are
exceptions such as dos.library prior to v36 (r2.0) and exec.library's
GetCC function.)

Device drivers also have a jump table along the same lines, though
almost all device driver calls are done through just two functions.

Opening a library returns a "base pointer" for the library; starting
at this address is a standard library structure followed by any
library-specific variables and before it is the jump table. This
allows the two structures to grow in opposite directions as new
features are added to the library. Shared library calls are performed
using a JSR relative instruction with the base pointer loaded into A6
(usually; a few functions don't require this) and the appropriate jump
table offset (also called library vector offset or LVO for short).

Since the jump tables are in RAM, any entry in them can be replaced.
There is a function in exec.library called SetFunction which will do
this, assuming that the entry is initially a JMP instruction. However
this isn't suitable for use by a patch that wraps rather than
replacing the original function.

What I don't know is how SetPatch patches code that isn't called
(at least, not directly) through library functions. For example
SetPatch v38 (r2.1) internationalises Workbench v37 (r2.0).

--
Ben Hutchings
Man invented language to satisfy his deep need to complain. - Lily Tomlin
.



Relevant Pages

  • [PATCH 1/4 -mm] kexec based hibernation -v7 : kexec jump
    ... This patch implements the functionality of jumping between the kexeced ... kernel and the original kernel. ... A jump back protocol for kexec is defined and documented. ... extern asmlinkage long compat_sys_kexec_load(unsigned long entry, ...
    (Linux-Kernel)
  • [PATCH 1/3 -mm] kexec based hibernation -v6: kexec jump
    ... This patch implements the functionality of jumping between the kexeced ... kernel and the original kernel. ... A jump back protocol for kexec is defined and documented. ... extern asmlinkage long compat_sys_kexec_load(unsigned long entry, ...
    (Linux-Kernel)
  • Re: copy function and run it
    ... jump to it. ... The executing function then copies a vxworks image ... A compiler could have optimized your function away as a dead code. ... Make sure that the location in the RAM is not used by anything else. ...
    (comp.arch.embedded)
  • Re: Loop non-jump
    ... S>it has to be said, the move remains an entry, period. ... You cannot bring you arms around and then think "jump". ... This arm motion and knee bend is what makes your BO edge curve on the ...
    (rec.sport.skating.ice.recreational)
  • mc68332 embedded programming problems
    ... I am trying very unsuccessfully to load my code from my Flash into ram, ... and then jump to ram. ... I can only load so many bytes to ram before the system resets. ...
    (sci.electronics.design)