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.

344 lines
18KB

  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>File Framework (GNU Compiler Collection (GCC) Internals)</title>
  21. <meta name="description" content="File Framework (GNU Compiler Collection (GCC) Internals)">
  22. <meta name="keywords" content="File Framework (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="Data-Output.html#Data-Output" rel="next" title="Data Output">
  31. <link href="Assembler-Format.html#Assembler-Format" rel="prev" title="Assembler Format">
  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="File-Framework"></a>
  62. <div class="header">
  63. <p>
  64. Next: <a href="Data-Output.html#Data-Output" accesskey="n" rel="next">Data Output</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="The-Overall-Framework-of-an-Assembler-File"></a>
  68. <h4 class="subsection">18.20.1 The Overall Framework of an Assembler File</h4>
  69. <a name="index-assembler-format"></a>
  70. <a name="index-output-of-assembler-code"></a>
  71. <p>This describes the overall framework of an assembly file.
  72. </p>
  73. <a name="index-default_005ffile_005fstart"></a>
  74. <dl>
  75. <dt><a name="index-TARGET_005fASM_005fFILE_005fSTART"></a>Target Hook: <em>void</em> <strong>TARGET_ASM_FILE_START</strong> <em>(void)</em></dt>
  76. <dd><p>Output to <code>asm_out_file</code> any text which the assembler expects to
  77. find at the beginning of a file. The default behavior is controlled
  78. by two flags, documented below. Unless your target&rsquo;s assembler is
  79. quite unusual, if you override the default, you should call
  80. <code>default_file_start</code> at some point in your target hook. This
  81. lets other target files rely on these variables.
  82. </p></dd></dl>
  83. <dl>
  84. <dt><a name="index-TARGET_005fASM_005fFILE_005fSTART_005fAPP_005fOFF"></a>Target Hook: <em>bool</em> <strong>TARGET_ASM_FILE_START_APP_OFF</strong></dt>
  85. <dd><p>If this flag is true, the text of the macro <code>ASM_APP_OFF</code> will be
  86. printed as the very first line in the assembly file, unless
  87. <samp>-fverbose-asm</samp> is in effect. (If that macro has been defined
  88. to the empty string, this variable has no effect.) With the normal
  89. definition of <code>ASM_APP_OFF</code>, the effect is to notify the GNU
  90. assembler that it need not bother stripping comments or extra
  91. whitespace from its input. This allows it to work a bit faster.
  92. </p>
  93. <p>The default is false. You should not set it to true unless you have
  94. verified that your port does not generate any extra whitespace or
  95. comments that will cause GAS to issue errors in NO_APP mode.
  96. </p></dd></dl>
  97. <dl>
  98. <dt><a name="index-TARGET_005fASM_005fFILE_005fSTART_005fFILE_005fDIRECTIVE"></a>Target Hook: <em>bool</em> <strong>TARGET_ASM_FILE_START_FILE_DIRECTIVE</strong></dt>
  99. <dd><p>If this flag is true, <code>output_file_directive</code> will be called
  100. for the primary source file, immediately after printing
  101. <code>ASM_APP_OFF</code> (if that is enabled). Most ELF assemblers expect
  102. this to be done. The default is false.
  103. </p></dd></dl>
  104. <dl>
  105. <dt><a name="index-TARGET_005fASM_005fFILE_005fEND"></a>Target Hook: <em>void</em> <strong>TARGET_ASM_FILE_END</strong> <em>(void)</em></dt>
  106. <dd><p>Output to <code>asm_out_file</code> any text which the assembler expects
  107. to find at the end of a file. The default is to output nothing.
  108. </p></dd></dl>
  109. <dl>
  110. <dt><a name="index-file_005fend_005findicate_005fexec_005fstack"></a>Function: <em>void</em> <strong>file_end_indicate_exec_stack</strong> <em>()</em></dt>
  111. <dd><p>Some systems use a common convention, the &lsquo;<samp>.note.GNU-stack</samp>&rsquo;
  112. special section, to indicate whether or not an object file relies on
  113. the stack being executable. If your system uses this convention, you
  114. should define <code>TARGET_ASM_FILE_END</code> to this function. If you
  115. need to do other things in that hook, have your hook function call
  116. this function.
  117. </p></dd></dl>
  118. <dl>
  119. <dt><a name="index-TARGET_005fASM_005fLTO_005fSTART"></a>Target Hook: <em>void</em> <strong>TARGET_ASM_LTO_START</strong> <em>(void)</em></dt>
  120. <dd><p>Output to <code>asm_out_file</code> any text which the assembler expects
  121. to find at the start of an LTO section. The default is to output
  122. nothing.
  123. </p></dd></dl>
  124. <dl>
  125. <dt><a name="index-TARGET_005fASM_005fLTO_005fEND"></a>Target Hook: <em>void</em> <strong>TARGET_ASM_LTO_END</strong> <em>(void)</em></dt>
  126. <dd><p>Output to <code>asm_out_file</code> any text which the assembler expects
  127. to find at the end of an LTO section. The default is to output
  128. nothing.
  129. </p></dd></dl>
  130. <dl>
  131. <dt><a name="index-TARGET_005fASM_005fCODE_005fEND"></a>Target Hook: <em>void</em> <strong>TARGET_ASM_CODE_END</strong> <em>(void)</em></dt>
  132. <dd><p>Output to <code>asm_out_file</code> any text which is needed before emitting
  133. unwind info and debug info at the end of a file. Some targets emit
  134. here PIC setup thunks that cannot be emitted at the end of file,
  135. because they couldn&rsquo;t have unwind info then. The default is to output
  136. nothing.
  137. </p></dd></dl>
  138. <dl>
  139. <dt><a name="index-ASM_005fCOMMENT_005fSTART"></a>Macro: <strong>ASM_COMMENT_START</strong></dt>
  140. <dd><p>A C string constant describing how to begin a comment in the target
  141. assembler language. The compiler assumes that the comment will end at
  142. the end of the line.
  143. </p></dd></dl>
  144. <dl>
  145. <dt><a name="index-ASM_005fAPP_005fON"></a>Macro: <strong>ASM_APP_ON</strong></dt>
  146. <dd><p>A C string constant for text to be output before each <code>asm</code>
  147. statement or group of consecutive ones. Normally this is
  148. <code>&quot;#APP&quot;</code>, which is a comment that has no effect on most
  149. assemblers but tells the GNU assembler that it must check the lines
  150. that follow for all valid assembler constructs.
  151. </p></dd></dl>
  152. <dl>
  153. <dt><a name="index-ASM_005fAPP_005fOFF"></a>Macro: <strong>ASM_APP_OFF</strong></dt>
  154. <dd><p>A C string constant for text to be output after each <code>asm</code>
  155. statement or group of consecutive ones. Normally this is
  156. <code>&quot;#NO_APP&quot;</code>, which tells the GNU assembler to resume making the
  157. time-saving assumptions that are valid for ordinary compiler output.
  158. </p></dd></dl>
  159. <dl>
  160. <dt><a name="index-ASM_005fOUTPUT_005fSOURCE_005fFILENAME"></a>Macro: <strong>ASM_OUTPUT_SOURCE_FILENAME</strong> <em>(<var>stream</var>, <var>name</var>)</em></dt>
  161. <dd><p>A C statement to output COFF information or DWARF debugging information
  162. which indicates that filename <var>name</var> is the current source file to
  163. the stdio stream <var>stream</var>.
  164. </p>
  165. <p>This macro need not be defined if the standard form of output
  166. for the file format in use is appropriate.
  167. </p></dd></dl>
  168. <dl>
  169. <dt><a name="index-TARGET_005fASM_005fOUTPUT_005fSOURCE_005fFILENAME"></a>Target Hook: <em>void</em> <strong>TARGET_ASM_OUTPUT_SOURCE_FILENAME</strong> <em>(FILE *<var>file</var>, const char *<var>name</var>)</em></dt>
  170. <dd><p>Output DWARF debugging information which indicates that filename <var>name</var> is the current source file to the stdio stream <var>file</var>.
  171. </p>
  172. <p>This target hook need not be defined if the standard form of output for the file format in use is appropriate.
  173. </p></dd></dl>
  174. <dl>
  175. <dt><a name="index-TARGET_005fASM_005fOUTPUT_005fIDENT"></a>Target Hook: <em>void</em> <strong>TARGET_ASM_OUTPUT_IDENT</strong> <em>(const char *<var>name</var>)</em></dt>
  176. <dd><p>Output a string based on <var>name</var>, suitable for the &lsquo;<samp>#ident</samp>&rsquo; directive, or the equivalent directive or pragma in non-C-family languages. If this hook is not defined, nothing is output for the &lsquo;<samp>#ident</samp>&rsquo; directive.
  177. </p></dd></dl>
  178. <dl>
  179. <dt><a name="index-OUTPUT_005fQUOTED_005fSTRING"></a>Macro: <strong>OUTPUT_QUOTED_STRING</strong> <em>(<var>stream</var>, <var>string</var>)</em></dt>
  180. <dd><p>A C statement to output the string <var>string</var> to the stdio stream
  181. <var>stream</var>. If you do not call the function <code>output_quoted_string</code>
  182. in your config files, GCC will only call it to output filenames to
  183. the assembler source. So you can use it to canonicalize the format
  184. of the filename using this macro.
  185. </p></dd></dl>
  186. <dl>
  187. <dt><a name="index-TARGET_005fASM_005fNAMED_005fSECTION"></a>Target Hook: <em>void</em> <strong>TARGET_ASM_NAMED_SECTION</strong> <em>(const char *<var>name</var>, unsigned int <var>flags</var>, tree <var>decl</var>)</em></dt>
  188. <dd><p>Output assembly directives to switch to section <var>name</var>. The section
  189. should have attributes as specified by <var>flags</var>, which is a bit mask
  190. of the <code>SECTION_*</code> flags defined in <samp>output.h</samp>. If <var>decl</var>
  191. is non-NULL, it is the <code>VAR_DECL</code> or <code>FUNCTION_DECL</code> with which
  192. this section is associated.
  193. </p></dd></dl>
  194. <dl>
  195. <dt><a name="index-TARGET_005fASM_005fELF_005fFLAGS_005fNUMERIC"></a>Target Hook: <em>bool</em> <strong>TARGET_ASM_ELF_FLAGS_NUMERIC</strong> <em>(unsigned int <var>flags</var>, unsigned int *<var>num</var>)</em></dt>
  196. <dd><p>This hook can be used to encode ELF section flags for which no letter
  197. code has been defined in the assembler. It is called by
  198. <code>default_asm_named_section</code> whenever the section flags need to be
  199. emitted in the assembler output. If the hook returns true, then the
  200. numerical value for ELF section flags should be calculated from
  201. <var>flags</var> and saved in <var>*num</var>; the value is printed out instead of the
  202. normal sequence of letter codes. If the hook is not defined, or if it
  203. returns false, then <var>num</var> is ignored and the traditional letter sequence
  204. is emitted.
  205. </p></dd></dl>
  206. <dl>
  207. <dt><a name="index-TARGET_005fASM_005fFUNCTION_005fSECTION"></a>Target Hook: <em>section *</em> <strong>TARGET_ASM_FUNCTION_SECTION</strong> <em>(tree <var>decl</var>, enum node_frequency <var>freq</var>, bool <var>startup</var>, bool <var>exit</var>)</em></dt>
  208. <dd><p>Return preferred text (sub)section for function <var>decl</var>.
  209. Main purpose of this function is to separate cold, normal and hot
  210. functions. <var>startup</var> is true when function is known to be used only
  211. at startup (from static constructors or it is <code>main()</code>).
  212. <var>exit</var> is true when function is known to be used only at exit
  213. (from static destructors).
  214. Return NULL if function should go to default text section.
  215. </p></dd></dl>
  216. <dl>
  217. <dt><a name="index-TARGET_005fASM_005fFUNCTION_005fSWITCHED_005fTEXT_005fSECTIONS"></a>Target Hook: <em>void</em> <strong>TARGET_ASM_FUNCTION_SWITCHED_TEXT_SECTIONS</strong> <em>(FILE *<var>file</var>, tree <var>decl</var>, bool <var>new_is_cold</var>)</em></dt>
  218. <dd><p>Used by the target to emit any assembler directives or additional labels needed when a function is partitioned between different sections. Output should be written to <var>file</var>. The function decl is available as <var>decl</var> and the new section is &lsquo;cold&rsquo; if <var>new_is_cold</var> is <code>true</code>.
  219. </p></dd></dl>
  220. <dl>
  221. <dt><a name="index-TARGET_005fHAVE_005fNAMED_005fSECTIONS"></a>Common Target Hook: <em>bool</em> <strong>TARGET_HAVE_NAMED_SECTIONS</strong></dt>
  222. <dd><p>This flag is true if the target supports <code>TARGET_ASM_NAMED_SECTION</code>.
  223. It must not be modified by command-line option processing.
  224. </p></dd></dl>
  225. <a name="TARGET_005fHAVE_005fSWITCHABLE_005fBSS_005fSECTIONS"></a><dl>
  226. <dt><a name="index-TARGET_005fHAVE_005fSWITCHABLE_005fBSS_005fSECTIONS"></a>Target Hook: <em>bool</em> <strong>TARGET_HAVE_SWITCHABLE_BSS_SECTIONS</strong></dt>
  227. <dd><p>This flag is true if we can create zeroed data by switching to a BSS
  228. section and then using <code>ASM_OUTPUT_SKIP</code> to allocate the space.
  229. This is true on most ELF targets.
  230. </p></dd></dl>
  231. <dl>
  232. <dt><a name="index-TARGET_005fSECTION_005fTYPE_005fFLAGS"></a>Target Hook: <em>unsigned int</em> <strong>TARGET_SECTION_TYPE_FLAGS</strong> <em>(tree <var>decl</var>, const char *<var>name</var>, int <var>reloc</var>)</em></dt>
  233. <dd><p>Choose a set of section attributes for use by <code>TARGET_ASM_NAMED_SECTION</code>
  234. based on a variable or function decl, a section name, and whether or not the
  235. declaration&rsquo;s initializer may contain runtime relocations. <var>decl</var> may be
  236. null, in which case read-write data should be assumed.
  237. </p>
  238. <p>The default version of this function handles choosing code vs data,
  239. read-only vs read-write data, and <code>flag_pic</code>. You should only
  240. need to override this if your target has special flags that might be
  241. set via <code>__attribute__</code>.
  242. </p></dd></dl>
  243. <dl>
  244. <dt><a name="index-TARGET_005fASM_005fRECORD_005fGCC_005fSWITCHES"></a>Target Hook: <em>int</em> <strong>TARGET_ASM_RECORD_GCC_SWITCHES</strong> <em>(print_switch_type <var>type</var>, const char *<var>text</var>)</em></dt>
  245. <dd><p>Provides the target with the ability to record the gcc command line
  246. switches that have been passed to the compiler, and options that are
  247. enabled. The <var>type</var> argument specifies what is being recorded.
  248. It can take the following values:
  249. </p>
  250. <dl compact="compact">
  251. <dt><code>SWITCH_TYPE_PASSED</code></dt>
  252. <dd><p><var>text</var> is a command line switch that has been set by the user.
  253. </p>
  254. </dd>
  255. <dt><code>SWITCH_TYPE_ENABLED</code></dt>
  256. <dd><p><var>text</var> is an option which has been enabled. This might be as a
  257. direct result of a command line switch, or because it is enabled by
  258. default or because it has been enabled as a side effect of a different
  259. command line switch. For example, the <samp>-O2</samp> switch enables
  260. various different individual optimization passes.
  261. </p>
  262. </dd>
  263. <dt><code>SWITCH_TYPE_DESCRIPTIVE</code></dt>
  264. <dd><p><var>text</var> is either NULL or some descriptive text which should be
  265. ignored. If <var>text</var> is NULL then it is being used to warn the
  266. target hook that either recording is starting or ending. The first
  267. time <var>type</var> is SWITCH_TYPE_DESCRIPTIVE and <var>text</var> is NULL, the
  268. warning is for start up and the second time the warning is for
  269. wind down. This feature is to allow the target hook to make any
  270. necessary preparations before it starts to record switches and to
  271. perform any necessary tidying up after it has finished recording
  272. switches.
  273. </p>
  274. </dd>
  275. <dt><code>SWITCH_TYPE_LINE_START</code></dt>
  276. <dd><p>This option can be ignored by this target hook.
  277. </p>
  278. </dd>
  279. <dt><code>SWITCH_TYPE_LINE_END</code></dt>
  280. <dd><p>This option can be ignored by this target hook.
  281. </p></dd>
  282. </dl>
  283. <p>The hook&rsquo;s return value must be zero. Other return values may be
  284. supported in the future.
  285. </p>
  286. <p>By default this hook is set to NULL, but an example implementation is
  287. provided for ELF based targets. Called <var>elf_record_gcc_switches</var>,
  288. it records the switches as ASCII text inside a new, string mergeable
  289. section in the assembler output file. The name of the new section is
  290. provided by the <code>TARGET_ASM_RECORD_GCC_SWITCHES_SECTION</code> target
  291. hook.
  292. </p></dd></dl>
  293. <dl>
  294. <dt><a name="index-TARGET_005fASM_005fRECORD_005fGCC_005fSWITCHES_005fSECTION"></a>Target Hook: <em>const char *</em> <strong>TARGET_ASM_RECORD_GCC_SWITCHES_SECTION</strong></dt>
  295. <dd><p>This is the name of the section that will be created by the example
  296. ELF implementation of the <code>TARGET_ASM_RECORD_GCC_SWITCHES</code> target
  297. hook.
  298. </p></dd></dl>
  299. <hr>
  300. <div class="header">
  301. <p>
  302. Next: <a href="Data-Output.html#Data-Output" accesskey="n" rel="next">Data Output</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>
  303. </div>
  304. </body>
  305. </html>