Next: , Previous: Linkage-table, Up: Foreign Linkage


4.2 Lazy Alien Resolution

On linkage-table ports SBCL is able to deal with forward-references to aliens – which is to say, compile and load code referring to aliens before the shared object containing the alien in question has been loaded.

This is handled by ENSURE-DYNAMIC-FOREIGN-SYMBOL-ADDRESS, which first tries to resolve the address in the loaded shared objects, but failing that records the alien as undefined and returns the address of a read/write/execute protected guard page for variables, and address of undefined_alien_function for routines. These are in turn responsible for catching attempts to access the undefined alien, and signalling the appropriate error.

These placeholder addresses get recorded in the linkage-table.

When new shared objects are loaded UPDATE-LINKAGE-TABLE is called, which in turn attempts to resolve all currently undefined aliens, and registers the correct addresses for them in the linkage-table.