nlist_64

Describes an entry in the symbol table for 64-bit architectures. Declared in /usr/include/mach-o/nlist.h.

Declaration

struct nlist_64 {
    ...
};

Discussion

See discussion in nlist.

Topics

Fields

n_un

A union that holds an index into the string table, n_strx. To specify an empty string (""), set this value to 0.

n_type

A byte value consisting of data accessed using four bit masks:

  • N_STAB (0xe0)—If any of these 3 bits are set, the symbol is a symbolic debugging table (stab) entry. In that case, the entire n_type field is interpreted as a stab value. See /usr/include/mach-o/stab.h for valid stab values.

  • N_PEXT (0x10)—If this bit is on, this symbol is marked as having limited global scope. When the file is fed to the static linker, it clears the N_EXT bit for each symbol with the N_PEXT bit set. (The ld option -keep_private_externs turns off this behavior.) With macOS GCC, you can use the __private_extern__ function attribute to set this bit.

  • N_TYPE (0x0e)—These bits define the type of the symbol.

  • N_EXT (0x01)—If this bit is on, this symbol is an external symbol, a symbol that is either defined outside this file or that is defined in this file but can be referenced by other files.

Values for the N_TYPE field include:

  • N_UNDF (0x0)—The symbol is undefined. Undefined symbols are symbols referenced in this module but defined in a different module. Set the n_sect field to NO_SECT.

  • N_ABS (0x2)—The symbol is absolute. The linker does not update the value of an absolute symbol. Set the n_sect field to NO_SECT.

  • N_SECT (0xe)—The symbol is defined in the section number given in n_sect.

  • N_PBUD (0xc)—The symbol is undefined and the image is using a prebound value for the symbol. Set the n_sect field to NO_SECT.

  • N_INDR ( 0xa)—The symbol is defined to be the same as another symbol. The n_value field is an index into the string table specifying the name of the other symbol. When that symbol is linked, both this and the other symbol point to the same defined type and value.

n_sect

An integer specifying the number of the section that this symbol can be found in, or NO_SECT if the symbol is not to be found in any section of this image. The sections are contiguously numbered across segments, starting from 1, according to the order they appear in the LC_SEGMENT load commands.

n_desc

A 16-bit value providing additional information about the nature of this symbol. The reference flags can be accessed using the REFERENCE_TYPE mask (0xF) and are defined as follows:

  • REFERENCE_FLAG_UNDEFINED_NON_LAZY (0x0)—This symbol is a reference to an external non-lazy (data) symbol.

  • REFERENCE_FLAG_UNDEFINED_LAZY (0x1)—This symbol is a reference to an external lazy symbol—that is, to a function call.

  • REFERENCE_FLAG_DEFINED (0x2)—This symbol is defined in this module.

  • REFERENCE_FLAG_PRIVATE_DEFINED (0x3)—This symbol is defined in this module and is visible only to modules within this shared library.

  • REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY (0x4)—This symbol is defined in another module in this file, is a non-lazy (data) symbol, and is visible only to modules within this shared library.

  • REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY (0x5)—This symbol is defined in another module in this file, is a lazy (function) symbol, and is visible only to modules within this shared library.

Additionally, the following bits might also be set:

  • REFERENCED_DYNAMICALLY (0x10)—Must be set for any defined symbol that is referenced by dynamic-loader APIs (such as NSLookupSymbolInImage) and not ordinary undefined symbol references. The strip tool uses this bit to avoid removing symbols that must exist: If the symbol has this bit set, strip does not strip it.

  • N_DESC_DISCARDED (0x20)—Used by the dynamic linker at runtime. Do not set this bit.

  • N_WEAK_REF (0x40)—Indicates that this symbol is a weak reference. If the dynamic linker cannot find a definition for this symbol, it sets the address of this symbol to 0. The static linker sets this symbol given the appropriate weak-linking flags.

  • N_WEAK_DEF (0x80)—Indicates that this symbol is a weak definition. If the static linker or the dynamic linker finds another (non-weak) definition for this symbol, the weak definition is ignored. Only symbols in a coalesced section can be marked as a weak definition.

If this file is a two-level namespace image (that is, if the MH_TWOLEVEL flag of the mach_header structure is set), the high 8 bits of n_desc specify the number of the library in which this symbol is defined. Use the macro GET_LIBRARY_ORDINAL to obtain this value and the macro SET_LIBRARY_ORDINAL to set it. Zero specifies the current image. 1 through 254 specify the library number according to the order of LC_LOAD_DYLIB commands in the file. For plug–ins that load symbols from the executable program they are linked against, 255 specifies the executable image. For flat namespace images, the high 8 bits must be 0.

Instance Properties