External Library Compatibility

If you enable the large data model when the compiler builds your main application, external libraries written in C also must be built with the large data model enabled. The linker enforces this requirement, catching global objects located out of range for particular instructions.

A more serious compatibility problem involves pointer parameters. Applications built with the large data memory model may pass pointer parameter values in two words of the stack. But libraries built using the small memory model may expect pointer arguments to occupy a single word of memory. This incompatibility will cause runtime stack corruption.

You may or may not build external libraries or modules written in assembly with extended addressing modes. The linker does not enforce any compatibility rules on assembly language modules or libraries.

The compiler encodes the memory model into the object file. The linker verifies that all objects linked into an executable have compatible memory models. The ELF header’s e_flags field includes the bit fields that contain the encoded data memory model attributes of the object file:

#define EF_M56800E_LDMM 0x00000001 /* Large data memory model flag */

Additionally, C language objects are identified by an ELF header flag.

#define EF_M56800E_C 0x00000002 /* Object file generated from C source */