You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

255 lines
12KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1988-2020 Free Software Foundation, Inc.
  4. Permission is granted to copy, distribute and/or modify this document
  5. under the terms of the GNU Free Documentation License, Version 1.3 or
  6. any later version published by the Free Software Foundation; with the
  7. Invariant Sections being "Funding Free Software", the Front-Cover
  8. Texts being (a) (see below), and with the Back-Cover Texts being (b)
  9. (see below). A copy of the license is included in the section entitled
  10. "GNU Free Documentation License".
  11. (a) The FSF's Front-Cover Text is:
  12. A GNU Manual
  13. (b) The FSF's Back-Cover Text is:
  14. You have freedom to copy and modify this GNU Manual, like GNU
  15. software. Copies published by the Free Software Foundation raise
  16. funds for GNU development. -->
  17. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <title>Macros for Initialization (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="Macros for Initialization (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="Macros for Initialization (GNU Compiler Collection (GCC) Internals)">
  23. <meta name="resource-type" content="document">
  24. <meta name="distribution" content="global">
  25. <meta name="Generator" content="makeinfo">
  26. <link href="index.html#Top" rel="start" title="Top">
  27. <link href="Option-Index.html#Option-Index" rel="index" title="Option Index">
  28. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  29. <link href="Assembler-Format.html#Assembler-Format" rel="up" title="Assembler Format">
  30. <link href="Instruction-Output.html#Instruction-Output" rel="next" title="Instruction Output">
  31. <link href="Initialization.html#Initialization" rel="prev" title="Initialization">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.indentedblock {margin-right: 0em}
  36. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  37. blockquote.smallquotation {font-size: smaller}
  38. div.display {margin-left: 3.2em}
  39. div.example {margin-left: 3.2em}
  40. div.lisp {margin-left: 3.2em}
  41. div.smalldisplay {margin-left: 3.2em}
  42. div.smallexample {margin-left: 3.2em}
  43. div.smalllisp {margin-left: 3.2em}
  44. kbd {font-style: oblique}
  45. pre.display {font-family: inherit}
  46. pre.format {font-family: inherit}
  47. pre.menu-comment {font-family: serif}
  48. pre.menu-preformatted {font-family: serif}
  49. pre.smalldisplay {font-family: inherit; font-size: smaller}
  50. pre.smallexample {font-size: smaller}
  51. pre.smallformat {font-family: inherit; font-size: smaller}
  52. pre.smalllisp {font-size: smaller}
  53. span.nolinebreak {white-space: nowrap}
  54. span.roman {font-family: initial; font-weight: normal}
  55. span.sansserif {font-family: sans-serif; font-weight: normal}
  56. ul.no-bullet {list-style: none}
  57. -->
  58. </style>
  59. </head>
  60. <body lang="en">
  61. <a name="Macros-for-Initialization"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Instruction-Output.html#Instruction-Output" accesskey="n" rel="next">Instruction Output</a>, Previous: <a href="Initialization.html#Initialization" accesskey="p" rel="prev">Initialization</a>, Up: <a href="Assembler-Format.html#Assembler-Format" accesskey="u" rel="up">Assembler Format</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  65. </div>
  66. <hr>
  67. <a name="Macros-Controlling-Initialization-Routines"></a>
  68. <h4 class="subsection">18.20.6 Macros Controlling Initialization Routines</h4>
  69. <p>Here are the macros that control how the compiler handles initialization
  70. and termination functions:
  71. </p>
  72. <dl>
  73. <dt><a name="index-INIT_005fSECTION_005fASM_005fOP-1"></a>Macro: <strong>INIT_SECTION_ASM_OP</strong></dt>
  74. <dd><p>If defined, a C string constant, including spacing, for the assembler
  75. operation to identify the following data as initialization code. If not
  76. defined, GCC will assume such a section does not exist. When you are
  77. using special sections for initialization and termination functions, this
  78. macro also controls how <samp>crtstuff.c</samp> and <samp>libgcc2.c</samp> arrange to
  79. run the initialization functions.
  80. </p></dd></dl>
  81. <dl>
  82. <dt><a name="index-HAS_005fINIT_005fSECTION"></a>Macro: <strong>HAS_INIT_SECTION</strong></dt>
  83. <dd><p>If defined, <code>main</code> will not call <code>__main</code> as described above.
  84. This macro should be defined for systems that control start-up code
  85. on a symbol-by-symbol basis, such as OSF/1, and should not
  86. be defined explicitly for systems that support <code>INIT_SECTION_ASM_OP</code>.
  87. </p></dd></dl>
  88. <dl>
  89. <dt><a name="index-LD_005fINIT_005fSWITCH"></a>Macro: <strong>LD_INIT_SWITCH</strong></dt>
  90. <dd><p>If defined, a C string constant for a switch that tells the linker that
  91. the following symbol is an initialization routine.
  92. </p></dd></dl>
  93. <dl>
  94. <dt><a name="index-LD_005fFINI_005fSWITCH"></a>Macro: <strong>LD_FINI_SWITCH</strong></dt>
  95. <dd><p>If defined, a C string constant for a switch that tells the linker that
  96. the following symbol is a finalization routine.
  97. </p></dd></dl>
  98. <dl>
  99. <dt><a name="index-COLLECT_005fSHARED_005fINIT_005fFUNC"></a>Macro: <strong>COLLECT_SHARED_INIT_FUNC</strong> <em>(<var>stream</var>, <var>func</var>)</em></dt>
  100. <dd><p>If defined, a C statement that will write a function that can be
  101. automatically called when a shared library is loaded. The function
  102. should call <var>func</var>, which takes no arguments. If not defined, and
  103. the object format requires an explicit initialization function, then a
  104. function called <code>_GLOBAL__DI</code> will be generated.
  105. </p>
  106. <p>This function and the following one are used by collect2 when linking a
  107. shared library that needs constructors or destructors, or has DWARF2
  108. exception tables embedded in the code.
  109. </p></dd></dl>
  110. <dl>
  111. <dt><a name="index-COLLECT_005fSHARED_005fFINI_005fFUNC"></a>Macro: <strong>COLLECT_SHARED_FINI_FUNC</strong> <em>(<var>stream</var>, <var>func</var>)</em></dt>
  112. <dd><p>If defined, a C statement that will write a function that can be
  113. automatically called when a shared library is unloaded. The function
  114. should call <var>func</var>, which takes no arguments. If not defined, and
  115. the object format requires an explicit finalization function, then a
  116. function called <code>_GLOBAL__DD</code> will be generated.
  117. </p></dd></dl>
  118. <dl>
  119. <dt><a name="index-INVOKE_005f_005fmain"></a>Macro: <strong>INVOKE__main</strong></dt>
  120. <dd><p>If defined, <code>main</code> will call <code>__main</code> despite the presence of
  121. <code>INIT_SECTION_ASM_OP</code>. This macro should be defined for systems
  122. where the init section is not actually run automatically, but is still
  123. useful for collecting the lists of constructors and destructors.
  124. </p></dd></dl>
  125. <dl>
  126. <dt><a name="index-SUPPORTS_005fINIT_005fPRIORITY"></a>Macro: <strong>SUPPORTS_INIT_PRIORITY</strong></dt>
  127. <dd><p>If nonzero, the C++ <code>init_priority</code> attribute is supported and the
  128. compiler should emit instructions to control the order of initialization
  129. of objects. If zero, the compiler will issue an error message upon
  130. encountering an <code>init_priority</code> attribute.
  131. </p></dd></dl>
  132. <dl>
  133. <dt><a name="index-TARGET_005fHAVE_005fCTORS_005fDTORS"></a>Target Hook: <em>bool</em> <strong>TARGET_HAVE_CTORS_DTORS</strong></dt>
  134. <dd><p>This value is true if the target supports some &ldquo;native&rdquo; method of
  135. collecting constructors and destructors to be run at startup and exit.
  136. It is false if we must use <code>collect2</code>.
  137. </p></dd></dl>
  138. <dl>
  139. <dt><a name="index-TARGET_005fASM_005fCONSTRUCTOR"></a>Target Hook: <em>void</em> <strong>TARGET_ASM_CONSTRUCTOR</strong> <em>(rtx <var>symbol</var>, int <var>priority</var>)</em></dt>
  140. <dd><p>If defined, a function that outputs assembler code to arrange to call
  141. the function referenced by <var>symbol</var> at initialization time.
  142. </p>
  143. <p>Assume that <var>symbol</var> is a <code>SYMBOL_REF</code> for a function taking
  144. no arguments and with no return value. If the target supports initialization
  145. priorities, <var>priority</var> is a value between 0 and <code>MAX_INIT_PRIORITY</code>;
  146. otherwise it must be <code>DEFAULT_INIT_PRIORITY</code>.
  147. </p>
  148. <p>If this macro is not defined by the target, a suitable default will
  149. be chosen if (1) the target supports arbitrary section names, (2) the
  150. target defines <code>CTORS_SECTION_ASM_OP</code>, or (3) <code>USE_COLLECT2</code>
  151. is not defined.
  152. </p></dd></dl>
  153. <dl>
  154. <dt><a name="index-TARGET_005fASM_005fDESTRUCTOR"></a>Target Hook: <em>void</em> <strong>TARGET_ASM_DESTRUCTOR</strong> <em>(rtx <var>symbol</var>, int <var>priority</var>)</em></dt>
  155. <dd><p>This is like <code>TARGET_ASM_CONSTRUCTOR</code> but used for termination
  156. functions rather than initialization functions.
  157. </p></dd></dl>
  158. <p>If <code>TARGET_HAVE_CTORS_DTORS</code> is true, the initialization routine
  159. generated for the generated object file will have static linkage.
  160. </p>
  161. <p>If your system uses <code>collect2</code> as the means of processing
  162. constructors, then that program normally uses <code>nm</code> to scan
  163. an object file for constructor functions to be called.
  164. </p>
  165. <p>On certain kinds of systems, you can define this macro to make
  166. <code>collect2</code> work faster (and, in some cases, make it work at all):
  167. </p>
  168. <dl>
  169. <dt><a name="index-OBJECT_005fFORMAT_005fCOFF"></a>Macro: <strong>OBJECT_FORMAT_COFF</strong></dt>
  170. <dd><p>Define this macro if the system uses COFF (Common Object File Format)
  171. object files, so that <code>collect2</code> can assume this format and scan
  172. object files directly for dynamic constructor/destructor functions.
  173. </p>
  174. <p>This macro is effective only in a native compiler; <code>collect2</code> as
  175. part of a cross compiler always uses <code>nm</code> for the target machine.
  176. </p></dd></dl>
  177. <dl>
  178. <dt><a name="index-REAL_005fNM_005fFILE_005fNAME"></a>Macro: <strong>REAL_NM_FILE_NAME</strong></dt>
  179. <dd><p>Define this macro as a C string constant containing the file name to use
  180. to execute <code>nm</code>. The default is to search the path normally for
  181. <code>nm</code>.
  182. </p></dd></dl>
  183. <dl>
  184. <dt><a name="index-NM_005fFLAGS"></a>Macro: <strong>NM_FLAGS</strong></dt>
  185. <dd><p><code>collect2</code> calls <code>nm</code> to scan object files for static
  186. constructors and destructors and LTO info. By default, <samp>-n</samp> is
  187. passed. Define <code>NM_FLAGS</code> to a C string constant if other options
  188. are needed to get the same output format as GNU <code>nm -n</code>
  189. produces.
  190. </p></dd></dl>
  191. <p>If your system supports shared libraries and has a program to list the
  192. dynamic dependencies of a given library or executable, you can define
  193. these macros to enable support for running initialization and
  194. termination functions in shared libraries:
  195. </p>
  196. <dl>
  197. <dt><a name="index-LDD_005fSUFFIX"></a>Macro: <strong>LDD_SUFFIX</strong></dt>
  198. <dd><p>Define this macro to a C string constant containing the name of the program
  199. which lists dynamic dependencies, like <code>ldd</code> under SunOS 4.
  200. </p></dd></dl>
  201. <dl>
  202. <dt><a name="index-PARSE_005fLDD_005fOUTPUT"></a>Macro: <strong>PARSE_LDD_OUTPUT</strong> <em>(<var>ptr</var>)</em></dt>
  203. <dd><p>Define this macro to be C code that extracts filenames from the output
  204. of the program denoted by <code>LDD_SUFFIX</code>. <var>ptr</var> is a variable
  205. of type <code>char *</code> that points to the beginning of a line of output
  206. from <code>LDD_SUFFIX</code>. If the line lists a dynamic dependency, the
  207. code must advance <var>ptr</var> to the beginning of the filename on that
  208. line. Otherwise, it must set <var>ptr</var> to <code>NULL</code>.
  209. </p></dd></dl>
  210. <dl>
  211. <dt><a name="index-SHLIB_005fSUFFIX"></a>Macro: <strong>SHLIB_SUFFIX</strong></dt>
  212. <dd><p>Define this macro to a C string constant containing the default shared
  213. library extension of the target (e.g., &lsquo;<samp>&quot;.so&quot;</samp>&rsquo;). <code>collect2</code>
  214. strips version information after this suffix when generating global
  215. constructor and destructor names. This define is only needed on targets
  216. that use <code>collect2</code> to process constructors and destructors.
  217. </p></dd></dl>
  218. <hr>
  219. <div class="header">
  220. <p>
  221. Next: <a href="Instruction-Output.html#Instruction-Output" accesskey="n" rel="next">Instruction Output</a>, Previous: <a href="Initialization.html#Initialization" accesskey="p" rel="prev">Initialization</a>, Up: <a href="Assembler-Format.html#Assembler-Format" accesskey="u" rel="up">Assembler Format</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html#Option-Index" title="Index" rel="index">Index</a>]</p>
  222. </div>
  223. </body>
  224. </html>