NID

Abbreviation of Numeric Identifier.

Usage
Dynamic linking of modules (by SceKernelModulemgr) is performed based on NIDs of functions/variables instead of names.

For example, a module that wants to import sceDisplayGetFrameBuf will indicate that it needs  in its libstub structures.

This solution provides multiple benefits:
 * Names of functions and variables are not included in modules - this reveals much less information to attackers
 * Lookup inside a NID table is faster
 * Equality testing is a simple 32-bit comparison instead of a costy.
 * A dichotomic search can be performed in  if NID tables are sorted.
 * While NID tables appear to be sorted, this optimization is seemingly not used by SCE.

Calculation
By default, NIDs are derived from a symbol's name using the following algorithm:
 * 1) Calculate the SHA-1 hash of the (optionally salted) name:
 * 2) *  acts as salt and may be a string or raw binary data
 * 3) *  corresponds to concatenation in this context
 * 4) ** For example,  and   results in
 * 5) Truncate the result to 32 bits:
 * 6) Reverse endianness of the truncated result:

Notes:
 * For C++, derivation is performed using the symbol's mangled name.
 * is derived using the same suffix as the rest of the library.
 * Since library names are always known, this makes it (in theory) possible to bruteforce the suffix used for NID derivation of any library.
 * The NID of functions and variables can be set to arbitrary values.
 * It is possible to encounter NIDs that do not match the "expected" NID found by deriving using this algorithm.
 * The following online tool can be used for NID calculations.

Example 1: suffixless
sceDisplayGetFrameBuf

Known suffixless libraries
Verifying is a library doesn't use a suffix for NID derivation is trivial: derive a NID based on the library name and check if it matches the  field of the libent structure of that library.

Example 2: plaintext suffix
The SceIpmi library uses  as suffix.

For C++ exports, the NID is derived from the mangled name.

Known plaintext suffixes
Plaintext suffixes follow patterns across some modules.

Example 3: binary suffix
Used for NONAME exports.

Known binary suffixes
The following suffixes are used by SCE for NID derivation: