* use bool instead of int if it's adequate.
* remove blank lines.
Change-Id: Ic4a5644a33ed9fc7ce388ef8ba15f1732446fcfc
Reviewed-on: https://go-review.googlesource.com/59375
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
return false
}
-func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
+func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) bool {
ld.Thearch.Vput(uint64(sectoff))
elfsym := r.Xsym.ElfsymForReloc()
switch r.Type {
default:
- return -1
-
+ return false
case objabi.R_ADDR:
if r.Siz == 4 {
ld.Thearch.Vput(ld.R_X86_64_32 | uint64(elfsym)<<32)
} else if r.Siz == 8 {
ld.Thearch.Vput(ld.R_X86_64_64 | uint64(elfsym)<<32)
} else {
- return -1
+ return false
}
-
case objabi.R_TLS_LE:
if r.Siz == 4 {
ld.Thearch.Vput(ld.R_X86_64_TPOFF32 | uint64(elfsym)<<32)
} else {
- return -1
+ return false
}
-
case objabi.R_TLS_IE:
if r.Siz == 4 {
ld.Thearch.Vput(ld.R_X86_64_GOTTPOFF | uint64(elfsym)<<32)
} else {
- return -1
+ return false
}
-
case objabi.R_CALL:
if r.Siz == 4 {
if r.Xsym.Type == ld.SDYNIMPORT {
ld.Thearch.Vput(ld.R_X86_64_PC32 | uint64(elfsym)<<32)
}
} else {
- return -1
+ return false
}
-
case objabi.R_PCREL:
if r.Siz == 4 {
if r.Xsym.Type == ld.SDYNIMPORT && r.Xsym.ElfType == elf.STT_FUNC {
ld.Thearch.Vput(ld.R_X86_64_PC32 | uint64(elfsym)<<32)
}
} else {
- return -1
+ return false
}
-
case objabi.R_GOTPCREL:
if r.Siz == 4 {
ld.Thearch.Vput(ld.R_X86_64_GOTPCREL | uint64(elfsym)<<32)
} else {
- return -1
+ return false
}
}
ld.Thearch.Vput(uint64(r.Xadd))
- return 0
+ return true
}
-func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
+func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) bool {
var v uint32
rs := r.Xsym
if rs.Type == ld.SHOSTOBJ || r.Type == objabi.R_PCREL || r.Type == objabi.R_GOTPCREL {
if rs.Dynid < 0 {
ld.Errorf(s, "reloc %d (%s) to non-macho symbol %s type=%d (%s)", r.Type, ld.RelocName(r.Type), rs.Name, rs.Type, rs.Type)
- return -1
+ return false
}
v = uint32(rs.Dynid)
v = uint32(rs.Sect.Extnum)
if v == 0 {
ld.Errorf(s, "reloc %d (%s) to symbol %s in non-macho section %s type=%d (%s)", r.Type, ld.RelocName(r.Type), rs.Name, rs.Sect.Name, rs.Type, rs.Type)
- return -1
+ return false
}
}
switch r.Type {
default:
- return -1
+ return false
case objabi.R_ADDR:
v |= ld.MACHO_X86_64_RELOC_UNSIGNED << 28
switch r.Siz {
default:
- return -1
+ return false
case 1:
v |= 0 << 25
ld.Thearch.Lput(uint32(sectoff))
ld.Thearch.Lput(v)
- return 0
+ return true
}
func pereloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) bool {
return true
}
-func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
- return -1
+func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) bool {
+ return false
}
func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 {
return false
}
-func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
+func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) bool {
ld.Thearch.Lput(uint32(sectoff))
elfsym := r.Xsym.ElfsymForReloc()
switch r.Type {
default:
- return -1
-
+ return false
case objabi.R_ADDR:
if r.Siz == 4 {
ld.Thearch.Lput(ld.R_ARM_ABS32 | uint32(elfsym)<<8)
} else {
- return -1
+ return false
}
-
case objabi.R_PCREL:
if r.Siz == 4 {
ld.Thearch.Lput(ld.R_ARM_REL32 | uint32(elfsym)<<8)
} else {
- return -1
+ return false
}
-
case objabi.R_CALLARM:
if r.Siz == 4 {
if r.Add&0xff000000 == 0xeb000000 { // BL
ld.Thearch.Lput(ld.R_ARM_JUMP24 | uint32(elfsym)<<8)
}
} else {
- return -1
+ return false
}
-
case objabi.R_TLS_LE:
ld.Thearch.Lput(ld.R_ARM_TLS_LE32 | uint32(elfsym)<<8)
-
case objabi.R_TLS_IE:
ld.Thearch.Lput(ld.R_ARM_TLS_IE32 | uint32(elfsym)<<8)
-
case objabi.R_GOTPCREL:
if r.Siz == 4 {
ld.Thearch.Lput(ld.R_ARM_GOT_PREL | uint32(elfsym)<<8)
} else {
- return -1
+ return false
}
}
- return 0
+ return true
}
func elfsetupplt(ctxt *ld.Link) {
}
}
-func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
+func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) bool {
var v uint32
rs := r.Xsym
if r.Type == objabi.R_PCREL {
if rs.Type == ld.SHOSTOBJ {
ld.Errorf(s, "pc-relative relocation of external symbol is not supported")
- return -1
+ return false
}
if r.Siz != 4 {
- return -1
+ return false
}
// emit a pair of "scattered" relocations that
ld.Thearch.Lput(uint32(ld.Symaddr(rs)))
ld.Thearch.Lput(o2)
ld.Thearch.Lput(uint32(s.Value + int64(r.Off)))
- return 0
+ return true
}
if rs.Type == ld.SHOSTOBJ || r.Type == objabi.R_CALLARM {
if rs.Dynid < 0 {
ld.Errorf(s, "reloc %d (%s) to non-macho symbol %s type=%d (%s)", r.Type, ld.RelocName(r.Type), rs.Name, rs.Type, rs.Type)
- return -1
+ return false
}
v = uint32(rs.Dynid)
v = uint32(rs.Sect.Extnum)
if v == 0 {
ld.Errorf(s, "reloc %d (%s) to symbol %s in non-macho section %s type=%d (%s)", r.Type, ld.RelocName(r.Type), rs.Name, rs.Sect.Name, rs.Type, rs.Type)
- return -1
+ return false
}
}
switch r.Type {
default:
- return -1
+ return false
case objabi.R_ADDR:
v |= ld.MACHO_GENERIC_RELOC_VANILLA << 28
switch r.Siz {
default:
- return -1
-
+ return false
case 1:
v |= 0 << 25
ld.Thearch.Lput(uint32(sectoff))
ld.Thearch.Lput(v)
- return 0
+ return true
}
// sign extend a 24-bit integer
// modify reloc to point to tramp, which will be resolved later
r.Sym = tramp
r.Add = r.Add&0xff000000 | 0xfffffe // clear the offset embedded in the instruction
- r.Done = 0
+ r.Done = false
}
default:
ld.Errorf(s, "trampoline called with non-jump reloc: %d (%s)", r.Type, ld.RelocName(r.Type))
}
}
-func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
+func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) bool {
if ld.Linkmode == ld.LinkExternal {
switch r.Type {
case objabi.R_CALLARM:
- r.Done = 0
+ r.Done = false
// set up addend for eventual relocation via outer symbol.
rs := r.Sym
}
*val = int64(braddoff(int32(0xff000000&uint32(r.Add)), int32(0xffffff&uint32(r.Xadd/4))))
- return 0
+ return true
}
- return -1
+ return false
}
switch r.Type {
case objabi.R_CONST:
*val = r.Add
- return 0
-
+ return true
case objabi.R_GOTOFF:
*val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ctxt.Syms.Lookup(".got", 0))
- return 0
+ return true
// The following three arch specific relocations are only for generation of
// Linux/ARM ELF's PLT entry (3 assembler instruction)
ld.Errorf(s, ".got.plt should be placed after .plt section.")
}
*val = 0xe28fc600 + (0xff & (int64(uint32(ld.Symaddr(r.Sym)-(ld.Symaddr(ctxt.Syms.Lookup(".plt", 0))+int64(r.Off))+r.Add)) >> 20))
- return 0
-
+ return true
case objabi.R_PLT1: // add ip, ip, #0xYY000
*val = 0xe28cca00 + (0xff & (int64(uint32(ld.Symaddr(r.Sym)-(ld.Symaddr(ctxt.Syms.Lookup(".plt", 0))+int64(r.Off))+r.Add+4)) >> 12))
- return 0
-
+ return true
case objabi.R_PLT2: // ldr pc, [ip, #0xZZZ]!
*val = 0xe5bcf000 + (0xfff & int64(uint32(ld.Symaddr(r.Sym)-(ld.Symaddr(ctxt.Syms.Lookup(".plt", 0))+int64(r.Off))+r.Add+8)))
- return 0
-
+ return true
case objabi.R_CALLARM: // bl XXXXXX or b YYYYYY
// r.Add is the instruction
// low 24-bit encodes the target address
}
*val = int64(braddoff(int32(0xff000000&uint32(r.Add)), int32(0xffffff&t)))
- return 0
+ return true
}
- return -1
+ return false
}
func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 {
return false
}
-func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
+func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) bool {
ld.Thearch.Vput(uint64(sectoff))
elfsym := r.Xsym.ElfsymForReloc()
switch r.Type {
default:
- return -1
-
+ return false
case objabi.R_ADDR:
switch r.Siz {
case 4:
case 8:
ld.Thearch.Vput(ld.R_AARCH64_ABS64 | uint64(elfsym)<<32)
default:
- return -1
+ return false
}
-
case objabi.R_ADDRARM64:
// two relocations: R_AARCH64_ADR_PREL_PG_HI21 and R_AARCH64_ADD_ABS_LO12_NC
ld.Thearch.Vput(ld.R_AARCH64_ADR_PREL_PG_HI21 | uint64(elfsym)<<32)
ld.Thearch.Vput(uint64(r.Xadd))
ld.Thearch.Vput(uint64(sectoff + 4))
ld.Thearch.Vput(ld.R_AARCH64_ADD_ABS_LO12_NC | uint64(elfsym)<<32)
-
case objabi.R_ARM64_TLS_LE:
ld.Thearch.Vput(ld.R_AARCH64_TLSLE_MOVW_TPREL_G0 | uint64(elfsym)<<32)
-
case objabi.R_ARM64_TLS_IE:
ld.Thearch.Vput(ld.R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 | uint64(elfsym)<<32)
ld.Thearch.Vput(uint64(r.Xadd))
ld.Thearch.Vput(uint64(sectoff + 4))
ld.Thearch.Vput(ld.R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC | uint64(elfsym)<<32)
-
case objabi.R_ARM64_GOTPCREL:
ld.Thearch.Vput(ld.R_AARCH64_ADR_GOT_PAGE | uint64(elfsym)<<32)
ld.Thearch.Vput(uint64(r.Xadd))
ld.Thearch.Vput(uint64(sectoff + 4))
ld.Thearch.Vput(ld.R_AARCH64_LD64_GOT_LO12_NC | uint64(elfsym)<<32)
-
case objabi.R_CALLARM64:
if r.Siz != 4 {
- return -1
+ return false
}
ld.Thearch.Vput(ld.R_AARCH64_CALL26 | uint64(elfsym)<<32)
}
ld.Thearch.Vput(uint64(r.Xadd))
- return 0
+ return true
}
func elfsetupplt(ctxt *ld.Link) {
return
}
-func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
+func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) bool {
var v uint32
rs := r.Xsym
if rs.Type == ld.SHOSTOBJ || r.Type == objabi.R_CALLARM64 || r.Type == objabi.R_ADDRARM64 || r.Type == objabi.R_ADDR {
if rs.Dynid < 0 {
ld.Errorf(s, "reloc %d (%s) to non-macho symbol %s type=%d (%s)", r.Type, ld.RelocName(r.Type), rs.Name, rs.Type, rs.Type)
- return -1
+ return false
}
v = uint32(rs.Dynid)
v = uint32(rs.Sect.Extnum)
if v == 0 {
ld.Errorf(s, "reloc %d (%s) to symbol %s in non-macho section %s type=%d (%s)", r.Type, ld.RelocName(r.Type), rs.Name, rs.Sect.Name, rs.Type, rs.Type)
- return -1
+ return false
}
}
switch r.Type {
default:
- return -1
-
+ return false
case objabi.R_ADDR:
v |= ld.MACHO_ARM64_RELOC_UNSIGNED << 28
-
case objabi.R_CALLARM64:
if r.Xadd != 0 {
ld.Errorf(s, "ld64 doesn't allow BR26 reloc with non-zero addend: %s+%d", rs.Name, r.Xadd)
v |= 1 << 24 // pc-relative bit
v |= ld.MACHO_ARM64_RELOC_BRANCH26 << 28
-
case objabi.R_ADDRARM64:
r.Siz = 4
// Two relocation entries: MACHO_ARM64_RELOC_PAGEOFF12 MACHO_ARM64_RELOC_PAGE21
switch r.Siz {
default:
- return -1
-
+ return false
case 1:
v |= 0 << 25
-
case 2:
v |= 1 << 25
-
case 4:
v |= 2 << 25
-
case 8:
v |= 3 << 25
}
ld.Thearch.Lput(uint32(sectoff))
ld.Thearch.Lput(v)
- return 0
+ return true
}
-func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
+func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) bool {
if ld.Linkmode == ld.LinkExternal {
switch r.Type {
default:
- return -1
-
+ return false
case objabi.R_ARM64_GOTPCREL:
var o1, o2 uint32
if ctxt.Arch.ByteOrder == binary.BigEndian {
*val = int64(o2)<<32 | int64(o1)
}
fallthrough
-
case objabi.R_ADDRARM64:
- r.Done = 0
+ r.Done = false
// set up addend for eventual relocation via outer symbol.
rs := r.Sym
}
}
- return 0
-
+ return true
case objabi.R_CALLARM64,
objabi.R_ARM64_TLS_LE,
objabi.R_ARM64_TLS_IE:
- r.Done = 0
+ r.Done = false
r.Xsym = r.Sym
r.Xadd = r.Add
- return 0
+ return true
}
}
switch r.Type {
case objabi.R_CONST:
*val = r.Add
- return 0
-
+ return true
case objabi.R_GOTOFF:
*val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ctxt.Syms.Lookup(".got", 0))
- return 0
-
+ return true
case objabi.R_ADDRARM64:
t := ld.Symaddr(r.Sym) + r.Add - ((s.Value + int64(r.Off)) &^ 0xfff)
if t >= 1<<32 || t < -1<<32 {
} else {
*val = int64(o1)<<32 | int64(o0)
}
- return 0
-
+ return true
case objabi.R_ARM64_TLS_LE:
- r.Done = 0
+ r.Done = false
if ld.Headtype != objabi.Hlinux {
ld.Errorf(s, "TLS reloc on unsupported OS %v", ld.Headtype)
}
ld.Errorf(s, "TLS offset out of range %d", v)
}
*val |= v << 5
- return 0
-
+ return true
case objabi.R_CALLARM64:
t := (ld.Symaddr(r.Sym) + r.Add) - (s.Value + int64(r.Off))
if t >= 1<<27 || t < -1<<27 {
ld.Errorf(s, "program too large, call relocation distance = %d", t)
}
*val |= (t >> 2) & 0x03ffffff
- return 0
+ return true
}
- return -1
+ return false
}
func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 {
for ri := int32(0); ri < int32(len(s.R)); ri++ {
r = &s.R[ri]
- r.Done = 1
+ r.Done = true
off = r.Off
siz = int32(r.Siz)
if off < 0 || off+siz > int32(len(s.P)) {
case 8:
o = int64(ctxt.Arch.ByteOrder.Uint64(s.P[off:]))
}
- if Thearch.Archreloc(ctxt, r, s, &o) < 0 {
+ if !Thearch.Archreloc(ctxt, r, s, &o) {
Errorf(s, "unknown reloc to %v: %d (%s)", r.Sym.Name, r.Type, RelocName(r.Type))
}
-
case objabi.R_TLS_LE:
isAndroidX86 := objabi.GOOS == "android" && (SysArch.InFamily(sys.AMD64, sys.I386))
if Linkmode == LinkExternal && Iself && !isAndroidX86 {
- r.Done = 0
+ r.Done = false
if r.Sym == nil {
r.Sym = ctxt.Tlsg
}
} else {
log.Fatalf("unexpected R_TLS_LE relocation for %v", Headtype)
}
-
case objabi.R_TLS_IE:
isAndroidX86 := objabi.GOOS == "android" && (SysArch.InFamily(sys.AMD64, sys.I386))
if Linkmode == LinkExternal && Iself && !isAndroidX86 {
- r.Done = 0
+ r.Done = false
if r.Sym == nil {
r.Sym = ctxt.Tlsg
}
} else {
log.Fatalf("cannot handle R_TLS_IE (sym %s) when linking internally", s.Name)
}
-
case objabi.R_ADDR:
if Linkmode == LinkExternal && r.Sym.Type != SCONST {
- r.Done = 0
+ r.Done = false
// set up addend for eventual relocation via outer symbol.
rs = r.Sym
Errorf(s, "non-pc-relative relocation address for %s is too big: %#x (%#x + %#x)", r.Sym.Name, uint64(o), Symaddr(r.Sym), r.Add)
errorexit()
}
-
case objabi.R_DWARFREF:
if r.Sym.Sect == nil {
Errorf(s, "missing DWARF section for relocation target %s", r.Sym.Name)
}
if Linkmode == LinkExternal {
- r.Done = 0
+ r.Done = false
// PE code emits IMAGE_REL_I386_SECREL and IMAGE_REL_AMD64_SECREL
// for R_DWARFREF relocations, while R_ADDR is replaced with
// IMAGE_REL_I386_DIR32, IMAGE_REL_AMD64_ADDR64 and IMAGE_REL_AMD64_ADDR32.
break
}
o = Symaddr(r.Sym) + r.Add - int64(r.Sym.Sect.Vaddr)
-
case objabi.R_WEAKADDROFF:
if !r.Sym.Attr.Reachable() {
continue
// r->sym can be null when CALL $(constant) is transformed from absolute PC to relative PC call.
case objabi.R_GOTPCREL:
if ctxt.DynlinkingGo() && Headtype == objabi.Hdarwin && r.Sym != nil && r.Sym.Type != SCONST {
- r.Done = 0
+ r.Done = false
r.Xadd = r.Add
r.Xadd -= int64(r.Siz) // relative to address after the relocated chunk
r.Xsym = r.Sym
fallthrough
case objabi.R_CALL, objabi.R_PCREL:
if Linkmode == LinkExternal && r.Sym != nil && r.Sym.Type != SCONST && (r.Sym.Sect != s.Sect || r.Type == objabi.R_GOTPCREL) {
- r.Done = 0
+ r.Done = false
// set up addend for eventual relocation via outer symbol.
rs = r.Sym
}
o += r.Add - (s.Value + int64(r.Off) + int64(r.Siz))
-
case objabi.R_SIZE:
o = r.Sym.Size + r.Add
}
// TODO(rsc): Remove.
case 1:
s.P[off] = byte(int8(o))
-
case 2:
if o != int64(int16(o)) {
Errorf(s, "relocation address for %s is too big: %#x", r.Sym.Name, o)
}
i16 = int16(o)
ctxt.Arch.ByteOrder.PutUint16(s.P[off:], uint16(i16))
-
case 4:
if r.Type == objabi.R_PCREL || r.Type == objabi.R_CALL {
if o != int64(int32(o)) {
fl = int32(o)
ctxt.Arch.ByteOrder.PutUint32(s.P[off:], uint32(fl))
-
case 8:
ctxt.Arch.ByteOrder.PutUint64(s.P[off:], uint64(o))
}
}
for ri := 0; ri < len(sym.R); ri++ {
r := &sym.R[ri]
- if r.Done != 0 {
+ if r.Done {
continue
}
if r.Xsym == nil {
if !r.Xsym.Attr.Reachable() {
Errorf(sym, "unreachable reloc %d (%s) target %v", r.Type, RelocName(r.Type), r.Xsym.Name)
}
- if Thearch.Elfreloc1(ctxt, r, int64(uint64(sym.Value+int64(r.Off))-sect.Vaddr)) < 0 {
+ if !Thearch.Elfreloc1(ctxt, r, int64(uint64(sym.Value+int64(r.Off))-sect.Vaddr)) {
Errorf(sym, "unsupported obj reloc %d (%s)/%d to %s", r.Type, RelocName(r.Type), r.Siz, r.Sym.Name)
}
}
Solarisdynld string
Adddynrel func(*Link, *Symbol, *Reloc) bool
Archinit func(*Link)
- Archreloc func(*Link, *Reloc, *Symbol, *int64) int
+ Archreloc func(*Link, *Reloc, *Symbol, *int64) bool
Archrelocvariant func(*Link, *Reloc, *Symbol, int64) int64
Trampoline func(*Link, *Reloc, *Symbol)
Asmb func(*Link)
- Elfreloc1 func(*Link, *Reloc, int64) int
+ Elfreloc1 func(*Link, *Reloc, int64) bool
Elfsetupplt func(*Link)
Gentext func(*Link)
- Machoreloc1 func(*Symbol, *Reloc, int64) int
+ Machoreloc1 func(*Symbol, *Reloc, int64) bool
PEreloc1 func(*Symbol, *Reloc, int64) bool
Wput func(uint16)
Lput func(uint32)
type Reloc struct {
Off int32 // offset to rewrite
Siz uint8 // number of bytes to rewrite, 1, 2, or 4
- Done uint8 // set to 1 when relocation is complete
+ Done bool // set to true when relocation is complete
Variant RelocVariant // variation on Type
Type objabi.RelocType // the relocation type
Add int64 // addend
}
for ri := 0; ri < len(sym.R); ri++ {
r := &sym.R[ri]
- if r.Done != 0 {
+ if r.Done {
continue
}
if r.Xsym == nil {
if !r.Xsym.Attr.Reachable() {
Errorf(sym, "unreachable reloc %d (%s) target %v", r.Type, RelocName(r.Type), r.Xsym.Name)
}
- if Thearch.Machoreloc1(sym, r, int64(uint64(sym.Value+int64(r.Off))-sect.Vaddr)) < 0 {
+ if !Thearch.Machoreloc1(sym, r, int64(uint64(sym.Value+int64(r.Off))-sect.Vaddr)) {
Errorf(sym, "unsupported obj reloc %d (%s)/%d to %s", r.Type, RelocName(r.Type), r.Siz, r.Sym.Name)
}
}
}
for ri := 0; ri < len(sym.R); ri++ {
r := &sym.R[ri]
- if r.Done != 0 {
+ if r.Done {
continue
}
if r.Xsym == nil {
return false
}
-func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
+func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) bool {
ld.Thearch.Lput(uint32(sectoff))
elfsym := r.Xsym.ElfsymForReloc()
switch r.Type {
default:
- return -1
-
+ return false
case objabi.R_ADDR:
if r.Siz != 4 {
- return -1
+ return false
}
ld.Thearch.Lput(ld.R_MIPS_32 | uint32(elfsym)<<8)
-
case objabi.R_ADDRMIPS:
ld.Thearch.Lput(ld.R_MIPS_LO16 | uint32(elfsym)<<8)
-
case objabi.R_ADDRMIPSU:
ld.Thearch.Lput(ld.R_MIPS_HI16 | uint32(elfsym)<<8)
-
case objabi.R_ADDRMIPSTLS:
ld.Thearch.Lput(ld.R_MIPS_TLS_TPREL_LO16 | uint32(elfsym)<<8)
-
case objabi.R_CALLMIPS, objabi.R_JMPMIPS:
ld.Thearch.Lput(ld.R_MIPS_26 | uint32(elfsym)<<8)
}
- return 0
+ return true
}
func elfsetupplt(ctxt *ld.Link) {
return
}
-func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
- return -1
+func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) bool {
+ return false
}
func applyrel(r *ld.Reloc, s *ld.Symbol, val *int64, t int64) {
}
}
-func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
+func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) bool {
if ld.Linkmode == ld.LinkExternal {
switch r.Type {
default:
- return -1
-
+ return false
case objabi.R_ADDRMIPS, objabi.R_ADDRMIPSU:
-
- r.Done = 0
+ r.Done = false
// set up addend for eventual relocation via outer symbol.
rs := r.Sym
}
r.Xsym = rs
applyrel(r, s, val, r.Xadd)
- return 0
-
+ return true
case objabi.R_ADDRMIPSTLS, objabi.R_CALLMIPS, objabi.R_JMPMIPS:
- r.Done = 0
+ r.Done = false
r.Xsym = r.Sym
r.Xadd = r.Add
applyrel(r, s, val, r.Add)
- return 0
+ return true
}
}
switch r.Type {
case objabi.R_CONST:
*val = r.Add
- return 0
-
+ return true
case objabi.R_GOTOFF:
*val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ctxt.Syms.Lookup(".got", 0))
- return 0
-
+ return true
case objabi.R_ADDRMIPS, objabi.R_ADDRMIPSU:
t := ld.Symaddr(r.Sym) + r.Add
applyrel(r, s, val, t)
- return 0
-
+ return true
case objabi.R_CALLMIPS, objabi.R_JMPMIPS:
t := ld.Symaddr(r.Sym) + r.Add
}
applyrel(r, s, val, t)
- return 0
-
+ return true
case objabi.R_ADDRMIPSTLS:
// thread pointer is at 0x7000 offset from the start of TLS data area
t := ld.Symaddr(r.Sym) + r.Add - 0x7000
ld.Errorf(s, "TLS offset out of range %d", t)
}
applyrel(r, s, val, t)
- return 0
+ return true
}
- return -1
+ return false
}
func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 {
return false
}
-func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
+func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) bool {
// mips64 ELF relocation (endian neutral)
// offset uint64
// sym uint32
ld.Cput(0)
switch r.Type {
default:
- return -1
-
+ return false
case objabi.R_ADDR:
switch r.Siz {
case 4:
case 8:
ld.Cput(ld.R_MIPS_64)
default:
- return -1
+ return false
}
-
case objabi.R_ADDRMIPS:
ld.Cput(ld.R_MIPS_LO16)
-
case objabi.R_ADDRMIPSU:
ld.Cput(ld.R_MIPS_HI16)
-
case objabi.R_ADDRMIPSTLS:
ld.Cput(ld.R_MIPS_TLS_TPREL_LO16)
-
case objabi.R_CALLMIPS,
objabi.R_JMPMIPS:
ld.Cput(ld.R_MIPS_26)
}
ld.Thearch.Vput(uint64(r.Xadd))
- return 0
+ return true
}
func elfsetupplt(ctxt *ld.Link) {
return
}
-func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
- return -1
+func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) bool {
+ return false
}
-func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
+func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) bool {
if ld.Linkmode == ld.LinkExternal {
switch r.Type {
default:
- return -1
-
+ return false
case objabi.R_ADDRMIPS,
objabi.R_ADDRMIPSU:
- r.Done = 0
+ r.Done = false
// set up addend for eventual relocation via outer symbol.
rs := r.Sym
}
r.Xsym = rs
- return 0
-
+ return true
case objabi.R_ADDRMIPSTLS,
objabi.R_CALLMIPS,
objabi.R_JMPMIPS:
- r.Done = 0
+ r.Done = false
r.Xsym = r.Sym
r.Xadd = r.Add
- return 0
+ return true
}
}
switch r.Type {
case objabi.R_CONST:
*val = r.Add
- return 0
-
+ return true
case objabi.R_GOTOFF:
*val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ctxt.Syms.Lookup(".got", 0))
- return 0
-
+ return true
case objabi.R_ADDRMIPS,
objabi.R_ADDRMIPSU:
t := ld.Symaddr(r.Sym) + r.Add
} else {
*val = int64(o1&0xffff0000 | uint32((t+1<<15)>>16)&0xffff)
}
- return 0
-
+ return true
case objabi.R_ADDRMIPSTLS:
// thread pointer is at 0x7000 offset from the start of TLS data area
t := ld.Symaddr(r.Sym) + r.Add - 0x7000
}
o1 := ld.SysArch.ByteOrder.Uint32(s.P[r.Off:])
*val = int64(o1&0xffff0000 | uint32(t)&0xffff)
- return 0
-
+ return true
case objabi.R_CALLMIPS,
objabi.R_JMPMIPS:
// Low 26 bits = (S + A) >> 2
t := ld.Symaddr(r.Sym) + r.Add
o1 := ld.SysArch.ByteOrder.Uint32(s.P[r.Off:])
*val = int64(o1&0xfc000000 | uint32(t>>2)&^0xfc000000)
- return 0
+ return true
}
- return -1
+ return false
}
func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 {
return false
}
-func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
+func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) bool {
ld.Thearch.Vput(uint64(sectoff))
elfsym := r.Xsym.ElfsymForReloc()
switch r.Type {
default:
- return -1
-
+ return false
case objabi.R_ADDR:
switch r.Siz {
case 4:
case 8:
ld.Thearch.Vput(ld.R_PPC64_ADDR64 | uint64(elfsym)<<32)
default:
- return -1
+ return false
}
-
case objabi.R_POWER_TLS:
ld.Thearch.Vput(ld.R_PPC64_TLS | uint64(elfsym)<<32)
-
case objabi.R_POWER_TLS_LE:
ld.Thearch.Vput(ld.R_PPC64_TPREL16 | uint64(elfsym)<<32)
-
case objabi.R_POWER_TLS_IE:
ld.Thearch.Vput(ld.R_PPC64_GOT_TPREL16_HA | uint64(elfsym)<<32)
ld.Thearch.Vput(uint64(r.Xadd))
ld.Thearch.Vput(uint64(sectoff + 4))
ld.Thearch.Vput(ld.R_PPC64_GOT_TPREL16_LO_DS | uint64(elfsym)<<32)
-
case objabi.R_ADDRPOWER:
ld.Thearch.Vput(ld.R_PPC64_ADDR16_HA | uint64(elfsym)<<32)
ld.Thearch.Vput(uint64(r.Xadd))
ld.Thearch.Vput(uint64(sectoff + 4))
ld.Thearch.Vput(ld.R_PPC64_ADDR16_LO | uint64(elfsym)<<32)
-
case objabi.R_ADDRPOWER_DS:
ld.Thearch.Vput(ld.R_PPC64_ADDR16_HA | uint64(elfsym)<<32)
ld.Thearch.Vput(uint64(r.Xadd))
ld.Thearch.Vput(uint64(sectoff + 4))
ld.Thearch.Vput(ld.R_PPC64_ADDR16_LO_DS | uint64(elfsym)<<32)
-
case objabi.R_ADDRPOWER_GOT:
ld.Thearch.Vput(ld.R_PPC64_GOT16_HA | uint64(elfsym)<<32)
ld.Thearch.Vput(uint64(r.Xadd))
ld.Thearch.Vput(uint64(sectoff + 4))
ld.Thearch.Vput(ld.R_PPC64_GOT16_LO_DS | uint64(elfsym)<<32)
-
case objabi.R_ADDRPOWER_PCREL:
ld.Thearch.Vput(ld.R_PPC64_REL16_HA | uint64(elfsym)<<32)
ld.Thearch.Vput(uint64(r.Xadd))
ld.Thearch.Vput(uint64(sectoff + 4))
ld.Thearch.Vput(ld.R_PPC64_REL16_LO | uint64(elfsym)<<32)
r.Xadd += 4
-
case objabi.R_ADDRPOWER_TOCREL:
ld.Thearch.Vput(ld.R_PPC64_TOC16_HA | uint64(elfsym)<<32)
ld.Thearch.Vput(uint64(r.Xadd))
ld.Thearch.Vput(uint64(sectoff + 4))
ld.Thearch.Vput(ld.R_PPC64_TOC16_LO | uint64(elfsym)<<32)
-
case objabi.R_ADDRPOWER_TOCREL_DS:
ld.Thearch.Vput(ld.R_PPC64_TOC16_HA | uint64(elfsym)<<32)
ld.Thearch.Vput(uint64(r.Xadd))
ld.Thearch.Vput(uint64(sectoff + 4))
ld.Thearch.Vput(ld.R_PPC64_TOC16_LO_DS | uint64(elfsym)<<32)
-
case objabi.R_CALLPOWER:
if r.Siz != 4 {
- return -1
+ return false
}
ld.Thearch.Vput(ld.R_PPC64_REL24 | uint64(elfsym)<<32)
}
ld.Thearch.Vput(uint64(r.Xadd))
- return 0
+ return true
}
func elfsetupplt(ctxt *ld.Link) {
}
}
-func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
- return -1
+func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) bool {
+ return false
}
// Return the value of .TOC. for symbol s
return toc.Value
}
-func archrelocaddr(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
+func archrelocaddr(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) bool {
var o1, o2 uint32
if ctxt.Arch.ByteOrder == binary.BigEndian {
o1 = uint32(*val >> 32)
case objabi.R_ADDRPOWER:
o1 |= (uint32(t) >> 16) & 0xffff
o2 |= uint32(t) & 0xffff
-
case objabi.R_ADDRPOWER_DS:
o1 |= (uint32(t) >> 16) & 0xffff
if t&3 != 0 {
ld.Errorf(s, "bad DS reloc for %s: %d", s.Name, ld.Symaddr(r.Sym))
}
o2 |= uint32(t) & 0xfffc
-
default:
- return -1
+ return false
}
if ctxt.Arch.ByteOrder == binary.BigEndian {
} else {
*val = int64(o2)<<32 | int64(o1)
}
- return 0
+ return true
}
// resolve direct jump relocation r in s, and add trampoline if necessary
}
r.Sym = tramp
r.Add = 0 // This was folded into the trampoline target address
- r.Done = 0
+ r.Done = false
}
default:
ld.Errorf(s, "trampoline called with non-jump reloc: %d (%s)", r.Type, ld.RelocName(r.Type))
ld.SysArch.ByteOrder.PutUint32(tramp.P[12:], o4)
}
-func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
+func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) bool {
if ld.Linkmode == ld.LinkExternal {
switch r.Type {
default:
- return -1
-
+ return false
case objabi.R_POWER_TLS, objabi.R_POWER_TLS_LE, objabi.R_POWER_TLS_IE:
- r.Done = 0
+ r.Done = false
// check Outer is nil, Type is TLSBSS?
r.Xadd = r.Add
r.Xsym = r.Sym
- return 0
-
+ return true
case objabi.R_ADDRPOWER,
objabi.R_ADDRPOWER_DS,
objabi.R_ADDRPOWER_TOCREL,
objabi.R_ADDRPOWER_TOCREL_DS,
objabi.R_ADDRPOWER_GOT,
objabi.R_ADDRPOWER_PCREL:
- r.Done = 0
+ r.Done = false
// set up addend for eventual relocation via outer symbol.
rs := r.Sym
}
r.Xsym = rs
- return 0
-
+ return true
case objabi.R_CALLPOWER:
- r.Done = 0
+ r.Done = false
r.Xsym = r.Sym
r.Xadd = r.Add
- return 0
+ return true
}
}
switch r.Type {
case objabi.R_CONST:
*val = r.Add
- return 0
-
+ return true
case objabi.R_GOTOFF:
*val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ctxt.Syms.Lookup(".got", 0))
- return 0
-
+ return true
case objabi.R_ADDRPOWER, objabi.R_ADDRPOWER_DS:
return archrelocaddr(ctxt, r, s, val)
-
case objabi.R_CALLPOWER:
// Bits 6 through 29 = (S + A - P) >> 2
ld.Errorf(s, "direct call too far: %s %x", r.Sym.Name, t)
}
*val |= int64(uint32(t) &^ 0xfc000003)
- return 0
-
+ return true
case objabi.R_POWER_TOC: // S + A - .TOC.
*val = ld.Symaddr(r.Sym) + r.Add - symtoc(ctxt, s)
- return 0
-
+ return true
case objabi.R_POWER_TLS_LE:
// The thread pointer points 0x7000 bytes after the start of the the
// thread local storage area as documented in section "3.7.2 TLS
ld.Errorf(s, "TLS offset out of range %d", v)
}
*val = (*val &^ 0xffff) | (v & 0xffff)
- return 0
+ return true
}
- return -1
+ return false
}
func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 {
return false
}
-func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
+func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) bool {
ld.Thearch.Vput(uint64(sectoff))
elfsym := r.Xsym.ElfsymForReloc()
switch r.Type {
default:
- return -1
-
+ return false
case objabi.R_TLS_LE:
switch r.Siz {
default:
- return -1
+ return false
case 4:
// WARNING - silently ignored by linker in ELF64
ld.Thearch.Vput(ld.R_390_TLS_LE32 | uint64(elfsym)<<32)
// WARNING - silently ignored by linker in ELF32
ld.Thearch.Vput(ld.R_390_TLS_LE64 | uint64(elfsym)<<32)
}
-
case objabi.R_TLS_IE:
switch r.Siz {
default:
- return -1
+ return false
case 4:
ld.Thearch.Vput(ld.R_390_TLS_IEENT | uint64(elfsym)<<32)
}
-
case objabi.R_ADDR:
switch r.Siz {
default:
- return -1
+ return false
case 4:
ld.Thearch.Vput(ld.R_390_32 | uint64(elfsym)<<32)
case 8:
ld.Thearch.Vput(ld.R_390_64 | uint64(elfsym)<<32)
}
-
case objabi.R_GOTPCREL:
if r.Siz == 4 {
ld.Thearch.Vput(ld.R_390_GOTENT | uint64(elfsym)<<32)
} else {
- return -1
+ return false
}
-
case objabi.R_PCREL, objabi.R_PCRELDBL, objabi.R_CALL:
elfrel := ld.R_390_NONE
isdbl := r.Variant&ld.RV_TYPE_MASK == ld.RV_390_DBL
}
}
if elfrel == ld.R_390_NONE {
- return -1 // unsupported size/dbl combination
+ return false // unsupported size/dbl combination
}
ld.Thearch.Vput(uint64(elfrel) | uint64(elfsym)<<32)
}
ld.Thearch.Vput(uint64(r.Xadd))
- return 0
+ return true
}
func elfsetupplt(ctxt *ld.Link) {
}
}
-func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
- return -1
+func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) bool {
+ return false
}
-func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
+func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) bool {
if ld.Linkmode == ld.LinkExternal {
- return -1
+ return false
}
switch r.Type {
case objabi.R_CONST:
*val = r.Add
- return 0
-
+ return true
case objabi.R_GOTOFF:
*val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ctxt.Syms.Lookup(".got", 0))
- return 0
+ return true
}
- return -1
+ return false
}
func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 {
return false
}
-func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) int {
+func elfreloc1(ctxt *ld.Link, r *ld.Reloc, sectoff int64) bool {
ld.Thearch.Lput(uint32(sectoff))
elfsym := r.Xsym.ElfsymForReloc()
switch r.Type {
default:
- return -1
-
+ return false
case objabi.R_ADDR:
if r.Siz == 4 {
ld.Thearch.Lput(ld.R_386_32 | uint32(elfsym)<<8)
} else {
- return -1
+ return false
}
-
case objabi.R_GOTPCREL:
if r.Siz == 4 {
ld.Thearch.Lput(ld.R_386_GOTPC)
ld.Thearch.Lput(ld.R_386_GOT32 | uint32(elfsym)<<8)
}
} else {
- return -1
+ return false
}
-
case objabi.R_CALL:
if r.Siz == 4 {
if r.Xsym.Type == ld.SDYNIMPORT {
ld.Thearch.Lput(ld.R_386_PC32 | uint32(elfsym)<<8)
}
} else {
- return -1
+ return false
}
-
case objabi.R_PCREL:
if r.Siz == 4 {
ld.Thearch.Lput(ld.R_386_PC32 | uint32(elfsym)<<8)
} else {
- return -1
+ return false
}
-
case objabi.R_TLS_LE:
if r.Siz == 4 {
ld.Thearch.Lput(ld.R_386_TLS_LE | uint32(elfsym)<<8)
} else {
- return -1
+ return false
}
-
case objabi.R_TLS_IE:
if r.Siz == 4 {
ld.Thearch.Lput(ld.R_386_GOTPC)
ld.Thearch.Lput(uint32(sectoff))
ld.Thearch.Lput(ld.R_386_TLS_GOTIE | uint32(elfsym)<<8)
} else {
- return -1
+ return false
}
}
- return 0
+ return true
}
-func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
+func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) bool {
var v uint32
rs := r.Xsym
if rs.Type == ld.SHOSTOBJ {
if rs.Dynid < 0 {
ld.Errorf(s, "reloc %d (%s) to non-macho symbol %s type=%d (%s)", r.Type, ld.RelocName(r.Type), rs.Name, rs.Type, rs.Type)
- return -1
+ return false
}
v = uint32(rs.Dynid)
v = uint32(rs.Sect.Extnum)
if v == 0 {
ld.Errorf(s, "reloc %d (%s) to symbol %s in non-macho section %s type=%d (%s)", r.Type, ld.RelocName(r.Type), rs.Name, rs.Sect.Name, rs.Type, rs.Type)
- return -1
+ return false
}
}
switch r.Type {
default:
- return -1
-
+ return false
case objabi.R_ADDR:
v |= ld.MACHO_GENERIC_RELOC_VANILLA << 28
-
case objabi.R_CALL,
objabi.R_PCREL:
v |= 1 << 24 // pc-relative bit
switch r.Siz {
default:
- return -1
-
+ return false
case 1:
v |= 0 << 25
-
case 2:
v |= 1 << 25
-
case 4:
v |= 2 << 25
-
case 8:
v |= 3 << 25
}
ld.Thearch.Lput(uint32(sectoff))
ld.Thearch.Lput(v)
- return 0
+ return true
}
func pereloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) bool {
return true
}
-func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) int {
+func archreloc(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, val *int64) bool {
if ld.Linkmode == ld.LinkExternal {
- return -1
+ return false
}
switch r.Type {
case objabi.R_CONST:
*val = r.Add
- return 0
-
+ return true
case objabi.R_GOTOFF:
*val = ld.Symaddr(r.Sym) + r.Add - ld.Symaddr(ctxt.Syms.Lookup(".got", 0))
- return 0
+ return true
}
- return -1
+ return false
}
func archrelocvariant(ctxt *ld.Link, r *ld.Reloc, s *ld.Symbol, t int64) int64 {