PageRenderTime 46ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/pkg/bootstrap/src/bootstrap/cmd/link/internal/arm64/obj.go

https://bitbucket.org/bnat6582/go192
Go | 140 lines | 94 code | 15 blank | 31 comment | 29 complexity | 30af7cfa1cb26d9aad2966eea9bc5920 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/arm64/obj.go
  2. //line /home/bnat6582/go/src/cmd/link/internal/arm64/obj.go:1
  3. // Inferno utils/5l/obj.c
  4. // https://bitbucket.org/inferno-os/inferno-os/src/default/utils/5l/obj.c
  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 arm64
  33. import (
  34. "bootstrap/cmd/internal/objabi"
  35. "bootstrap/cmd/internal/sys"
  36. "bootstrap/cmd/link/internal/ld"
  37. "fmt"
  38. )
  39. func Init() {
  40. ld.SysArch = sys.ArchARM64
  41. ld.Thearch.Funcalign = funcAlign
  42. ld.Thearch.Maxalign = maxAlign
  43. ld.Thearch.Minalign = minAlign
  44. ld.Thearch.Dwarfregsp = dwarfRegSP
  45. ld.Thearch.Dwarfreglr = dwarfRegLR
  46. ld.Thearch.Adddynrel = adddynrel
  47. ld.Thearch.Archinit = archinit
  48. ld.Thearch.Archreloc = archreloc
  49. ld.Thearch.Archrelocvariant = archrelocvariant
  50. ld.Thearch.Asmb = asmb
  51. ld.Thearch.Elfreloc1 = elfreloc1
  52. ld.Thearch.Elfsetupplt = elfsetupplt
  53. ld.Thearch.Gentext = gentext
  54. ld.Thearch.Machoreloc1 = machoreloc1
  55. ld.Thearch.Lput = ld.Lputl
  56. ld.Thearch.Wput = ld.Wputl
  57. ld.Thearch.Vput = ld.Vputl
  58. ld.Thearch.Append16 = ld.Append16l
  59. ld.Thearch.Append32 = ld.Append32l
  60. ld.Thearch.Append64 = ld.Append64l
  61. ld.Thearch.Linuxdynld = "/lib/ld-linux-aarch64.so.1"
  62. ld.Thearch.Freebsddynld = "XXX"
  63. ld.Thearch.Openbsddynld = "XXX"
  64. ld.Thearch.Netbsddynld = "XXX"
  65. ld.Thearch.Dragonflydynld = "XXX"
  66. ld.Thearch.Solarisdynld = "XXX"
  67. }
  68. func archinit(ctxt *ld.Link) {
  69. switch ld.Headtype {
  70. default:
  71. ld.Exitf("unknown -H option: %v", ld.Headtype)
  72. case objabi.Hplan9: /* plan 9 */
  73. ld.HEADR = 32
  74. if *ld.FlagTextAddr == -1 {
  75. *ld.FlagTextAddr = 4096 + int64(ld.HEADR)
  76. }
  77. if *ld.FlagDataAddr == -1 {
  78. *ld.FlagDataAddr = 0
  79. }
  80. if *ld.FlagRound == -1 {
  81. *ld.FlagRound = 4096
  82. }
  83. case objabi.Hlinux: /* arm64 elf */
  84. ld.Elfinit(ctxt)
  85. ld.HEADR = ld.ELFRESERVE
  86. if *ld.FlagTextAddr == -1 {
  87. *ld.FlagTextAddr = 0x10000 + int64(ld.HEADR)
  88. }
  89. if *ld.FlagDataAddr == -1 {
  90. *ld.FlagDataAddr = 0
  91. }
  92. if *ld.FlagRound == -1 {
  93. *ld.FlagRound = 0x10000
  94. }
  95. case objabi.Hdarwin: /* apple MACH */
  96. *ld.FlagW = true // disable DWARF generation
  97. ld.Machoinit()
  98. ld.HEADR = ld.INITIAL_MACHO_HEADR
  99. if *ld.FlagTextAddr == -1 {
  100. *ld.FlagTextAddr = 4096 + int64(ld.HEADR)
  101. }
  102. if *ld.FlagDataAddr == -1 {
  103. *ld.FlagDataAddr = 0
  104. }
  105. if *ld.FlagRound == -1 {
  106. *ld.FlagRound = 4096
  107. }
  108. case objabi.Hnacl:
  109. ld.Elfinit(ctxt)
  110. ld.HEADR = 0x10000
  111. ld.Funcalign = 16
  112. if *ld.FlagTextAddr == -1 {
  113. *ld.FlagTextAddr = 0x20000
  114. }
  115. if *ld.FlagDataAddr == -1 {
  116. *ld.FlagDataAddr = 0
  117. }
  118. if *ld.FlagRound == -1 {
  119. *ld.FlagRound = 0x10000
  120. }
  121. }
  122. if *ld.FlagDataAddr != 0 && *ld.FlagRound != 0 {
  123. fmt.Printf("warning: -D0x%x is ignored because of -R0x%x\n", uint64(*ld.FlagDataAddr), uint32(*ld.FlagRound))
  124. }
  125. }