Skip to content

Commit

Permalink
cmd/link: move Headtype global to ctxt
Browse files Browse the repository at this point in the history
For #22095

Change-Id: Idcfdfe8a94db8626392658bb93429454238f648a
Reviewed-on: https://go-review.googlesource.com/70835
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
  • Loading branch information
crawshaw committed Oct 21, 2017
1 parent 6fd1f82 commit 38cfeb9
Show file tree
Hide file tree
Showing 27 changed files with 145 additions and 145 deletions.
20 changes: 10 additions & 10 deletions src/cmd/link/internal/amd64/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {

case objabi.R_ADDR:
if s.Type == sym.STEXT && ctxt.IsELF {
if ld.Headtype == objabi.Hsolaris {
if ctxt.HeadType == objabi.Hsolaris {
addpltsym(ctxt, targ)
r.Sym = ctxt.Syms.Lookup(".plt", 0)
r.Add += int64(targ.Plt)
Expand Down Expand Up @@ -334,7 +334,7 @@ func adddynrel(ctxt *ld.Link, s *sym.Symbol, r *sym.Reloc) bool {
return true
}

if ld.Headtype == objabi.Hdarwin && s.Size == int64(ctxt.Arch.PtrSize) && r.Off == 0 {
if ctxt.HeadType == objabi.Hdarwin && s.Size == int64(ctxt.Arch.PtrSize) && r.Off == 0 {
// Mach-O relocations are a royal pain to lay out.
// They use a compact stateful bytecode representation
// that is too much bother to deal with.
Expand Down Expand Up @@ -603,7 +603,7 @@ func addpltsym(ctxt *ld.Link, s *sym.Symbol) {
rela.AddUint64(ctxt.Arch, 0)

s.Plt = int32(plt.Size - 16)
} else if ld.Headtype == objabi.Hdarwin {
} else if ctxt.HeadType == objabi.Hdarwin {
// To do lazy symbol lookup right, we're supposed
// to tell the dynamic loader which library each
// symbol comes from and format the link info
Expand Down Expand Up @@ -645,7 +645,7 @@ func addgotsym(ctxt *ld.Link, s *sym.Symbol) {
rela.AddAddrPlus(ctxt.Arch, got, int64(s.Got))
rela.AddUint64(ctxt.Arch, ld.ELF64_R_INFO(uint32(s.Dynid), uint32(elf.R_X86_64_GLOB_DAT)))
rela.AddUint64(ctxt.Arch, 0)
} else if ld.Headtype == objabi.Hdarwin {
} else if ctxt.HeadType == objabi.Hdarwin {
ctxt.Syms.Lookup(".linkedit.got", 0).AddUint32(ctxt.Arch, uint32(s.Dynid))
} else {
ld.Errorf(s, "addgotsym: unsupported binary format")
Expand Down Expand Up @@ -700,13 +700,13 @@ func asmb(ctxt *ld.Link) {
ld.Dwarfblk(ctxt, int64(ld.Segdwarf.Vaddr), int64(ld.Segdwarf.Filelen))

machlink := int64(0)
if ld.Headtype == objabi.Hdarwin {
if ctxt.HeadType == objabi.Hdarwin {
machlink = ld.Domacholink(ctxt)
}

switch ld.Headtype {
switch ctxt.HeadType {
default:
ld.Errorf(nil, "unknown header type %v", ld.Headtype)
ld.Errorf(nil, "unknown header type %v", ctxt.HeadType)
fallthrough

case objabi.Hplan9:
Expand Down Expand Up @@ -736,7 +736,7 @@ func asmb(ctxt *ld.Link) {
if ctxt.Debugvlog != 0 {
ctxt.Logf("%5.2f sym\n", ld.Cputime())
}
switch ld.Headtype {
switch ctxt.HeadType {
default:
case objabi.Hplan9:
*ld.FlagS = true
Expand All @@ -761,7 +761,7 @@ func asmb(ctxt *ld.Link) {
}

ctxt.Out.SeekSet(symo)
switch ld.Headtype {
switch ctxt.HeadType {
default:
if ctxt.IsELF {
ctxt.Out.SeekSet(symo)
Expand Down Expand Up @@ -805,7 +805,7 @@ func asmb(ctxt *ld.Link) {
ctxt.Logf("%5.2f headr\n", ld.Cputime())
}
ctxt.Out.SeekSet(0)
switch ld.Headtype {
switch ctxt.HeadType {
default:
case objabi.Hplan9: /* plan9 */
magic := int32(4*26*26 + 7)
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/link/internal/amd64/obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ func Init() (*sys.Arch, ld.Arch) {
}

func archinit(ctxt *ld.Link) {
switch ld.Headtype {
switch ctxt.HeadType {
default:
ld.Exitf("unknown -H option: %v", ld.Headtype)
ld.Exitf("unknown -H option: %v", ctxt.HeadType)

case objabi.Hplan9: /* plan 9 */
ld.HEADR = 32 + 8
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/link/internal/arm/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ func archreloc(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, val *int64) bool {
// the section load address.
// we need to compensate that by removing the instruction's address
// from addend.
if ld.Headtype == objabi.Hdarwin {
if ctxt.HeadType == objabi.Hdarwin {
r.Xadd -= ld.Symaddr(s) + int64(r.Off)
}

Expand Down Expand Up @@ -781,7 +781,7 @@ func asmb(ctxt *ld.Link) {
ld.Dwarfblk(ctxt, int64(ld.Segdwarf.Vaddr), int64(ld.Segdwarf.Filelen))

machlink := uint32(0)
if ld.Headtype == objabi.Hdarwin {
if ctxt.HeadType == objabi.Hdarwin {
machlink = uint32(ld.Domacholink(ctxt))
}

Expand All @@ -795,7 +795,7 @@ func asmb(ctxt *ld.Link) {
if ctxt.Debugvlog != 0 {
ctxt.Logf("%5.2f sym\n", ld.Cputime())
}
switch ld.Headtype {
switch ctxt.HeadType {
default:
if ctxt.IsELF {
symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
Expand All @@ -810,7 +810,7 @@ func asmb(ctxt *ld.Link) {
}

ctxt.Out.SeekSet(int64(symo))
switch ld.Headtype {
switch ctxt.HeadType {
default:
if ctxt.IsELF {
if ctxt.Debugvlog != 0 {
Expand Down Expand Up @@ -847,7 +847,7 @@ func asmb(ctxt *ld.Link) {
ctxt.Logf("%5.2f header\n", ld.Cputime())
}
ctxt.Out.SeekSet(0)
switch ld.Headtype {
switch ctxt.HeadType {
default:
case objabi.Hplan9: /* plan 9 */
ctxt.Out.Write32b(0x647) /* magic */
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/link/internal/arm/obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ func Init() (*sys.Arch, ld.Arch) {
}

func archinit(ctxt *ld.Link) {
switch ld.Headtype {
switch ctxt.HeadType {
default:
ld.Exitf("unknown -H option: %v", ld.Headtype)
ld.Exitf("unknown -H option: %v", ctxt.HeadType)

case objabi.Hplan9: /* plan 9 */
ld.HEADR = 32
Expand Down
14 changes: 7 additions & 7 deletions src/cmd/link/internal/arm64/asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func archreloc(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, val *int64) bool {
// the BR26 relocation should be fully resolved at link time.
// That is the reason why the next if block is disabled. When the bug in ld64
// is fixed, we can enable this block and also enable duff's device in cmd/7g.
if false && ld.Headtype == objabi.Hdarwin {
if false && ctxt.HeadType == objabi.Hdarwin {
var o0, o1 uint32

if ctxt.Arch.ByteOrder == binary.BigEndian {
Expand Down Expand Up @@ -346,8 +346,8 @@ func archreloc(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, val *int64) bool {
return true
case objabi.R_ARM64_TLS_LE:
r.Done = false
if ld.Headtype != objabi.Hlinux {
ld.Errorf(s, "TLS reloc on unsupported OS %v", ld.Headtype)
if ctxt.HeadType != objabi.Hlinux {
ld.Errorf(s, "TLS reloc on unsupported OS %v", ctxt.HeadType)
}
// The TCB is two pointers. This is not documented anywhere, but is
// de facto part of the ABI.
Expand Down Expand Up @@ -417,7 +417,7 @@ func asmb(ctxt *ld.Link) {
ld.Dwarfblk(ctxt, int64(ld.Segdwarf.Vaddr), int64(ld.Segdwarf.Filelen))

machlink := uint32(0)
if ld.Headtype == objabi.Hdarwin {
if ctxt.HeadType == objabi.Hdarwin {
machlink = uint32(ld.Domacholink(ctxt))
}

Expand All @@ -431,7 +431,7 @@ func asmb(ctxt *ld.Link) {
if ctxt.Debugvlog != 0 {
ctxt.Logf("%5.2f sym\n", ld.Cputime())
}
switch ld.Headtype {
switch ctxt.HeadType {
default:
if ctxt.IsELF {
symo = uint32(ld.Segdwarf.Fileoff + ld.Segdwarf.Filelen)
Expand All @@ -446,7 +446,7 @@ func asmb(ctxt *ld.Link) {
}

ctxt.Out.SeekSet(int64(symo))
switch ld.Headtype {
switch ctxt.HeadType {
default:
if ctxt.IsELF {
if ctxt.Debugvlog != 0 {
Expand Down Expand Up @@ -483,7 +483,7 @@ func asmb(ctxt *ld.Link) {
ctxt.Logf("%5.2f header\n", ld.Cputime())
}
ctxt.Out.SeekSet(0)
switch ld.Headtype {
switch ctxt.HeadType {
default:
case objabi.Hplan9: /* plan 9 */
ctxt.Out.Write32(0x647) /* magic */
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/link/internal/arm64/obj.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ func Init() (*sys.Arch, ld.Arch) {
}

func archinit(ctxt *ld.Link) {
switch ld.Headtype {
switch ctxt.HeadType {
default:
ld.Exitf("unknown -H option: %v", ld.Headtype)
ld.Exitf("unknown -H option: %v", ctxt.HeadType)

case objabi.Hplan9: /* plan 9 */
ld.HEADR = 32
Expand Down
Loading

0 comments on commit 38cfeb9

Please sign in to comment.