1
0
mirror of https://github.com/golang/go synced 2024-11-19 10:24:43 -07:00

cmd/internal/ld, cmd/internal/obj: delete Ctxt.Endian

Replaced by Ctxt.ByteOrder, which uses the standard binary.ByteOrder type.

Change-Id: I06cec0674c153a9ad75ff937f7eb934891effd0b
Reviewed-on: https://go-review.googlesource.com/6450
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Russ Cox 2015-03-01 22:02:13 -05:00
parent b38fa898c6
commit ea7be5170a
10 changed files with 13 additions and 33 deletions

View File

@ -32,6 +32,7 @@ package main
import (
"cmd/internal/obj"
"encoding/binary"
"fmt"
"log"
)
@ -185,7 +186,7 @@ func gencallstub(abicase int, stub *ld.LSym, targ *ld.LSym) {
r.Sym = plt
r.Add = int64(targ.Plt)
r.Siz = 2
if ld.Ctxt.Arch.Endian == ld.BigEndian {
if ld.Ctxt.Arch.ByteOrder == binary.BigEndian {
r.Off += int32(r.Siz)
}
r.Type = ld.R_POWER_TOC
@ -196,7 +197,7 @@ func gencallstub(abicase int, stub *ld.LSym, targ *ld.LSym) {
r.Sym = plt
r.Add = int64(targ.Plt)
r.Siz = 2
if ld.Ctxt.Arch.Endian == ld.BigEndian {
if ld.Ctxt.Arch.ByteOrder == binary.BigEndian {
r.Off += int32(r.Siz)
}
r.Type = ld.R_POWER_TOC
@ -400,7 +401,7 @@ func archreloc(r *ld.Reloc, s *ld.LSym, val *int64) int {
o2 = o2&0xffff0000 | uint32(t)&0xffff
// when laid out, the instruction order must always be o1, o2.
if ld.Ctxt.Arch.Endian == ld.BigEndian {
if ld.Ctxt.Arch.ByteOrder == binary.BigEndian {
*val = int64(o1)<<32 | int64(o2)
} else {
*val = int64(o2)<<32 | int64(o1)
@ -409,7 +410,7 @@ func archreloc(r *ld.Reloc, s *ld.LSym, val *int64) int {
case ld.R_CALLPOWER:
// Bits 6 through 29 = (S + A - P) >> 2
if ld.Ctxt.Arch.Endian == ld.BigEndian {
if ld.Ctxt.Arch.ByteOrder == binary.BigEndian {
o1 = ld.Be32(s.P[r.Off:])
} else {
o1 = ld.Le32(s.P[r.Off:])
@ -451,7 +452,7 @@ func archrelocvariant(r *ld.Reloc, s *ld.LSym, t int64) int64 {
if r.Variant&ld.RV_CHECK_OVERFLOW != 0 {
// Whether to check for signed or unsigned
// overflow depends on the instruction
if ld.Ctxt.Arch.Endian == ld.BigEndian {
if ld.Ctxt.Arch.ByteOrder == binary.BigEndian {
o1 = ld.Be32(s.P[r.Off-2:])
} else {
o1 = ld.Le32(s.P[r.Off:])
@ -484,7 +485,7 @@ func archrelocvariant(r *ld.Reloc, s *ld.LSym, t int64) int64 {
if r.Variant&ld.RV_CHECK_OVERFLOW != 0 {
// Whether to check for signed or unsigned
// overflow depends on the instruction
if ld.Ctxt.Arch.Endian == ld.BigEndian {
if ld.Ctxt.Arch.ByteOrder == binary.BigEndian {
o1 = ld.Be32(s.P[r.Off-2:])
} else {
o1 = ld.Le32(s.P[r.Off:])
@ -507,7 +508,7 @@ func archrelocvariant(r *ld.Reloc, s *ld.LSym, t int64) int64 {
return int64(int16(t))
case ld.RV_POWER_DS:
if ld.Ctxt.Arch.Endian == ld.BigEndian {
if ld.Ctxt.Arch.ByteOrder == binary.BigEndian {
o1 = uint32(ld.Be16(s.P[r.Off:]))
} else {
o1 = uint32(ld.Le16(s.P[r.Off:]))

View File

@ -10,7 +10,6 @@ var Linkarm = LinkArch{
ByteOrder: binary.LittleEndian,
Name: "arm",
Thechar: '5',
Endian: LittleEndian,
Minlc: 4,
Ptrsize: 4,
Regsize: 4,
@ -20,7 +19,6 @@ var Linkamd64 = LinkArch{
ByteOrder: binary.LittleEndian,
Name: "amd64",
Thechar: '6',
Endian: LittleEndian,
Minlc: 1,
Ptrsize: 8,
Regsize: 8,
@ -30,7 +28,6 @@ var Linkamd64p32 = LinkArch{
ByteOrder: binary.LittleEndian,
Name: "amd64p32",
Thechar: '6',
Endian: LittleEndian,
Minlc: 1,
Ptrsize: 4,
Regsize: 8,
@ -40,7 +37,6 @@ var Link386 = LinkArch{
ByteOrder: binary.LittleEndian,
Name: "386",
Thechar: '8',
Endian: LittleEndian,
Minlc: 1,
Ptrsize: 4,
Regsize: 4,
@ -50,7 +46,6 @@ var Linkppc64 = LinkArch{
ByteOrder: binary.BigEndian,
Name: "ppc64",
Thechar: '9',
Endian: BigEndian,
Minlc: 4,
Ptrsize: 8,
Regsize: 8,
@ -60,7 +55,6 @@ var Linkppc64le = LinkArch{
ByteOrder: binary.LittleEndian,
Name: "ppc64le",
Thechar: '9',
Endian: LittleEndian,
Minlc: 4,
Ptrsize: 8,
Regsize: 8,

View File

@ -5,6 +5,7 @@
package ld
import (
"encoding/binary"
"fmt"
"os"
)
@ -755,7 +756,7 @@ func Elfinit() {
switch Thearch.Thechar {
// 64-bit architectures
case '9':
if Ctxt.Arch.Endian == BigEndian {
if Ctxt.Arch.ByteOrder == binary.BigEndian {
ehdr.flags = 1 /* Version 1 ABI */
} else {
ehdr.flags = 2 /* Version 2 ABI */
@ -2342,7 +2343,7 @@ elfobj:
} else {
eh.ident[EI_CLASS] = ELFCLASS32
}
if Ctxt.Arch.Endian == BigEndian {
if Ctxt.Arch.ByteOrder == binary.BigEndian {
eh.ident[EI_DATA] = ELFDATA2MSB
} else {
eh.ident[EI_DATA] = ELFDATA2LSB

View File

@ -269,11 +269,6 @@ const (
// Link holds the context for writing object code from a compiler
// to be linker input or for reading that input into the linker.
const (
LittleEndian = 0x04030201
BigEndian = 0x01020304
)
// LinkArch is the definition of a single architecture.
/* executable header types */

View File

@ -1066,7 +1066,6 @@ var Linkarm = obj.LinkArch{
Pconv: Pconv,
Name: "arm",
Thechar: '5',
Endian: obj.LittleEndian,
Preprocess: preprocess,
Assemble: span5,
Follow: follow,

View File

@ -914,7 +914,6 @@ var Link386 = obj.LinkArch{
Pconv: Pconv,
Name: "386",
Thechar: '8',
Endian: obj.LittleEndian,
Preprocess: preprocess,
Assemble: span8,
Follow: follow,

View File

@ -246,7 +246,6 @@ type LinkArch struct {
ByteOrder binary.ByteOrder
Name string
Thechar int
Endian int32
Preprocess func(*Link, *LSym)
Assemble func(*Link, *LSym)
Follow func(*Link, *LSym)
@ -547,11 +546,6 @@ const (
// Link holds the context for writing object code from a compiler
// to be linker input or for reading that input into the linker.
const (
LittleEndian = 0x04030201
BigEndian = 0x01020304
)
// LinkArch is the definition of a single architecture.
/* executable header types */

View File

@ -31,6 +31,7 @@ package ppc64
import (
"cmd/internal/obj"
"encoding/binary"
"fmt"
"log"
"sort"
@ -2038,7 +2039,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
case 31: /* dword */
d = vregoff(ctxt, &p.From)
if ctxt.Arch.Endian == obj.BigEndian {
if ctxt.Arch.ByteOrder == binary.BigEndian {
o1 = uint32(d >> 32)
o2 = uint32(d)
} else {

View File

@ -970,7 +970,6 @@ var Linkppc64 = obj.LinkArch{
Pconv: Pconv,
Name: "ppc64",
Thechar: '9',
Endian: obj.BigEndian,
Preprocess: preprocess,
Assemble: span9,
Follow: follow,
@ -986,7 +985,6 @@ var Linkppc64le = obj.LinkArch{
Pconv: Pconv,
Name: "ppc64le",
Thechar: '9',
Endian: obj.LittleEndian,
Preprocess: preprocess,
Assemble: span9,
Follow: follow,

View File

@ -1116,7 +1116,6 @@ var Linkamd64 = obj.LinkArch{
Pconv: Pconv,
Name: "amd64",
Thechar: '6',
Endian: obj.LittleEndian,
Preprocess: preprocess,
Assemble: span6,
Follow: follow,
@ -1132,7 +1131,6 @@ var Linkamd64p32 = obj.LinkArch{
Pconv: Pconv,
Name: "amd64p32",
Thechar: '6',
Endian: obj.LittleEndian,
Preprocess: preprocess,
Assemble: span6,
Follow: follow,