gccint: Macros for Initialization
1
1 18.20.6 Macros Controlling Initialization Routines
1 --------------------------------------------------
1
1 Here are the macros that control how the compiler handles initialization
1 and termination functions:
1
1 -- Macro: INIT_SECTION_ASM_OP
1 If defined, a C string constant, including spacing, for the
1 assembler operation to identify the following data as
1 initialization code. If not defined, GCC will assume such a
1 section does not exist. When you are using special sections for
1 initialization and termination functions, this macro also controls
1 how 'crtstuff.c' and 'libgcc2.c' arrange to run the initialization
1 functions.
1
1 -- Macro: HAS_INIT_SECTION
1 If defined, 'main' will not call '__main' as described above. This
1 macro should be defined for systems that control start-up code on a
1 symbol-by-symbol basis, such as OSF/1, and should not be defined
1 explicitly for systems that support 'INIT_SECTION_ASM_OP'.
1
1 -- Macro: LD_INIT_SWITCH
1 If defined, a C string constant for a switch that tells the linker
1 that the following symbol is an initialization routine.
1
1 -- Macro: LD_FINI_SWITCH
1 If defined, a C string constant for a switch that tells the linker
1 that the following symbol is a finalization routine.
1
1 -- Macro: COLLECT_SHARED_INIT_FUNC (STREAM, FUNC)
1 If defined, a C statement that will write a function that can be
1 automatically called when a shared library is loaded. The function
1 should call FUNC, which takes no arguments. If not defined, and
1 the object format requires an explicit initialization function,
1 then a function called '_GLOBAL__DI' will be generated.
1
1 This function and the following one are used by collect2 when
1 linking a shared library that needs constructors or destructors, or
1 has DWARF2 exception tables embedded in the code.
1
1 -- Macro: COLLECT_SHARED_FINI_FUNC (STREAM, FUNC)
1 If defined, a C statement that will write a function that can be
1 automatically called when a shared library is unloaded. The
1 function should call FUNC, which takes no arguments. If not
1 defined, and the object format requires an explicit finalization
1 function, then a function called '_GLOBAL__DD' will be generated.
1
1 -- Macro: INVOKE__main
1 If defined, 'main' will call '__main' despite the presence of
1 'INIT_SECTION_ASM_OP'. This macro should be defined for systems
1 where the init section is not actually run automatically, but is
1 still useful for collecting the lists of constructors and
1 destructors.
1
1 -- Macro: SUPPORTS_INIT_PRIORITY
1 If nonzero, the C++ 'init_priority' attribute is supported and the
1 compiler should emit instructions to control the order of
1 initialization of objects. If zero, the compiler will issue an
1 error message upon encountering an 'init_priority' attribute.
1
1 -- Target Hook: bool TARGET_HAVE_CTORS_DTORS
1 This value is true if the target supports some "native" method of
1 collecting constructors and destructors to be run at startup and
1 exit. It is false if we must use 'collect2'.
1
1 -- Target Hook: void TARGET_ASM_CONSTRUCTOR (rtx SYMBOL, int PRIORITY)
1 If defined, a function that outputs assembler code to arrange to
1 call the function referenced by SYMBOL at initialization time.
1
1 Assume that SYMBOL is a 'SYMBOL_REF' for a function taking no
1 arguments and with no return value. If the target supports
1 initialization priorities, PRIORITY is a value between 0 and
1 'MAX_INIT_PRIORITY'; otherwise it must be 'DEFAULT_INIT_PRIORITY'.
1
1 If this macro is not defined by the target, a suitable default will
1 be chosen if (1) the target supports arbitrary section names, (2)
1 the target defines 'CTORS_SECTION_ASM_OP', or (3) 'USE_COLLECT2' is
1 not defined.
1
1 -- Target Hook: void TARGET_ASM_DESTRUCTOR (rtx SYMBOL, int PRIORITY)
1 This is like 'TARGET_ASM_CONSTRUCTOR' but used for termination
1 functions rather than initialization functions.
1
1 If 'TARGET_HAVE_CTORS_DTORS' is true, the initialization routine
1 generated for the generated object file will have static linkage.
1
1 If your system uses 'collect2' as the means of processing constructors,
1 then that program normally uses 'nm' to scan an object file for
1 constructor functions to be called.
1
1 On certain kinds of systems, you can define this macro to make
1 'collect2' work faster (and, in some cases, make it work at all):
1
1 -- Macro: OBJECT_FORMAT_COFF
1 Define this macro if the system uses COFF (Common Object File
1 Format) object files, so that 'collect2' can assume this format and
1 scan object files directly for dynamic constructor/destructor
1 functions.
1
1 This macro is effective only in a native compiler; 'collect2' as
1 part of a cross compiler always uses 'nm' for the target machine.
1
1 -- Macro: REAL_NM_FILE_NAME
1 Define this macro as a C string constant containing the file name
1 to use to execute 'nm'. The default is to search the path normally
1 for 'nm'.
1
1 -- Macro: NM_FLAGS
1 'collect2' calls 'nm' to scan object files for static constructors
1 and destructors and LTO info. By default, '-n' is passed. Define
1 'NM_FLAGS' to a C string constant if other options are needed to
1 get the same output format as GNU 'nm -n' produces.
1
1 If your system supports shared libraries and has a program to list the
1 dynamic dependencies of a given library or executable, you can define
1 these macros to enable support for running initialization and
1 termination functions in shared libraries:
1
1 -- Macro: LDD_SUFFIX
1 Define this macro to a C string constant containing the name of the
1 program which lists dynamic dependencies, like 'ldd' under SunOS 4.
1
1 -- Macro: PARSE_LDD_OUTPUT (PTR)
1 Define this macro to be C code that extracts filenames from the
1 output of the program denoted by 'LDD_SUFFIX'. PTR is a variable
1 of type 'char *' that points to the beginning of a line of output
1 from 'LDD_SUFFIX'. If the line lists a dynamic dependency, the
1 code must advance PTR to the beginning of the filename on that
1 line. Otherwise, it must set PTR to 'NULL'.
1
1 -- Macro: SHLIB_SUFFIX
1 Define this macro to a C string constant containing the default
1 shared library extension of the target (e.g., '".so"'). 'collect2'
1 strips version information after this suffix when generating global
1 constructor and destructor names. This define is only needed on
1 targets that use 'collect2' to process constructors and
1 destructors.
1