switch r.Type {
default:
if r.Type >= 256 {
- ld.Errorf(s, "unexpected relocation type %d", r.Type)
+ ld.Errorf(s, "unexpected relocation type %d (%s)", r.Type, ld.RelocName(r.Type))
return false
}
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, r.Type, rs.Name, rs.Type, rs.Type)
+ 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
}
} else {
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, r.Type, rs.Name, rs.Sect.Name, rs.Type, rs.Type)
+ 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
}
}
rs := r.Xsym
if rs.Dynid < 0 {
- ld.Errorf(s, "reloc %d (%s) to non-coff symbol %s type=%d (%s)", r.Type, r.Type, rs.Name, rs.Type, rs.Type)
+ ld.Errorf(s, "reloc %d (%s) to non-coff symbol %s type=%d (%s)", r.Type, ld.RelocName(r.Type), rs.Name, rs.Type, rs.Type)
return false
}
switch r.Type {
default:
if r.Type >= 256 {
- ld.Errorf(s, "unexpected relocation type %d", r.Type)
+ ld.Errorf(s, "unexpected relocation type %d (%s)", r.Type, ld.RelocName(r.Type))
return false
}
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, r.Type, rs.Name, rs.Type, rs.Type)
+ 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
}
} else {
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, r.Type, rs.Name, rs.Sect.Name, rs.Type, rs.Type)
+ 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
}
}
r.Done = 0
}
default:
- ld.Errorf(s, "trampoline called with non-jump reloc: %v", r.Type)
+ ld.Errorf(s, "trampoline called with non-jump reloc: %d (%s)", r.Type, ld.RelocName(r.Type))
}
}
// UNSIGNED relocation at all.
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, r.Type, rs.Name, rs.Type, rs.Type)
+ 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
}
} else {
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, r.Type, rs.Name, rs.Sect.Name, rs.Type, rs.Type)
+ 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
}
}
// shared libraries, and Solaris needs it always
if Headtype != objabi.Hsolaris && r.Sym != nil && r.Sym.Type == SDYNIMPORT && !ctxt.DynlinkingGo() {
if !(SysArch.Family == sys.PPC64 && Linkmode == LinkExternal && r.Sym.Name == ".TOC.") {
- Errorf(s, "unhandled relocation for %s (type %d (%s) rtype %d (%s))", r.Sym.Name, r.Sym.Type, r.Sym.Type, r.Type, r.Type)
+ Errorf(s, "unhandled relocation for %s (type %d (%s) rtype %d (%s))", r.Sym.Name, r.Sym.Type, r.Sym.Type, r.Type, RelocName(r.Type))
}
}
if r.Sym != nil && r.Sym.Type != STLSBSS && r.Type != objabi.R_WEAKADDROFF && !r.Sym.Attr.Reachable() {
o = int64(ctxt.Arch.ByteOrder.Uint64(s.P[off:]))
}
if Thearch.Archreloc(ctxt, r, s, &o) < 0 {
- Errorf(s, "unknown reloc to %v: %v", r.Sym.Name, r.Type)
+ Errorf(s, "unknown reloc to %v: %d (%s)", r.Sym.Name, r.Type, RelocName(r.Type))
}
case objabi.R_TLS_LE:
if r.Sym != nil {
nam = r.Sym.Name
}
- fmt.Printf("relocate %s %#x (%#x+%#x, size %d) => %s %#x +%#x [type %d/%d, %x]\n", s.Name, s.Value+int64(off), s.Value, r.Off, r.Siz, nam, Symaddr(r.Sym), r.Add, r.Type, r.Variant, o)
+ fmt.Printf("relocate %s %#x (%#x+%#x, size %d) => %s %#x +%#x [type %d (%s)/%d, %x]\n", s.Name, s.Value+int64(off), s.Value, r.Off, r.Siz, nam, Symaddr(r.Sym), r.Add, r.Type, RelocName(r.Type), r.Variant, o)
}
switch siz {
default:
Errorf(s, "dynamic relocation to unreachable symbol %s", r.Sym.Name)
}
if !Thearch.Adddynrel(ctxt, s, r) {
- Errorf(s, "unsupported dynamic relocation for symbol %s (type=%d (%s) stype=%d (%s))", r.Sym.Name, r.Type, r.Type, r.Sym.Type, r.Sym.Type)
+ Errorf(s, "unsupported dynamic relocation for symbol %s (type=%d (%s) stype=%d (%s))", r.Sym.Name, r.Type, RelocName(r.Type), r.Sym.Type, r.Sym.Type)
}
}
}
continue
}
if r.Xsym.ElfsymForReloc() == 0 {
- Errorf(sym, "reloc %d (%s) to non-elf symbol %s (outer=%s) %d (%s)", r.Type, r.Type, r.Sym.Name, r.Xsym.Name, r.Sym.Type, r.Sym.Type)
+ Errorf(sym, "reloc %d (%s) to non-elf symbol %s (outer=%s) %d (%s)", r.Type, RelocName(r.Type), r.Sym.Name, r.Xsym.Name, r.Sym.Type, r.Sym.Type)
}
if !r.Xsym.Attr.Reachable() {
- Errorf(sym, "unreachable reloc %v target %v", r.Type, r.Xsym.Name)
+ 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 {
- Errorf(sym, "unsupported obj reloc %d (%s)/%d to %s", r.Type, r.Type, r.Siz, r.Sym.Name)
+ Errorf(sym, "unsupported obj reloc %d (%s)/%d to %s", r.Type, RelocName(r.Type), r.Siz, r.Sym.Name)
}
}
}
RV_CHECK_OVERFLOW RelocVariant = 1 << 7
RV_TYPE_MASK RelocVariant = RV_CHECK_OVERFLOW - 1
)
+
+func RelocName(r objabi.RelocType) string {
+ // We didn't have some relocation types at Go1.4.
+ // Uncomment code when we include those in bootstrap code.
+
+ switch {
+ case r >= 512: // Mach-O
+ // nr := (r - 512)>>1
+ // switch SysArch.Family {
+ // case sys.AMD64:
+ // return macho.RelocTypeX86_64(nr).String()
+ // case sys.ARM:
+ // return macho.RelocTypeARM(nr).String()
+ // case sys.ARM64:
+ // return macho.RelocTypeARM64(nr).String()
+ // case sys.I386:
+ // return macho.RelocTypeGeneric(nr).String()
+ // default:
+ // panic("unreachable")
+ // }
+ case r >= 256: // ELF
+ nr := r - 256
+ switch SysArch.Family {
+ case sys.AMD64:
+ return elf.R_X86_64(nr).String()
+ case sys.ARM:
+ return elf.R_ARM(nr).String()
+ case sys.ARM64:
+ return elf.R_AARCH64(nr).String()
+ case sys.I386:
+ return elf.R_386(nr).String()
+ case sys.MIPS, sys.MIPS64:
+ // return elf.R_MIPS(nr).String()
+ case sys.PPC64:
+ // return elf.R_PPC64(nr).String()
+ case sys.S390X:
+ // return elf.R_390(nr).String()
+ default:
+ panic("unreachable")
+ }
+ }
+
+ return r.String()
+}
continue
}
if !r.Xsym.Attr.Reachable() {
- Errorf(sym, "unreachable reloc %v target %v", r.Type, r.Xsym.Name)
+ 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 {
- Errorf(sym, "unsupported obj reloc %v/%d to %s", r.Type, r.Siz, r.Sym.Name)
+ Errorf(sym, "unsupported obj reloc %d (%s)/%d to %s", r.Type, RelocName(r.Type), r.Siz, r.Sym.Name)
}
}
}
}
if r.Xsym.Dynid < 0 {
- Errorf(sym, "reloc %d (%s) to non-coff symbol %s (outer=%s) %d (%s)", r.Type, r.Type, r.Sym.Name, r.Xsym.Name, r.Sym.Type, r.Sym.Type)
+ Errorf(sym, "reloc %d (%s) to non-coff symbol %s (outer=%s) %d (%s)", r.Type, RelocName(r.Type), r.Sym.Name, r.Xsym.Name, r.Sym.Type, r.Sym.Type)
}
if !Thearch.PEreloc1(sym, r, int64(uint64(sym.Value+int64(r.Off))-base)) {
- Errorf(sym, "unsupported obj reloc %d (%s)/%d to %s", r.Type, r.Type, r.Siz, r.Sym.Name)
+ Errorf(sym, "unsupported obj reloc %d (%s)/%d to %s", r.Type, RelocName(r.Type), r.Siz, r.Sym.Name)
}
relocs++
switch r.Type {
default:
if r.Type >= 256 {
- ld.Errorf(s, "unexpected relocation type %d", r.Type)
+ ld.Errorf(s, "unexpected relocation type %d (%s)", r.Type, ld.RelocName(r.Type))
return false
}
r.Done = 0
}
default:
- ld.Errorf(s, "trampoline called with non-jump reloc: %v", r.Type)
+ ld.Errorf(s, "trampoline called with non-jump reloc: %d (%s)", r.Type, ld.RelocName(r.Type))
}
}
switch r.Type {
default:
if r.Type >= 256 {
- ld.Errorf(s, "unexpected relocation type %d", r.Type)
+ ld.Errorf(s, "unexpected relocation type %d (%s)", r.Type, ld.RelocName(r.Type))
return false
}
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, r.Type, rs.Name, rs.Type, rs.Type)
+ 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
}
} else {
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, r.Type, rs.Name, rs.Sect.Name, rs.Type, rs.Type)
+ 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
}
}
rs := r.Xsym
if rs.Dynid < 0 {
- ld.Errorf(s, "reloc %d (%s) to non-coff symbol %s type=%d (%s)", r.Type, r.Type, rs.Name, rs.Type, rs.Type)
+ ld.Errorf(s, "reloc %d (%s) to non-coff symbol %s type=%d (%s)", r.Type, ld.RelocName(r.Type), rs.Name, rs.Type, rs.Type)
return false
}