How to relocate static array and string

A static array is
  v = array { ... }

The array is created and allocated in DS during the compile-time and it is replaced by an address atom (ADS in the parse tree). A string constant is allocated in DS and replaced by ADS. ADS of a string constant is unique.  

ADS is generated into a constant number (in v5, a global variable).  Its value needs to be updated when reloc.  This can be done by keeping track of the number generated in a list.

A global variable in an immediate line which holds value of static array and string must has its value updated when reloc. Its compile-time value is created and fixed.  A global variable can be accessed in the symbol table.  During code generation, this type of gv must be marked for its value to be updated when reloc (by VARRAY).  Updating through the symbol table will ensure that each value is relocated only once (which is a correct behaviour).

In summary, to reloc static array and string, the atom of type ADS represented a static array and a string.  It is changed into a gv, this gv is keep tracked in a list.  This list is used to reloc these gvs. To work with an immediate line, another static array has the form:
  v = array 10
The value of this gv must also be updated when reloc.  During code generation of immediate line, for this type of gv, a special mark is placed in its symbol table entry.  When reloc, use the symbol table and update the marked entry.

So "to updatesym" the line "M[ref] = cdr e" is incorrect.  ref is an index into the symbol table, at best it should be "M[getRef ref]" but it is not necessary because "to reloc" will do the proper job when outputting the object file.

24 Oct 2009
