This option generates a malloc library for security facility.
A malloc library for normal use is generated.
When using a malloc library for security facility, the __heap_chk_fail function is called when one of the following operations is performed: |
A pointer to an area other than that allocated by calloc, malloc, or realloc is passed to free or realloc. |
After a value is written to an address outside the area allocated by calloc, malloc, or realloc (within two bytes before and after the allocated area), the pointer to that area is passed to free or realloc. |
The __heap_chk_fail function needs to be defined by the user. This function describes the processing to be executed when an error occurs in management of dynamic memory. |
The __heap_chk_fail function should be a far function whose return value and parameter type should be the void type. |
void __far __heap_chk_fail(void);
The calloc, malloc, and realloc functions for the security facility allocate two extra bytes each before and after an allocated area for the purpose of detecting writing to addresses outside the allocated area. This consumes more heap memory area than with the usual functions. |
To change the heap memory area, define the _REL_sysheap array and set the array size in the _REL_sizeof_sysheap variable. |