• Ben Avison's avatar
    Add support for (C++) static constructor and destructor functions · d8b72a18
    Ben Avison authored
    Later versions of the toolchain move on from the CFront model for static
    object construction and destruction (which used symbols called '__link'
    in object files which the linker manipulated into a linked list pointed at
    by the symbol '__head').
    
    Now, global or file-scope constructors are indicated by function pointers
    emitted into the area C$$ctorvec, with the function bodies being emitted
    into the area C$$ctor.
    
    The C library supports the calling of global or file-scope destructors in
    two ways: either they can be registered using atexit() calls from within the
    corresponding constructor (these are issued first) or function pointers can
    be provided in the area C$$dtorvec (with function bodies in the area
    C$$dtor).
    
    Function- or block-scope static-storage-duration destructors are a bit more
    complicated, since they are only constructed when the block in which they
    are declared comes into scope at run-time. For a module client, this means
    that ...
    d8b72a18