Relo cating Machine Instructions by Currying
Norman Ramsey
University of Virginia
Relo cation adjusts machine instructions to account for changes in the lo cations of the instructions
themselves or of external symb ols to which they refer Standard linkers implement a nite set of
relo cation transformations suitable for a single architecture These transformations are enumer
ated named and engraved in a machine dep endent ob ject le format and linkers must recognize
them by name These names and their asso ciated transformations are an unnecessary source of
machine dep endence
An alternative is to use SLED Sp eci cation Language for Enco ding and Deco ding to sp ecify
representations of machine instructions Instructions are describ ed by constructors which denote
functions mapping lists of op erands to instructions binary representations Any op erand can b e
designated as relo catable meaning that the op erand s value need not b e known at the time the
instruction is enco ded From a SLED sp eci cation the New Jersey Machine Co de To olkit can
generate functions that enco de instructions in the native binary representation For instructions
with relo catable op erands the to olkit also computes relo cating transformations To ol writers
can create machine indep endent software that uses these transformations to relo cate machine
instructions For example mld a retargetable linker built with the to olkit needs only lines of
C co de for relo cation and that co de is machine indep endent
The to olkit discovers relo cating transformations by currying enco ding functions An attempt to
enco de an instruction with a relo catable op erand results in the creation of a closure The closure
can b e applied when the values of the relo catable op erands b ecome known Currying provides a
general machine indep endent metho d of relo cation
Currying rewrites a term into two nested terms The standard implementation has the