PREV UP NEXT Using and Porting GNU CC

16.16.6: Macros Controlling Initialization Routines

Here are the macros that control how the compiler handles initialization and termination functions:

INIT_SECTION_ASM_OP
If defined, a C string constant for the assembler operation to identify the following data as initialization code. If not defined, GNU CC will assume such a section does not exist. When you are using special sections for initialization and termination functions, this macro also controls how `crtstuff.c' and `libgcc2.c' arrange to run the initialization functions.
ASM_OUTPUT_CONSTRUCTOR (stream, name)
Define this macro as a C statement to output on the stream stream the assembler code to arrange to call the function named name at initialization time.

Assume that name is the name of a C function generated automatically by the compiler. This function takes no arguments. Use the function assemble_name to output the name name; this performs any system-specific syntactic transformations such as adding an underscore.

If you don't define this macro, nothing special is output to arrange to call the function. This is correct when the function will be called in some other manner---for example, by means of the collect2 program, which looks through the symbol table to find these functions by their names.

ASM_OUTPUT_DESTRUCTOR (stream, name)
This is like ASM_OUTPUT_CONSTRUCTOR but used for termination functions rather than initialization functions.

If your system uses collect2 as the means of processing constructors, then that program normally uses nm to scan an object file for constructor functions to be called. On certain kinds of systems, you can define these macros to make collect2 work faster (and, in some cases, make it work at all):

OBJECT_FORMAT_COFF
Define this macro if the system uses COFF (Common Object File Format) object files, so that collect2 can assume this format and scan object files directly for dynamic constructor/destructor functions.
OBJECT_FORMAT_ROSE
Define this macro if the system uses ROSE format object files, so that collect2 can assume this format and scan object files directly for dynamic constructor/destructor functions.

These macros are effective only in a native compiler; collect2 as part of a cross compiler always uses nm.

REAL_NM_FILE_NAME
Define this macro as a C string constant containing the file name to use to execute nm. The default is to search the path normally for nm.