Sections.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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-2017 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 5.2, http://www.gnu.org/software/texinfo/ -->
  18. <head>
  19. <title>GNU Compiler Collection (GCC) Internals: Sections</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Sections">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Sections">
  22. <meta name="resource-type" content="document">
  23. <meta name="distribution" content="global">
  24. <meta name="Generator" content="makeinfo">
  25. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  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="Target-Macros.html#Target-Macros" rel="up" title="Target Macros">
  30. <link href="PIC.html#PIC" rel="next" title="PIC">
  31. <link href="Scheduling.html#Scheduling" rel="prev" title="Scheduling">
  32. <style type="text/css">
  33. <!--
  34. a.summary-letter {text-decoration: none}
  35. blockquote.smallquotation {font-size: smaller}
  36. div.display {margin-left: 3.2em}
  37. div.example {margin-left: 3.2em}
  38. div.indentedblock {margin-left: 3.2em}
  39. div.lisp {margin-left: 3.2em}
  40. div.smalldisplay {margin-left: 3.2em}
  41. div.smallexample {margin-left: 3.2em}
  42. div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
  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.nocodebreak {white-space:nowrap}
  54. span.nolinebreak {white-space:nowrap}
  55. span.roman {font-family:serif; font-weight:normal}
  56. span.sansserif {font-family:sans-serif; font-weight:normal}
  57. ul.no-bullet {list-style: none}
  58. -->
  59. </style>
  60. </head>
  61. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  62. <a name="Sections"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="PIC.html#PIC" accesskey="n" rel="next">PIC</a>, Previous: <a href="Scheduling.html#Scheduling" accesskey="p" rel="prev">Scheduling</a>, Up: <a href="Target-Macros.html#Target-Macros" accesskey="u" rel="up">Target Macros</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>
  66. </div>
  67. <hr>
  68. <a name="Dividing-the-Output-into-Sections-_0028Texts_002c-Data_002c-_2026_0029"></a>
  69. <h3 class="section">17.18 Dividing the Output into Sections (Texts, Data, &hellip;)</h3>
  70. <p>An object file is divided into sections containing different types of
  71. data. In the most common case, there are three sections: the <em>text
  72. section</em>, which holds instructions and read-only data; the <em>data
  73. section</em>, which holds initialized writable data; and the <em>bss
  74. section</em>, which holds uninitialized data. Some systems have other kinds
  75. of sections.
  76. </p>
  77. <p><samp>varasm.c</samp> provides several well-known sections, such as
  78. <code>text_section</code>, <code>data_section</code> and <code>bss_section</code>.
  79. The normal way of controlling a <code><var>foo</var>_section</code> variable
  80. is to define the associated <code><var>FOO</var>_SECTION_ASM_OP</code> macro,
  81. as described below. The macros are only read once, when <samp>varasm.c</samp>
  82. initializes itself, so their values must be run-time constants.
  83. They may however depend on command-line flags.
  84. </p>
  85. <p><em>Note:</em> Some run-time files, such <samp>crtstuff.c</samp>, also make
  86. use of the <code><var>FOO</var>_SECTION_ASM_OP</code> macros, and expect them
  87. to be string literals.
  88. </p>
  89. <p>Some assemblers require a different string to be written every time a
  90. section is selected. If your assembler falls into this category, you
  91. should define the <code>TARGET_ASM_INIT_SECTIONS</code> hook and use
  92. <code>get_unnamed_section</code> to set up the sections.
  93. </p>
  94. <p>You must always create a <code>text_section</code>, either by defining
  95. <code>TEXT_SECTION_ASM_OP</code> or by initializing <code>text_section</code>
  96. in <code>TARGET_ASM_INIT_SECTIONS</code>. The same is true of
  97. <code>data_section</code> and <code>DATA_SECTION_ASM_OP</code>. If you do not
  98. create a distinct <code>readonly_data_section</code>, the default is to
  99. reuse <code>text_section</code>.
  100. </p>
  101. <p>All the other <samp>varasm.c</samp> sections are optional, and are null
  102. if the target does not provide them.
  103. </p>
  104. <dl>
  105. <dt><a name="index-TEXT_005fSECTION_005fASM_005fOP"></a>Macro: <strong>TEXT_SECTION_ASM_OP</strong></dt>
  106. <dd><p>A C expression whose value is a string, including spacing, containing the
  107. assembler operation that should precede instructions and read-only data.
  108. Normally <code>&quot;\t.text&quot;</code> is right.
  109. </p></dd></dl>
  110. <dl>
  111. <dt><a name="index-HOT_005fTEXT_005fSECTION_005fNAME"></a>Macro: <strong>HOT_TEXT_SECTION_NAME</strong></dt>
  112. <dd><p>If defined, a C string constant for the name of the section containing most
  113. frequently executed functions of the program. If not defined, GCC will provide
  114. a default definition if the target supports named sections.
  115. </p></dd></dl>
  116. <dl>
  117. <dt><a name="index-UNLIKELY_005fEXECUTED_005fTEXT_005fSECTION_005fNAME"></a>Macro: <strong>UNLIKELY_EXECUTED_TEXT_SECTION_NAME</strong></dt>
  118. <dd><p>If defined, a C string constant for the name of the section containing unlikely
  119. executed functions in the program.
  120. </p></dd></dl>
  121. <dl>
  122. <dt><a name="index-DATA_005fSECTION_005fASM_005fOP"></a>Macro: <strong>DATA_SECTION_ASM_OP</strong></dt>
  123. <dd><p>A C expression whose value is a string, including spacing, containing the
  124. assembler operation to identify the following data as writable initialized
  125. data. Normally <code>&quot;\t.data&quot;</code> is right.
  126. </p></dd></dl>
  127. <dl>
  128. <dt><a name="index-SDATA_005fSECTION_005fASM_005fOP"></a>Macro: <strong>SDATA_SECTION_ASM_OP</strong></dt>
  129. <dd><p>If defined, a C expression whose value is a string, including spacing,
  130. containing the assembler operation to identify the following data as
  131. initialized, writable small data.
  132. </p></dd></dl>
  133. <dl>
  134. <dt><a name="index-READONLY_005fDATA_005fSECTION_005fASM_005fOP"></a>Macro: <strong>READONLY_DATA_SECTION_ASM_OP</strong></dt>
  135. <dd><p>A C expression whose value is a string, including spacing, containing the
  136. assembler operation to identify the following data as read-only initialized
  137. data.
  138. </p></dd></dl>
  139. <dl>
  140. <dt><a name="index-BSS_005fSECTION_005fASM_005fOP"></a>Macro: <strong>BSS_SECTION_ASM_OP</strong></dt>
  141. <dd><p>If defined, a C expression whose value is a string, including spacing,
  142. containing the assembler operation to identify the following data as
  143. uninitialized global data. If not defined, and
  144. <code>ASM_OUTPUT_ALIGNED_BSS</code> not defined,
  145. uninitialized global data will be output in the data section if
  146. <samp>-fno-common</samp> is passed, otherwise <code>ASM_OUTPUT_COMMON</code> will be
  147. used.
  148. </p></dd></dl>
  149. <dl>
  150. <dt><a name="index-SBSS_005fSECTION_005fASM_005fOP"></a>Macro: <strong>SBSS_SECTION_ASM_OP</strong></dt>
  151. <dd><p>If defined, a C expression whose value is a string, including spacing,
  152. containing the assembler operation to identify the following data as
  153. uninitialized, writable small data.
  154. </p></dd></dl>
  155. <dl>
  156. <dt><a name="index-TLS_005fCOMMON_005fASM_005fOP"></a>Macro: <strong>TLS_COMMON_ASM_OP</strong></dt>
  157. <dd><p>If defined, a C expression whose value is a string containing the
  158. assembler operation to identify the following data as thread-local
  159. common data. The default is <code>&quot;.tls_common&quot;</code>.
  160. </p></dd></dl>
  161. <dl>
  162. <dt><a name="index-TLS_005fSECTION_005fASM_005fFLAG"></a>Macro: <strong>TLS_SECTION_ASM_FLAG</strong></dt>
  163. <dd><p>If defined, a C expression whose value is a character constant
  164. containing the flag used to mark a section as a TLS section. The
  165. default is <code>'T'</code>.
  166. </p></dd></dl>
  167. <dl>
  168. <dt><a name="index-INIT_005fSECTION_005fASM_005fOP"></a>Macro: <strong>INIT_SECTION_ASM_OP</strong></dt>
  169. <dd><p>If defined, a C expression whose value is a string, including spacing,
  170. containing the assembler operation to identify the following data as
  171. initialization code. If not defined, GCC will assume such a section does
  172. not exist. This section has no corresponding <code>init_section</code>
  173. variable; it is used entirely in runtime code.
  174. </p></dd></dl>
  175. <dl>
  176. <dt><a name="index-FINI_005fSECTION_005fASM_005fOP"></a>Macro: <strong>FINI_SECTION_ASM_OP</strong></dt>
  177. <dd><p>If defined, a C expression whose value is a string, including spacing,
  178. containing the assembler operation to identify the following data as
  179. finalization code. If not defined, GCC will assume such a section does
  180. not exist. This section has no corresponding <code>fini_section</code>
  181. variable; it is used entirely in runtime code.
  182. </p></dd></dl>
  183. <dl>
  184. <dt><a name="index-INIT_005fARRAY_005fSECTION_005fASM_005fOP"></a>Macro: <strong>INIT_ARRAY_SECTION_ASM_OP</strong></dt>
  185. <dd><p>If defined, a C expression whose value is a string, including spacing,
  186. containing the assembler operation to identify the following data as
  187. part of the <code>.init_array</code> (or equivalent) section. If not
  188. defined, GCC will assume such a section does not exist. Do not define
  189. both this macro and <code>INIT_SECTION_ASM_OP</code>.
  190. </p></dd></dl>
  191. <dl>
  192. <dt><a name="index-FINI_005fARRAY_005fSECTION_005fASM_005fOP"></a>Macro: <strong>FINI_ARRAY_SECTION_ASM_OP</strong></dt>
  193. <dd><p>If defined, a C expression whose value is a string, including spacing,
  194. containing the assembler operation to identify the following data as
  195. part of the <code>.fini_array</code> (or equivalent) section. If not
  196. defined, GCC will assume such a section does not exist. Do not define
  197. both this macro and <code>FINI_SECTION_ASM_OP</code>.
  198. </p></dd></dl>
  199. <dl>
  200. <dt><a name="index-MACH_005fDEP_005fSECTION_005fASM_005fFLAG"></a>Macro: <strong>MACH_DEP_SECTION_ASM_FLAG</strong></dt>
  201. <dd><p>If defined, a C expression whose value is a character constant
  202. containing the flag used to mark a machine-dependent section. This
  203. corresponds to the <code>SECTION_MACH_DEP</code> section flag.
  204. </p></dd></dl>
  205. <dl>
  206. <dt><a name="index-CRT_005fCALL_005fSTATIC_005fFUNCTION"></a>Macro: <strong>CRT_CALL_STATIC_FUNCTION</strong> <em>(<var>section_op</var>, <var>function</var>)</em></dt>
  207. <dd><p>If defined, an ASM statement that switches to a different section
  208. via <var>section_op</var>, calls <var>function</var>, and switches back to
  209. the text section. This is used in <samp>crtstuff.c</samp> if
  210. <code>INIT_SECTION_ASM_OP</code> or <code>FINI_SECTION_ASM_OP</code> to calls
  211. to initialization and finalization functions from the init and fini
  212. sections. By default, this macro uses a simple function call. Some
  213. ports need hand-crafted assembly code to avoid dependencies on
  214. registers initialized in the function prologue or to ensure that
  215. constant pools don&rsquo;t end up too far way in the text section.
  216. </p></dd></dl>
  217. <dl>
  218. <dt><a name="index-TARGET_005fLIBGCC_005fSDATA_005fSECTION"></a>Macro: <strong>TARGET_LIBGCC_SDATA_SECTION</strong></dt>
  219. <dd><p>If defined, a string which names the section into which small
  220. variables defined in crtstuff and libgcc should go. This is useful
  221. when the target has options for optimizing access to small data, and
  222. you want the crtstuff and libgcc routines to be conservative in what
  223. they expect of your application yet liberal in what your application
  224. expects. For example, for targets with a <code>.sdata</code> section (like
  225. MIPS), you could compile crtstuff with <code>-G 0</code> so that it doesn&rsquo;t
  226. require small data support from your application, but use this macro
  227. to put small data into <code>.sdata</code> so that your application can
  228. access these variables whether it uses small data or not.
  229. </p></dd></dl>
  230. <dl>
  231. <dt><a name="index-FORCE_005fCODE_005fSECTION_005fALIGN"></a>Macro: <strong>FORCE_CODE_SECTION_ALIGN</strong></dt>
  232. <dd><p>If defined, an ASM statement that aligns a code section to some
  233. arbitrary boundary. This is used to force all fragments of the
  234. <code>.init</code> and <code>.fini</code> sections to have to same alignment
  235. and thus prevent the linker from having to add any padding.
  236. </p></dd></dl>
  237. <dl>
  238. <dt><a name="index-JUMP_005fTABLES_005fIN_005fTEXT_005fSECTION"></a>Macro: <strong>JUMP_TABLES_IN_TEXT_SECTION</strong></dt>
  239. <dd><p>Define this macro to be an expression with a nonzero value if jump
  240. tables (for <code>tablejump</code> insns) should be output in the text
  241. section, along with the assembler instructions. Otherwise, the
  242. readonly data section is used.
  243. </p>
  244. <p>This macro is irrelevant if there is no separate readonly data section.
  245. </p></dd></dl>
  246. <dl>
  247. <dt><a name="index-TARGET_005fASM_005fINIT_005fSECTIONS"></a>Target Hook: <em>void</em> <strong>TARGET_ASM_INIT_SECTIONS</strong> <em>(void)</em></dt>
  248. <dd><p>Define this hook if you need to do something special to set up the
  249. <samp>varasm.c</samp> sections, or if your target has some special sections
  250. of its own that you need to create.
  251. </p>
  252. <p>GCC calls this hook after processing the command line, but before writing
  253. any assembly code, and before calling any of the section-returning hooks
  254. described below.
  255. </p></dd></dl>
  256. <dl>
  257. <dt><a name="index-TARGET_005fASM_005fRELOC_005fRW_005fMASK"></a>Target Hook: <em>int</em> <strong>TARGET_ASM_RELOC_RW_MASK</strong> <em>(void)</em></dt>
  258. <dd><p>Return a mask describing how relocations should be treated when
  259. selecting sections. Bit 1 should be set if global relocations
  260. should be placed in a read-write section; bit 0 should be set if
  261. local relocations should be placed in a read-write section.
  262. </p>
  263. <p>The default version of this function returns 3 when <samp>-fpic</samp>
  264. is in effect, and 0 otherwise. The hook is typically redefined
  265. when the target cannot support (some kinds of) dynamic relocations
  266. in read-only sections even in executables.
  267. </p></dd></dl>
  268. <dl>
  269. <dt><a name="index-TARGET_005fASM_005fSELECT_005fSECTION"></a>Target Hook: <em>section *</em> <strong>TARGET_ASM_SELECT_SECTION</strong> <em>(tree <var>exp</var>, int <var>reloc</var>, unsigned HOST_WIDE_INT <var>align</var>)</em></dt>
  270. <dd><p>Return the section into which <var>exp</var> should be placed. You can
  271. assume that <var>exp</var> is either a <code>VAR_DECL</code> node or a constant of
  272. some sort. <var>reloc</var> indicates whether the initial value of <var>exp</var>
  273. requires link-time relocations. Bit 0 is set when variable contains
  274. local relocations only, while bit 1 is set for global relocations.
  275. <var>align</var> is the constant alignment in bits.
  276. </p>
  277. <p>The default version of this function takes care of putting read-only
  278. variables in <code>readonly_data_section</code>.
  279. </p>
  280. <p>See also <var>USE_SELECT_SECTION_FOR_FUNCTIONS</var>.
  281. </p></dd></dl>
  282. <dl>
  283. <dt><a name="index-USE_005fSELECT_005fSECTION_005fFOR_005fFUNCTIONS"></a>Macro: <strong>USE_SELECT_SECTION_FOR_FUNCTIONS</strong></dt>
  284. <dd><p>Define this macro if you wish TARGET_ASM_SELECT_SECTION to be called
  285. for <code>FUNCTION_DECL</code>s as well as for variables and constants.
  286. </p>
  287. <p>In the case of a <code>FUNCTION_DECL</code>, <var>reloc</var> will be zero if the
  288. function has been determined to be likely to be called, and nonzero if
  289. it is unlikely to be called.
  290. </p></dd></dl>
  291. <dl>
  292. <dt><a name="index-TARGET_005fASM_005fUNIQUE_005fSECTION"></a>Target Hook: <em>void</em> <strong>TARGET_ASM_UNIQUE_SECTION</strong> <em>(tree <var>decl</var>, int <var>reloc</var>)</em></dt>
  293. <dd><p>Build up a unique section name, expressed as a <code>STRING_CST</code> node,
  294. and assign it to &lsquo;<samp>DECL_SECTION_NAME (<var>decl</var>)</samp>&rsquo;.
  295. As with <code>TARGET_ASM_SELECT_SECTION</code>, <var>reloc</var> indicates whether
  296. the initial value of <var>exp</var> requires link-time relocations.
  297. </p>
  298. <p>The default version of this function appends the symbol name to the
  299. ELF section name that would normally be used for the symbol. For
  300. example, the function <code>foo</code> would be placed in <code>.text.foo</code>.
  301. Whatever the actual target object format, this is often good enough.
  302. </p></dd></dl>
  303. <dl>
  304. <dt><a name="index-TARGET_005fASM_005fFUNCTION_005fRODATA_005fSECTION"></a>Target Hook: <em>section *</em> <strong>TARGET_ASM_FUNCTION_RODATA_SECTION</strong> <em>(tree <var>decl</var>)</em></dt>
  305. <dd><p>Return the readonly data section associated with
  306. &lsquo;<samp>DECL_SECTION_NAME (<var>decl</var>)</samp>&rsquo;.
  307. The default version of this function selects <code>.gnu.linkonce.r.name</code> if
  308. the function&rsquo;s section is <code>.gnu.linkonce.t.name</code>, <code>.rodata.name</code>
  309. if function is in <code>.text.name</code>, and the normal readonly-data section
  310. otherwise.
  311. </p></dd></dl>
  312. <dl>
  313. <dt><a name="index-TARGET_005fASM_005fMERGEABLE_005fRODATA_005fPREFIX"></a>Target Hook: <em>const char *</em> <strong>TARGET_ASM_MERGEABLE_RODATA_PREFIX</strong></dt>
  314. <dd><p>Usually, the compiler uses the prefix <code>&quot;.rodata&quot;</code> to construct
  315. section names for mergeable constant data. Define this macro to override
  316. the string if a different section name should be used.
  317. </p></dd></dl>
  318. <dl>
  319. <dt><a name="index-TARGET_005fASM_005fTM_005fCLONE_005fTABLE_005fSECTION"></a>Target Hook: <em>section *</em> <strong>TARGET_ASM_TM_CLONE_TABLE_SECTION</strong> <em>(void)</em></dt>
  320. <dd><p>Return the section that should be used for transactional memory clone tables.
  321. </p></dd></dl>
  322. <dl>
  323. <dt><a name="index-TARGET_005fASM_005fSELECT_005fRTX_005fSECTION"></a>Target Hook: <em>section *</em> <strong>TARGET_ASM_SELECT_RTX_SECTION</strong> <em>(machine_mode <var>mode</var>, rtx <var>x</var>, unsigned HOST_WIDE_INT <var>align</var>)</em></dt>
  324. <dd><p>Return the section into which a constant <var>x</var>, of mode <var>mode</var>,
  325. should be placed. You can assume that <var>x</var> is some kind of
  326. constant in RTL. The argument <var>mode</var> is redundant except in the
  327. case of a <code>const_int</code> rtx. <var>align</var> is the constant alignment
  328. in bits.
  329. </p>
  330. <p>The default version of this function takes care of putting symbolic
  331. constants in <code>flag_pic</code> mode in <code>data_section</code> and everything
  332. else in <code>readonly_data_section</code>.
  333. </p></dd></dl>
  334. <dl>
  335. <dt><a name="index-TARGET_005fMANGLE_005fDECL_005fASSEMBLER_005fNAME"></a>Target Hook: <em>tree</em> <strong>TARGET_MANGLE_DECL_ASSEMBLER_NAME</strong> <em>(tree <var>decl</var>, tree <var>id</var>)</em></dt>
  336. <dd><p>Define this hook if you need to postprocess the assembler name generated
  337. by target-independent code. The <var>id</var> provided to this hook will be
  338. the computed name (e.g., the macro <code>DECL_NAME</code> of the <var>decl</var> in C,
  339. or the mangled name of the <var>decl</var> in C++). The return value of the
  340. hook is an <code>IDENTIFIER_NODE</code> for the appropriate mangled name on
  341. your target system. The default implementation of this hook just
  342. returns the <var>id</var> provided.
  343. </p></dd></dl>
  344. <dl>
  345. <dt><a name="index-TARGET_005fENCODE_005fSECTION_005fINFO"></a>Target Hook: <em>void</em> <strong>TARGET_ENCODE_SECTION_INFO</strong> <em>(tree <var>decl</var>, rtx <var>rtl</var>, int <var>new_decl_p</var>)</em></dt>
  346. <dd><p>Define this hook if references to a symbol or a constant must be
  347. treated differently depending on something about the variable or
  348. function named by the symbol (such as what section it is in).
  349. </p>
  350. <p>The hook is executed immediately after rtl has been created for
  351. <var>decl</var>, which may be a variable or function declaration or
  352. an entry in the constant pool. In either case, <var>rtl</var> is the
  353. rtl in question. Do <em>not</em> use <code>DECL_RTL (<var>decl</var>)</code>
  354. in this hook; that field may not have been initialized yet.
  355. </p>
  356. <p>In the case of a constant, it is safe to assume that the rtl is
  357. a <code>mem</code> whose address is a <code>symbol_ref</code>. Most decls
  358. will also have this form, but that is not guaranteed. Global
  359. register variables, for instance, will have a <code>reg</code> for their
  360. rtl. (Normally the right thing to do with such unusual rtl is
  361. leave it alone.)
  362. </p>
  363. <p>The <var>new_decl_p</var> argument will be true if this is the first time
  364. that <code>TARGET_ENCODE_SECTION_INFO</code> has been invoked on this decl. It will
  365. be false for subsequent invocations, which will happen for duplicate
  366. declarations. Whether or not anything must be done for the duplicate
  367. declaration depends on whether the hook examines <code>DECL_ATTRIBUTES</code>.
  368. <var>new_decl_p</var> is always true when the hook is called for a constant.
  369. </p>
  370. <a name="index-SYMBOL_005fREF_005fFLAG_002c-in-TARGET_005fENCODE_005fSECTION_005fINFO"></a>
  371. <p>The usual thing for this hook to do is to record flags in the
  372. <code>symbol_ref</code>, using <code>SYMBOL_REF_FLAG</code> or <code>SYMBOL_REF_FLAGS</code>.
  373. Historically, the name string was modified if it was necessary to
  374. encode more than one bit of information, but this practice is now
  375. discouraged; use <code>SYMBOL_REF_FLAGS</code>.
  376. </p>
  377. <p>The default definition of this hook, <code>default_encode_section_info</code>
  378. in <samp>varasm.c</samp>, sets a number of commonly-useful bits in
  379. <code>SYMBOL_REF_FLAGS</code>. Check whether the default does what you need
  380. before overriding it.
  381. </p></dd></dl>
  382. <dl>
  383. <dt><a name="index-TARGET_005fSTRIP_005fNAME_005fENCODING"></a>Target Hook: <em>const char *</em> <strong>TARGET_STRIP_NAME_ENCODING</strong> <em>(const char *<var>name</var>)</em></dt>
  384. <dd><p>Decode <var>name</var> and return the real name part, sans
  385. the characters that <code>TARGET_ENCODE_SECTION_INFO</code>
  386. may have added.
  387. </p></dd></dl>
  388. <dl>
  389. <dt><a name="index-TARGET_005fIN_005fSMALL_005fDATA_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_IN_SMALL_DATA_P</strong> <em>(const_tree <var>exp</var>)</em></dt>
  390. <dd><p>Returns true if <var>exp</var> should be placed into a &ldquo;small data&rdquo; section.
  391. The default version of this hook always returns false.
  392. </p></dd></dl>
  393. <dl>
  394. <dt><a name="index-TARGET_005fHAVE_005fSRODATA_005fSECTION"></a>Target Hook: <em>bool</em> <strong>TARGET_HAVE_SRODATA_SECTION</strong></dt>
  395. <dd><p>Contains the value true if the target places read-only
  396. &ldquo;small data&rdquo; into a separate section. The default value is false.
  397. </p></dd></dl>
  398. <dl>
  399. <dt><a name="index-TARGET_005fPROFILE_005fBEFORE_005fPROLOGUE"></a>Target Hook: <em>bool</em> <strong>TARGET_PROFILE_BEFORE_PROLOGUE</strong> <em>(void)</em></dt>
  400. <dd><p>It returns true if target wants profile code emitted before prologue.
  401. </p>
  402. <p>The default version of this hook use the target macro
  403. <code>PROFILE_BEFORE_PROLOGUE</code>.
  404. </p></dd></dl>
  405. <dl>
  406. <dt><a name="index-TARGET_005fBINDS_005fLOCAL_005fP"></a>Target Hook: <em>bool</em> <strong>TARGET_BINDS_LOCAL_P</strong> <em>(const_tree <var>exp</var>)</em></dt>
  407. <dd><p>Returns true if <var>exp</var> names an object for which name resolution
  408. rules must resolve to the current &ldquo;module&rdquo; (dynamic shared library
  409. or executable image).
  410. </p>
  411. <p>The default version of this hook implements the name resolution rules
  412. for ELF, which has a looser model of global name binding than other
  413. currently supported object file formats.
  414. </p></dd></dl>
  415. <dl>
  416. <dt><a name="index-TARGET_005fHAVE_005fTLS"></a>Target Hook: <em>bool</em> <strong>TARGET_HAVE_TLS</strong></dt>
  417. <dd><p>Contains the value true if the target supports thread-local storage.
  418. The default value is false.
  419. </p></dd></dl>
  420. <hr>
  421. <div class="header">
  422. <p>
  423. Next: <a href="PIC.html#PIC" accesskey="n" rel="next">PIC</a>, Previous: <a href="Scheduling.html#Scheduling" accesskey="p" rel="prev">Scheduling</a>, Up: <a href="Target-Macros.html#Target-Macros" accesskey="u" rel="up">Target Macros</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>
  424. </div>
  425. </body>
  426. </html>