The OpenD Programming Language

SELF_LIBRARY_ORDINAL

For images created by the static link editor with the -twolevel_namespace option in effect the flags field of the mach header is marked with MH_TWOLEVEL. And the binding of the undefined references of the image are determined by the static link editor. Which library an undefined symbol is bound to is recorded by the static linker in the high 8 bits of the n_desc field using the SET_LIBRARY_ORDINAL macro below. The ordinal recorded references the libraries listed in the Mach-O's LC_LOAD_DYLIB, LC_LOAD_WEAK_DYLIB, LC_REEXPORT_DYLIB, LC_LOAD_UPWARD_DYLIB, and LC_LAZY_LOAD_DYLIB, etc. load commands in the order they appear in the headers. The library ordinals start from 1. For a dynamic library that is built as a two-level namespace image the undefined references from module defined in another use the same nlist struct an in that case SELF_LIBRARY_ORDINAL is used as the library ordinal. For defined symbols in all images they also must have the library ordinal set to SELF_LIBRARY_ORDINAL. The EXECUTABLE_ORDINAL refers to the executable image for references from plugins that refer to the executable that loads them.

The DYNAMIC_LOOKUP_ORDINAL is for undefined symbols in a two-level namespace image that are looked up by the dynamic linker with flat namespace semantics. This ordinal was added as a feature in Mac OS X 10.3 by reducing the value of MAX_LIBRARY_ORDINAL by one. So it is legal for existing binaries or binaries built with older tools to have 0xfe (254) dynamic libraries. In this case the ordinal value 0xfe (254) must be treated as a library ordinal for compatibility.

Meta