1 // Do not edit. Bootstrap copy of /usr/local/google/buildbot/src/android/build-tools/out/obj/go/src/cmd/link/internal/amd64/obj.go 2 3 //line /usr/local/google/buildbot/src/android/build-tools/out/obj/go/src/cmd/link/internal/amd64/obj.go:1 4 // Inferno utils/6l/obj.c 5 // http://code.google.com/p/inferno-os/source/browse/utils/6l/obj.c 6 // 7 // Copyright 1994-1999 Lucent Technologies Inc. All rights reserved. 8 // Portions Copyright 1995-1997 C H Forsyth (forsyth (a] terzarima.net) 9 // Portions Copyright 1997-1999 Vita Nuova Limited 10 // Portions Copyright 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com) 11 // Portions Copyright 2004,2006 Bruce Ellis 12 // Portions Copyright 2005-2007 C H Forsyth (forsyth (a] terzarima.net) 13 // Revisions Copyright 2000-2007 Lucent Technologies Inc. and others 14 // Portions Copyright 2009 The Go Authors. All rights reserved. 15 // 16 // Permission is hereby granted, free of charge, to any person obtaining a copy 17 // of this software and associated documentation files (the "Software"), to deal 18 // in the Software without restriction, including without limitation the rights 19 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 20 // copies of the Software, and to permit persons to whom the Software is 21 // furnished to do so, subject to the following conditions: 22 // 23 // The above copyright notice and this permission notice shall be included in 24 // all copies or substantial portions of the Software. 25 // 26 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 31 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 32 // THE SOFTWARE. 33 34 package amd64 35 36 import ( 37 "bootstrap/internal/obj" 38 "bootstrap/link/internal/ld" 39 "fmt" 40 "log" 41 ) 42 43 // Reading object files. 44 45 func Main() { 46 linkarchinit() 47 ld.Ldmain() 48 } 49 50 func linkarchinit() { 51 ld.Thestring = "amd64" 52 ld.Thelinkarch = &ld.Linkamd64 53 if obj.Getgoarch() == "amd64p32" { 54 ld.Thelinkarch = &ld.Linkamd64p32 55 } 56 57 ld.Thearch.Thechar = thechar 58 ld.Thearch.Ptrsize = ld.Thelinkarch.Ptrsize 59 ld.Thearch.Intsize = ld.Thelinkarch.Ptrsize 60 ld.Thearch.Regsize = ld.Thelinkarch.Regsize 61 ld.Thearch.Funcalign = FuncAlign 62 ld.Thearch.Maxalign = MaxAlign 63 ld.Thearch.Minlc = MINLC 64 ld.Thearch.Dwarfregsp = DWARFREGSP 65 ld.Thearch.Dwarfreglr = DWARFREGLR 66 67 ld.Thearch.Adddynrel = adddynrel 68 ld.Thearch.Archinit = archinit 69 ld.Thearch.Archreloc = archreloc 70 ld.Thearch.Archrelocvariant = archrelocvariant 71 ld.Thearch.Asmb = asmb 72 ld.Thearch.Elfreloc1 = elfreloc1 73 ld.Thearch.Elfsetupplt = elfsetupplt 74 ld.Thearch.Gentext = gentext 75 ld.Thearch.Machoreloc1 = machoreloc1 76 ld.Thearch.PEreloc1 = pereloc1 77 ld.Thearch.Lput = ld.Lputl 78 ld.Thearch.Wput = ld.Wputl 79 ld.Thearch.Vput = ld.Vputl 80 81 ld.Thearch.Linuxdynld = "/lib64/ld-linux-x86-64.so.2" 82 ld.Thearch.Freebsddynld = "/libexec/ld-elf.so.1" 83 ld.Thearch.Openbsddynld = "/usr/libexec/ld.so" 84 ld.Thearch.Netbsddynld = "/libexec/ld.elf_so" 85 ld.Thearch.Dragonflydynld = "/usr/libexec/ld-elf.so.2" 86 ld.Thearch.Solarisdynld = "/lib/amd64/ld.so.1" 87 } 88 89 func archinit() { 90 // getgoextlinkenabled is based on GO_EXTLINK_ENABLED when 91 // Go was built; see ../../make.bash. 92 if ld.Linkmode == ld.LinkAuto && obj.Getgoextlinkenabled() == "0" { 93 ld.Linkmode = ld.LinkInternal 94 } 95 96 if ld.Buildmode == ld.BuildmodeCArchive || ld.Buildmode == ld.BuildmodeCShared || ld.DynlinkingGo() { 97 ld.Linkmode = ld.LinkExternal 98 } 99 100 switch ld.HEADTYPE { 101 default: 102 if ld.Linkmode == ld.LinkAuto { 103 ld.Linkmode = ld.LinkInternal 104 } 105 if ld.Linkmode == ld.LinkExternal && obj.Getgoextlinkenabled() != "1" { 106 log.Fatalf("cannot use -linkmode=external with -H %s", ld.Headstr(int(ld.HEADTYPE))) 107 } 108 109 case obj.Hdarwin, 110 obj.Hdragonfly, 111 obj.Hfreebsd, 112 obj.Hlinux, 113 obj.Hnacl, 114 obj.Hnetbsd, 115 obj.Hopenbsd, 116 obj.Hsolaris, 117 obj.Hwindows: 118 break 119 } 120 121 switch ld.HEADTYPE { 122 default: 123 ld.Exitf("unknown -H option: %v", ld.HEADTYPE) 124 125 case obj.Hplan9: /* plan 9 */ 126 ld.HEADR = 32 + 8 127 128 if ld.INITTEXT == -1 { 129 ld.INITTEXT = 0x200000 + int64(ld.HEADR) 130 } 131 if ld.INITDAT == -1 { 132 ld.INITDAT = 0 133 } 134 if ld.INITRND == -1 { 135 ld.INITRND = 0x200000 136 } 137 138 case obj.Helf: /* elf32 executable */ 139 ld.HEADR = int32(ld.Rnd(52+3*32, 16)) 140 141 if ld.INITTEXT == -1 { 142 ld.INITTEXT = 0x80110000 143 } 144 if ld.INITDAT == -1 { 145 ld.INITDAT = 0 146 } 147 if ld.INITRND == -1 { 148 ld.INITRND = 4096 149 } 150 151 case obj.Hdarwin: /* apple MACH */ 152 ld.Machoinit() 153 154 ld.HEADR = ld.INITIAL_MACHO_HEADR 155 if ld.INITRND == -1 { 156 ld.INITRND = 4096 157 } 158 if ld.INITTEXT == -1 { 159 ld.INITTEXT = 4096 + int64(ld.HEADR) 160 } 161 if ld.INITDAT == -1 { 162 ld.INITDAT = 0 163 } 164 165 case obj.Hlinux, /* elf64 executable */ 166 obj.Hfreebsd, /* freebsd */ 167 obj.Hnetbsd, /* netbsd */ 168 obj.Hopenbsd, /* openbsd */ 169 obj.Hdragonfly, /* dragonfly */ 170 obj.Hsolaris: /* solaris */ 171 ld.Elfinit() 172 173 ld.HEADR = ld.ELFRESERVE 174 if ld.INITTEXT == -1 { 175 ld.INITTEXT = (1 << 22) + int64(ld.HEADR) 176 } 177 if ld.INITDAT == -1 { 178 ld.INITDAT = 0 179 } 180 if ld.INITRND == -1 { 181 ld.INITRND = 4096 182 } 183 184 case obj.Hnacl: 185 ld.Elfinit() 186 ld.Debug['w']++ // disable dwarf, which gets confused and is useless anyway 187 ld.HEADR = 0x10000 188 ld.Funcalign = 32 189 if ld.INITTEXT == -1 { 190 ld.INITTEXT = 0x20000 191 } 192 if ld.INITDAT == -1 { 193 ld.INITDAT = 0 194 } 195 if ld.INITRND == -1 { 196 ld.INITRND = 0x10000 197 } 198 199 case obj.Hwindows: /* PE executable */ 200 ld.Peinit() 201 202 ld.HEADR = ld.PEFILEHEADR 203 if ld.INITTEXT == -1 { 204 ld.INITTEXT = ld.PEBASE + int64(ld.PESECTHEADR) 205 } 206 if ld.INITDAT == -1 { 207 ld.INITDAT = 0 208 } 209 if ld.INITRND == -1 { 210 ld.INITRND = ld.PESECTALIGN 211 } 212 } 213 214 if ld.INITDAT != 0 && ld.INITRND != 0 { 215 fmt.Printf("warning: -D0x%x is ignored because of -R0x%x\n", uint64(ld.INITDAT), uint32(ld.INITRND)) 216 } 217 } 218