Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

133 lines
7.3KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1992-2020 Free Software Foundation, Inc.
  4. Contributed by Cygnus Support. Written by Julia Menapace, Jim Kingdon,
  5. and David MacKenzie.
  6. Permission is granted to copy, distribute and/or modify this document
  7. under the terms of the GNU Free Documentation License, Version 1.3 or
  8. any later version published by the Free Software Foundation; with no
  9. Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
  10. Texts. A copy of the license is included in the section entitled "GNU
  11. Free Documentation License". -->
  12. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  15. <title>ELF Linker Relocation (STABS)</title>
  16. <meta name="description" content="ELF Linker Relocation (STABS)">
  17. <meta name="keywords" content="ELF Linker Relocation (STABS)">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <link href="index.html#Top" rel="start" title="Top">
  22. <link href="Symbol-Types-Index.html#Symbol-Types-Index" rel="index" title="Symbol Types Index">
  23. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  24. <link href="Stab-Sections.html#Stab-Sections" rel="up" title="Stab Sections">
  25. <link href="GNU-Free-Documentation-License.html#GNU-Free-Documentation-License" rel="next" title="GNU Free Documentation License">
  26. <link href="Stab-Section-Basics.html#Stab-Section-Basics" rel="prev" title="Stab Section Basics">
  27. <style type="text/css">
  28. <!--
  29. a.summary-letter {text-decoration: none}
  30. blockquote.indentedblock {margin-right: 0em}
  31. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  32. blockquote.smallquotation {font-size: smaller}
  33. div.display {margin-left: 3.2em}
  34. div.example {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smalllisp {margin-left: 3.2em}
  39. kbd {font-style: oblique}
  40. pre.display {font-family: inherit}
  41. pre.format {font-family: inherit}
  42. pre.menu-comment {font-family: serif}
  43. pre.menu-preformatted {font-family: serif}
  44. pre.smalldisplay {font-family: inherit; font-size: smaller}
  45. pre.smallexample {font-size: smaller}
  46. pre.smallformat {font-family: inherit; font-size: smaller}
  47. pre.smalllisp {font-size: smaller}
  48. span.nolinebreak {white-space: nowrap}
  49. span.roman {font-family: initial; font-weight: normal}
  50. span.sansserif {font-family: sans-serif; font-weight: normal}
  51. ul.no-bullet {list-style: none}
  52. -->
  53. </style>
  54. </head>
  55. <body lang="en">
  56. <a name="ELF-Linker-Relocation"></a>
  57. <div class="header">
  58. <p>
  59. Previous: <a href="Stab-Section-Basics.html#Stab-Section-Basics" accesskey="p" rel="prev">Stab Section Basics</a>, Up: <a href="Stab-Sections.html#Stab-Sections" accesskey="u" rel="up">Stab Sections</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Types-Index.html#Symbol-Types-Index" title="Index" rel="index">Index</a>]</p>
  60. </div>
  61. <hr>
  62. <a name="Having-the-Linker-Relocate-Stabs-in-ELF"></a>
  63. <h3 class="appendixsec">F.2 Having the Linker Relocate Stabs in ELF</h3>
  64. <p>This section describes some Sun hacks for Stabs in ELF; it does not
  65. apply to COFF or SOM. While <small>GDB</small> no longer supports this hack
  66. for Sun Stabs in ELF, this section is kept to document the issue.
  67. </p>
  68. <p>To keep linking fast, you don&rsquo;t want the linker to have to relocate very
  69. many stabs. Making sure this is done for <code>N_SLINE</code>,
  70. <code>N_RBRAC</code>, and <code>N_LBRAC</code> stabs is the most important thing
  71. (see the descriptions of those stabs for more information). But Sun&rsquo;s
  72. stabs in ELF has taken this further, to make all addresses in the
  73. <code>n_value</code> field (functions and static variables) relative to the
  74. source file. For the <code>N_SO</code> symbol itself, Sun simply omits the
  75. address. To find the address of each section corresponding to a given
  76. source file, the compiler puts out symbols giving the address of each
  77. section for a given source file. Since these are ELF (not stab)
  78. symbols, the linker relocates them correctly without having to touch the
  79. stabs section. They are named <code>Bbss.bss</code> for the bss section,
  80. <code>Ddata.data</code> for the data section, and <code>Drodata.rodata</code> for
  81. the rodata section. For the text section, there is no such symbol (but
  82. there should be, see below). For an example of how these symbols work,
  83. See <a href="Stab-Section-Transformations.html#Stab-Section-Transformations">Stab Section Transformations</a>. GCC does not provide these symbols;
  84. it instead relies on the stabs getting relocated. Thus addresses which
  85. would normally be relative to <code>Bbss.bss</code>, etc., are already
  86. relocated. The Sun linker provided with Solaris 2.2 and earlier
  87. relocates stabs using normal ELF relocation information, as it would do
  88. for any section. Sun has been threatening to kludge their linker to not
  89. do this (to speed up linking), even though the correct way to avoid
  90. having the linker do these relocations is to have the compiler no longer
  91. output relocatable values. Last I heard they had been talked out of the
  92. linker kludge. See Sun point patch 101052-01 and Sun bug 1142109. With
  93. the Sun compiler this affects &lsquo;<samp>S</samp>&rsquo; symbol descriptor stabs
  94. (see <a href="Statics.html#Statics">Statics</a>) and functions (see <a href="Procedures.html#Procedures">Procedures</a>). In the latter
  95. case, to adopt the clean solution (making the value of the stab relative
  96. to the start of the compilation unit), it would be necessary to invent a
  97. <code>Ttext.text</code> symbol, analogous to the <code>Bbss.bss</code>, etc.,
  98. symbols. I recommend this rather than using a zero value and getting
  99. the address from the ELF symbols.
  100. </p>
  101. <p>Finding the correct <code>Bbss.bss</code>, etc., symbol is difficult, because
  102. the linker simply concatenates the <code>.stab</code> sections from each
  103. <samp>.o</samp> file without including any information about which part of a
  104. <code>.stab</code> section comes from which <samp>.o</samp> file. The way GDB use to
  105. do this is to look for an ELF <code>STT_FILE</code> symbol which has the same
  106. name as the last component of the file name from the <code>N_SO</code> symbol
  107. in the stabs (for example, if the file name is <samp>../../gdb/main.c</samp>,
  108. it looks for an ELF <code>STT_FILE</code> symbol named <code>main.c</code>). This
  109. loses if different files have the same name (they could be in different
  110. directories, a library could have been copied from one system to
  111. another, etc.). It would be much cleaner to have the <code>Bbss.bss</code>
  112. symbols in the stabs themselves. Having the linker relocate them there
  113. is no more work than having the linker relocate ELF symbols, and it
  114. solves the problem of having to associate the ELF and stab symbols.
  115. However, no one has yet designed or implemented such a scheme.
  116. </p>
  117. <hr>
  118. <div class="header">
  119. <p>
  120. Previous: <a href="Stab-Section-Basics.html#Stab-Section-Basics" accesskey="p" rel="prev">Stab Section Basics</a>, Up: <a href="Stab-Sections.html#Stab-Sections" accesskey="u" rel="up">Stab Sections</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Types-Index.html#Symbol-Types-Index" title="Index" rel="index">Index</a>]</p>
  121. </div>
  122. </body>
  123. </html>