PageRenderTime 31ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/pkg/bootstrap/src/bootstrap/cmd/link/internal/ld/symkind.go

https://bitbucket.org/bnat6582/go192
Go | 155 lines | 85 code | 12 blank | 58 comment | 0 complexity | 4c1f86059db626ec55e46852b82e101b MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0
  1. // Do not edit. Bootstrap copy of /home/bnat6582/go/src/cmd/link/internal/ld/symkind.go
  2. //line /home/bnat6582/go/src/cmd/link/internal/ld/symkind.go:1
  3. // Derived from Inferno utils/6l/l.h and related files.
  4. // https://bitbucket.org/inferno-os/inferno-os/src/default/utils/6l/l.h
  5. //
  6. // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
  7. // Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
  8. // Portions Copyright © 1997-1999 Vita Nuova Limited
  9. // Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
  10. // Portions Copyright © 2004,2006 Bruce Ellis
  11. // Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
  12. // Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
  13. // Portions Copyright © 2009 The Go Authors. All rights reserved.
  14. //
  15. // Permission is hereby granted, free of charge, to any person obtaining a copy
  16. // of this software and associated documentation files (the "Software"), to deal
  17. // in the Software without restriction, including without limitation the rights
  18. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  19. // copies of the Software, and to permit persons to whom the Software is
  20. // furnished to do so, subject to the following conditions:
  21. //
  22. // The above copyright notice and this permission notice shall be included in
  23. // all copies or substantial portions of the Software.
  24. //
  25. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  26. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  27. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  28. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  29. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  30. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  31. // THE SOFTWARE.
  32. package ld
  33. // A SymKind describes the kind of memory represented by a symbol.
  34. type SymKind int16
  35. // Defined SymKind values.
  36. //
  37. // TODO(rsc): Give idiomatic Go names.
  38. //go:generate stringer -type=SymKind
  39. const (
  40. Sxxx SymKind = iota
  41. STEXT
  42. SELFRXSECT
  43. // Read-only sections.
  44. STYPE
  45. SSTRING
  46. SGOSTRING
  47. SGOFUNC
  48. SGCBITS
  49. SRODATA
  50. SFUNCTAB
  51. SELFROSECT
  52. SMACHOPLT
  53. // Read-only sections with relocations.
  54. //
  55. // Types STYPE-SFUNCTAB above are written to the .rodata section by default.
  56. // When linking a shared object, some conceptually "read only" types need to
  57. // be written to by relocations and putting them in a section called
  58. // ".rodata" interacts poorly with the system linkers. The GNU linkers
  59. // support this situation by arranging for sections of the name
  60. // ".data.rel.ro.XXX" to be mprotected read only by the dynamic linker after
  61. // relocations have applied, so when the Go linker is creating a shared
  62. // object it checks all objects of the above types and bumps any object that
  63. // has a relocation to it to the corresponding type below, which are then
  64. // written to sections with appropriate magic names.
  65. STYPERELRO
  66. SSTRINGRELRO
  67. SGOSTRINGRELRO
  68. SGOFUNCRELRO
  69. SGCBITSRELRO
  70. SRODATARELRO
  71. SFUNCTABRELRO
  72. // Part of .data.rel.ro if it exists, otherwise part of .rodata.
  73. STYPELINK
  74. SITABLINK
  75. SSYMTAB
  76. SPCLNTAB
  77. // Writable sections.
  78. SELFSECT
  79. SMACHO
  80. SMACHOGOT
  81. SWINDOWS
  82. SELFGOT
  83. SNOPTRDATA
  84. SINITARR
  85. SDATA
  86. SBSS
  87. SNOPTRBSS
  88. STLSBSS
  89. SXREF
  90. SMACHOSYMSTR
  91. SMACHOSYMTAB
  92. SMACHOINDIRECTPLT
  93. SMACHOINDIRECTGOT
  94. SFILE
  95. SFILEPATH
  96. SCONST
  97. SDYNIMPORT
  98. SHOSTOBJ
  99. SDWARFSECT
  100. SDWARFINFO
  101. SDWARFRANGE
  102. SSUB = SymKind(1 << 8)
  103. SMASK = SymKind(SSUB - 1)
  104. SHIDDEN = SymKind(1 << 9)
  105. SCONTAINER = SymKind(1 << 10) // has a sub-symbol
  106. )
  107. // abiSymKindToSymKind maps values read from object files (which are
  108. // of type cmd/internal/objabi.SymKind) to values of type SymKind.
  109. var abiSymKindToSymKind = [...]SymKind{
  110. Sxxx,
  111. STEXT,
  112. SRODATA,
  113. SNOPTRDATA,
  114. SDATA,
  115. SBSS,
  116. SNOPTRBSS,
  117. STLSBSS,
  118. SDWARFINFO,
  119. SDWARFRANGE,
  120. }
  121. // readOnly are the symbol kinds that form read-only sections. In some
  122. // cases, if they will require relocations, they are transformed into
  123. // rel-ro sections using relROMap.
  124. var readOnly = []SymKind{
  125. STYPE,
  126. SSTRING,
  127. SGOSTRING,
  128. SGOFUNC,
  129. SGCBITS,
  130. SRODATA,
  131. SFUNCTAB,
  132. }
  133. // relROMap describes the transformation of read-only symbols to rel-ro
  134. // symbols.
  135. var relROMap = map[SymKind]SymKind{
  136. STYPE: STYPERELRO,
  137. SSTRING: SSTRINGRELRO,
  138. SGOSTRING: SGOSTRINGRELRO,
  139. SGOFUNC: SGOFUNCRELRO,
  140. SGCBITS: SGCBITSRELRO,
  141. SRODATA: SRODATARELRO,
  142. SFUNCTAB: SFUNCTABRELRO,
  143. }