The following applies to Linux* systems only.
Applications designed to take advantage of Intel® 64 architecture can be built with one of three memory models:
small (-mcmodel=small or /Qmcmodel=small)
This causes code and data to be restricted to the first 2GB of address
space so that all accesses of code and data can be done with Instruction
Pointer (IP)-relative addressing.
medium (-mcmodel=medium or
/Qmcmodel=medium)
This causes code to be restricted to the first 2GB; however, there
is no restriction on data. Code can be addressed with IP-relative addressing,
but access of data must use absolute addressing.
large (-mcmodel=large or /Qmcmodel=large)
There are no restrictions on code or data; access to both code and
data uses absolute addressing.
IP-relative addressing requires only 32 bits, whereas absolute addressing requires 64-bits. This can affect code size and performance. (IP-relative addressing is somewhat faster.)
Additional Notes:
When you specify the medium or large memory models, you must also specify the –shared-intel compiler option to ensure that the correct dynamic versions of the Intel run-time libraries are used.
When you build shared objects (.so), Position-Independent Code (PIC) is specified (that is, -fpic is added by the compiler driver) so that a single .so can support all three memory models. However, code that is to be placed in a static library, or linked statically, must be built with the proper memory model specified. Note that there is a performance impact to specifying the medium or large memory models.