Movatterモバイル変換


[0]ホーム

URL:


Next:, Previous:, Up:Defining the Output Assembler Language   [Contents][Index]


17.22.6 Macros Controlling Initialization Routines

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

Macro:INIT_SECTION_ASM_OP

If defined, a C string constant, including spacing, for the assembleroperation to identify the following data as initialization code. If notdefined, GCC will assume such a section does not exist. When you areusing special sections for initialization and termination functions, thismacro also controls howcrtstuff.c andlibgcc2.c arrange torun the initialization functions.

Macro:HAS_INIT_SECTION

If defined,main will not call__main as described above.This macro should be defined for systems that control start-up codeon a symbol-by-symbol basis, such as OSF/1, and should notbe defined explicitly for systems that supportINIT_SECTION_ASM_OP.

Macro:LD_INIT_SWITCH

If defined, a C string constant for a switch that tells the linker thatthe following symbol is an initialization routine.

Macro:LD_FINI_SWITCH

If defined, a C string constant for a switch that tells the linker thatthe following symbol is a finalization routine.

Macro:COLLECT_SHARED_INIT_FUNC(stream,func)

If defined, a C statement that will write a function that can beautomatically called when a shared library is loaded. The functionshould callfunc, which takes no arguments. If not defined, andthe object format requires an explicit initialization function, then afunction called_GLOBAL__DI will be generated.

This function and the following one are used by collect2 when linking ashared library that needs constructors or destructors, or has DWARF2exception tables embedded in the code.

Macro:COLLECT_SHARED_FINI_FUNC(stream,func)

If defined, a C statement that will write a function that can beautomatically called when a shared library is unloaded. The functionshould callfunc, which takes no arguments. If not defined, andthe object format requires an explicit finalization function, then afunction called_GLOBAL__DD will be generated.

Macro:INVOKE__main

If defined,main will call__main despite the presence ofINIT_SECTION_ASM_OP. This macro should be defined for systemswhere the init section is not actually run automatically, but is stilluseful for collecting the lists of constructors and destructors.

Macro:SUPPORTS_INIT_PRIORITY

If nonzero, the C++init_priority attribute is supported and thecompiler should emit instructions to control the order of initializationof objects. If zero, the compiler will issue an error message uponencountering aninit_priority attribute.

Target Hook:boolTARGET_HAVE_CTORS_DTORS

This value is true if the target supports some “native” method ofcollecting constructors and destructors to be run at startup and exit.It is false if we must usecollect2.

Target Hook:boolTARGET_DTORS_FROM_CXA_ATEXIT

This value is true if the target wants destructors to be queued to berun from__cxa_atexit. If this is the case then, for eachpriority level, a new constructor will be entered that registers thedestructors for that level with__cxa_atexit (and there will beno destructors emitted).It is false the method implied byhave_ctors_dtors is used.

Target Hook:voidTARGET_ASM_CONSTRUCTOR(rtxsymbol, intpriority)

If defined, a function that outputs assembler code to arrange to callthe function referenced bysymbol at initialization time.

Assume thatsymbol is aSYMBOL_REF for a function takingno arguments and with no return value. If the target supports initializationpriorities,priority is a value between 0 andMAX_INIT_PRIORITY;otherwise it must beDEFAULT_INIT_PRIORITY.

If this macro is not defined by the target, a suitable default willbe chosen if (1) the target supports arbitrary section names, (2) thetarget definesCTORS_SECTION_ASM_OP, or (3)USE_COLLECT2is not defined.

Target Hook:voidTARGET_ASM_DESTRUCTOR(rtxsymbol, intpriority)

This is likeTARGET_ASM_CONSTRUCTOR but used for terminationfunctions rather than initialization functions.

IfTARGET_HAVE_CTORS_DTORS is true, the initialization routinegenerated for the generated object file will have static linkage.

If your system usescollect2 as the means of processingconstructors, then that program normally usesnm to scanan object file for constructor functions to be called.

On certain kinds of systems, you can define this macro to makecollect2 work faster (and, in some cases, make it work at all):

Macro:OBJECT_FORMAT_COFF

Define this macro if the system uses COFF (Common Object File Format)object files, so thatcollect2 can assume this format and scanobject files directly for dynamic constructor/destructor functions.

This macro is effective only in a native compiler;collect2 aspart of a cross compiler always usesnm for the target machine.

Macro:REAL_NM_FILE_NAME

Define this macro as a C string constant containing the file name to useto executenm. The default is to search the path normally fornm.

Macro:NM_FLAGS

collect2 callsnm to scan object files for staticconstructors and destructors and LTO info. By default,-n ispassed. DefineNM_FLAGS to a C string constant if other optionsare needed to get the same output format as GNUnm -nproduces.

If your system supports shared libraries and has a program to list thedynamic dependencies of a given library or executable, you can definethese macros to enable support for running initialization andtermination functions in shared libraries:

Macro:LDD_SUFFIX

Define this macro to a C string constant containing the name of the programwhich lists dynamic dependencies, likeldd under SunOS 4.

Macro:PARSE_LDD_OUTPUT(ptr)

Define this macro to be C code that extracts filenames from the outputof the program denoted byLDD_SUFFIX.ptr is a variableof typechar * that points to the beginning of a line of outputfromLDD_SUFFIX. If the line lists a dynamic dependency, thecode must advanceptr to the beginning of the filename on thatline. Otherwise, it must setptr toNULL.

Macro:SHLIB_SUFFIX

Define this macro to a C string constant containing the default sharedlibrary extension of the target (e.g., ‘".so"’).collect2strips version information after this suffix when generating globalconstructor and destructor names. This define is only needed on targetsthat usecollect2 to process constructors and destructors.


Next:Output of Assembler Instructions, Previous:How Initialization Functions Are Handled, Up:Defining the Output Assembler Language   [Contents][Index]


[8]ページ先頭

©2009-2026 Movatter.jp