the compilers and linkers use ther own memory allocator.
free memory is between hunk and hunk+nhunk. allocation
works by checking if nhunk is bigger or equal to the
amount needed, and if not, repeatedly call gethunk()
until there is. after that, the allocated amount is added
from hunk and subtracted from nhunk by the user.
the problem was when the needed amount was bigger than
the default NHUNK size gethunk() allocates per call.
gethunk() would not actually grow nhunk, but instead
just set hunk and nhunk variables to the last allocated
block. this resulted in a infinite loop of calls to
gethunk() until sbrk() would hit the maximum size for
the BSS segment.
this change makes gethunk() actually grow the hunk space,
increasing nhunk, and only updating hunk when nhunk was
previously zero. we assume that mysbrk() retuns increasing
addresses and that the space between the previous hunk+nhunk
and the new block base returned by mysbrk() is usable.
The plan 9 assemblers support the DUPOK flag on text symbols. They parse and
ignore it on GLOBL symbols. This patch makes it work in the linkers.
The reason I ran into this is because my programming language (Myrddin) uses
data symbols to generate type information, and it's useful to avoid
duplicating all of the type info in every file that gets generated.
fixes bug with libmemdraw where the linker would hoist
the final ADD $const, SP at the end over loads from the
stack causing the front to fall off once a interrupt hits.