Uninitialized-Data.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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: Uninitialized Data</title>
  20. <meta name="description" content="GNU Compiler Collection (GCC) Internals: Uninitialized Data">
  21. <meta name="keywords" content="GNU Compiler Collection (GCC) Internals: Uninitialized Data">
  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="Assembler-Format.html#Assembler-Format" rel="up" title="Assembler Format">
  30. <link href="Label-Output.html#Label-Output" rel="next" title="Label Output">
  31. <link href="Data-Output.html#Data-Output" rel="prev" title="Data Output">
  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="Uninitialized-Data"></a>
  63. <div class="header">
  64. <p>
  65. Next: <a href="Label-Output.html#Label-Output" accesskey="n" rel="next">Label Output</a>, Previous: <a href="Data-Output.html#Data-Output" accesskey="p" rel="prev">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>
  66. </div>
  67. <hr>
  68. <a name="Output-of-Uninitialized-Variables"></a>
  69. <h4 class="subsection">17.20.3 Output of Uninitialized Variables</h4>
  70. <p>Each of the macros in this section is used to do the whole job of
  71. outputting a single uninitialized variable.
  72. </p>
  73. <dl>
  74. <dt><a name="index-ASM_005fOUTPUT_005fCOMMON"></a>Macro: <strong>ASM_OUTPUT_COMMON</strong> <em>(<var>stream</var>, <var>name</var>, <var>size</var>, <var>rounded</var>)</em></dt>
  75. <dd><p>A C statement (sans semicolon) to output to the stdio stream
  76. <var>stream</var> the assembler definition of a common-label named
  77. <var>name</var> whose size is <var>size</var> bytes. The variable <var>rounded</var>
  78. is the size rounded up to whatever alignment the caller wants. It is
  79. possible that <var>size</var> may be zero, for instance if a struct with no
  80. other member than a zero-length array is defined. In this case, the
  81. backend must output a symbol definition that allocates at least one
  82. byte, both so that the address of the resulting object does not compare
  83. equal to any other, and because some object formats cannot even express
  84. the concept of a zero-sized common symbol, as that is how they represent
  85. an ordinary undefined external.
  86. </p>
  87. <p>Use the expression <code>assemble_name (<var>stream</var>, <var>name</var>)</code> to
  88. output the name itself; before and after that, output the additional
  89. assembler syntax for defining the name, and a newline.
  90. </p>
  91. <p>This macro controls how the assembler definitions of uninitialized
  92. common global variables are output.
  93. </p></dd></dl>
  94. <dl>
  95. <dt><a name="index-ASM_005fOUTPUT_005fALIGNED_005fCOMMON"></a>Macro: <strong>ASM_OUTPUT_ALIGNED_COMMON</strong> <em>(<var>stream</var>, <var>name</var>, <var>size</var>, <var>alignment</var>)</em></dt>
  96. <dd><p>Like <code>ASM_OUTPUT_COMMON</code> except takes the required alignment as a
  97. separate, explicit argument. If you define this macro, it is used in
  98. place of <code>ASM_OUTPUT_COMMON</code>, and gives you more flexibility in
  99. handling the required alignment of the variable. The alignment is specified
  100. as the number of bits.
  101. </p></dd></dl>
  102. <dl>
  103. <dt><a name="index-ASM_005fOUTPUT_005fALIGNED_005fDECL_005fCOMMON"></a>Macro: <strong>ASM_OUTPUT_ALIGNED_DECL_COMMON</strong> <em>(<var>stream</var>, <var>decl</var>, <var>name</var>, <var>size</var>, <var>alignment</var>)</em></dt>
  104. <dd><p>Like <code>ASM_OUTPUT_ALIGNED_COMMON</code> except that <var>decl</var> of the
  105. variable to be output, if there is one, or <code>NULL_TREE</code> if there
  106. is no corresponding variable. If you define this macro, GCC will use it
  107. in place of both <code>ASM_OUTPUT_COMMON</code> and
  108. <code>ASM_OUTPUT_ALIGNED_COMMON</code>. Define this macro when you need to see
  109. the variable&rsquo;s decl in order to chose what to output.
  110. </p></dd></dl>
  111. <dl>
  112. <dt><a name="index-ASM_005fOUTPUT_005fALIGNED_005fBSS"></a>Macro: <strong>ASM_OUTPUT_ALIGNED_BSS</strong> <em>(<var>stream</var>, <var>decl</var>, <var>name</var>, <var>size</var>, <var>alignment</var>)</em></dt>
  113. <dd><p>A C statement (sans semicolon) to output to the stdio stream
  114. <var>stream</var> the assembler definition of uninitialized global <var>decl</var> named
  115. <var>name</var> whose size is <var>size</var> bytes. The variable <var>alignment</var>
  116. is the alignment specified as the number of bits.
  117. </p>
  118. <p>Try to use function <code>asm_output_aligned_bss</code> defined in file
  119. <samp>varasm.c</samp> when defining this macro. If unable, use the expression
  120. <code>assemble_name (<var>stream</var>, <var>name</var>)</code> to output the name itself;
  121. before and after that, output the additional assembler syntax for defining
  122. the name, and a newline.
  123. </p>
  124. <p>There are two ways of handling global BSS. One is to define this macro.
  125. The other is to have <code>TARGET_ASM_SELECT_SECTION</code> return a
  126. switchable BSS section (see <a href="File-Framework.html#TARGET_005fHAVE_005fSWITCHABLE_005fBSS_005fSECTIONS">TARGET_HAVE_SWITCHABLE_BSS_SECTIONS</a>).
  127. You do not need to do both.
  128. </p>
  129. <p>Some languages do not have <code>common</code> data, and require a
  130. non-common form of global BSS in order to handle uninitialized globals
  131. efficiently. C++ is one example of this. However, if the target does
  132. not support global BSS, the front end may choose to make globals
  133. common in order to save space in the object file.
  134. </p></dd></dl>
  135. <dl>
  136. <dt><a name="index-ASM_005fOUTPUT_005fLOCAL"></a>Macro: <strong>ASM_OUTPUT_LOCAL</strong> <em>(<var>stream</var>, <var>name</var>, <var>size</var>, <var>rounded</var>)</em></dt>
  137. <dd><p>A C statement (sans semicolon) to output to the stdio stream
  138. <var>stream</var> the assembler definition of a local-common-label named
  139. <var>name</var> whose size is <var>size</var> bytes. The variable <var>rounded</var>
  140. is the size rounded up to whatever alignment the caller wants.
  141. </p>
  142. <p>Use the expression <code>assemble_name (<var>stream</var>, <var>name</var>)</code> to
  143. output the name itself; before and after that, output the additional
  144. assembler syntax for defining the name, and a newline.
  145. </p>
  146. <p>This macro controls how the assembler definitions of uninitialized
  147. static variables are output.
  148. </p></dd></dl>
  149. <dl>
  150. <dt><a name="index-ASM_005fOUTPUT_005fALIGNED_005fLOCAL"></a>Macro: <strong>ASM_OUTPUT_ALIGNED_LOCAL</strong> <em>(<var>stream</var>, <var>name</var>, <var>size</var>, <var>alignment</var>)</em></dt>
  151. <dd><p>Like <code>ASM_OUTPUT_LOCAL</code> except takes the required alignment as a
  152. separate, explicit argument. If you define this macro, it is used in
  153. place of <code>ASM_OUTPUT_LOCAL</code>, and gives you more flexibility in
  154. handling the required alignment of the variable. The alignment is specified
  155. as the number of bits.
  156. </p></dd></dl>
  157. <dl>
  158. <dt><a name="index-ASM_005fOUTPUT_005fALIGNED_005fDECL_005fLOCAL"></a>Macro: <strong>ASM_OUTPUT_ALIGNED_DECL_LOCAL</strong> <em>(<var>stream</var>, <var>decl</var>, <var>name</var>, <var>size</var>, <var>alignment</var>)</em></dt>
  159. <dd><p>Like <code>ASM_OUTPUT_ALIGNED_DECL</code> except that <var>decl</var> of the
  160. variable to be output, if there is one, or <code>NULL_TREE</code> if there
  161. is no corresponding variable. If you define this macro, GCC will use it
  162. in place of both <code>ASM_OUTPUT_DECL</code> and
  163. <code>ASM_OUTPUT_ALIGNED_DECL</code>. Define this macro when you need to see
  164. the variable&rsquo;s decl in order to chose what to output.
  165. </p></dd></dl>
  166. <hr>
  167. <div class="header">
  168. <p>
  169. Next: <a href="Label-Output.html#Label-Output" accesskey="n" rel="next">Label Output</a>, Previous: <a href="Data-Output.html#Data-Output" accesskey="p" rel="prev">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>
  170. </div>
  171. </body>
  172. </html>