]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: improve error message
authorHiroshi Ioka <hirochachacha@gmail.com>
Sat, 12 Aug 2017 13:52:17 +0000 (22:52 +0900)
committerIan Lance Taylor <iant@golang.org>
Tue, 15 Aug 2017 00:28:27 +0000 (00:28 +0000)
ld.SymKind and objabi.RelocType have string representations,
which is human friendly. Prefer to use it.

Change-Id: I458ee0ca5866be0db8462c36cd053561a8206c95
Reviewed-on: https://go-review.googlesource.com/55253
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/link/internal/amd64/asm.go
src/cmd/link/internal/arm/asm.go
src/cmd/link/internal/arm64/asm.go
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/ld/elf.go
src/cmd/link/internal/ld/pe.go
src/cmd/link/internal/x86/asm.go

index d2f63d3d0592e04ba068a63039a7b272207bad3a..5f2a74d8cfe837b6bb836976614d33cab706ab81 100644 (file)
@@ -434,7 +434,7 @@ func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
 
        if rs.Type == ld.SHOSTOBJ || r.Type == objabi.R_PCREL || r.Type == objabi.R_GOTPCREL {
                if rs.Dynid < 0 {
-                       ld.Errorf(s, "reloc %d to non-macho symbol %s type=%d", r.Type, rs.Name, rs.Type)
+                       ld.Errorf(s, "reloc %d (%s) to non-macho symbol %s type=%d (%s)", r.Type, r.Type, rs.Name, rs.Type, rs.Type)
                        return -1
                }
 
@@ -443,7 +443,7 @@ func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
        } else {
                v = uint32(rs.Sect.Extnum)
                if v == 0 {
-                       ld.Errorf(s, "reloc %d to symbol %s in non-macho section %s type=%d", r.Type, rs.Name, rs.Sect.Name, rs.Type)
+                       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)
                        return -1
                }
        }
@@ -496,7 +496,7 @@ func pereloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) bool {
        rs := r.Xsym
 
        if rs.Dynid < 0 {
-               ld.Errorf(s, "reloc %d to non-coff symbol %s type=%d", r.Type, rs.Name, rs.Type)
+               ld.Errorf(s, "reloc %d (%s) to non-coff symbol %s type=%d (%s)", r.Type, r.Type, rs.Name, rs.Type, rs.Type)
                return false
        }
 
index 0f281c15998afdadf200bea07baa340c9db77e4f..2fc9329b61f04300c5fd78d5e041c256b9aeb0e3 100644 (file)
@@ -363,7 +363,7 @@ func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
 
        if rs.Type == ld.SHOSTOBJ || r.Type == objabi.R_CALLARM {
                if rs.Dynid < 0 {
-                       ld.Errorf(s, "reloc %d to non-macho symbol %s type=%d", r.Type, rs.Name, rs.Type)
+                       ld.Errorf(s, "reloc %d (%s) to non-macho symbol %s type=%d (%s)", r.Type, r.Type, rs.Name, rs.Type, rs.Type)
                        return -1
                }
 
@@ -372,7 +372,7 @@ func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
        } else {
                v = uint32(rs.Sect.Extnum)
                if v == 0 {
-                       ld.Errorf(s, "reloc %d to symbol %s in non-macho section %s type=%d", r.Type, rs.Name, rs.Sect.Name, rs.Type)
+                       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)
                        return -1
                }
        }
index 92a87f99f7dddc2a9fea049941d2e36a50f34dc9..8d3c6fcb576a33fabcceab1f0c8209c2672184c7 100644 (file)
@@ -158,7 +158,7 @@ func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
        // 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 to non-macho symbol %s type=%d", r.Type, rs.Name, rs.Type)
+                       ld.Errorf(s, "reloc %d (%s) to non-macho symbol %s type=%d (%s)", r.Type, r.Type, rs.Name, rs.Type, rs.Type)
                        return -1
                }
 
@@ -167,7 +167,7 @@ func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
        } else {
                v = uint32(rs.Sect.Extnum)
                if v == 0 {
-                       ld.Errorf(s, "reloc %d to symbol %s in non-macho section %s type=%d", r.Type, rs.Name, rs.Sect.Name, rs.Type)
+                       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)
                        return -1
                }
        }
index 23e0e4f2b036bf9beed5d7ea331e90af5cc1eee8..691e74cc974eb69ff881f5b98e4ffaa5ef71022c 100644 (file)
@@ -432,7 +432,7 @@ func relocsym(ctxt *Link, s *Symbol) {
                // 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 rtype %d)", r.Sym.Name, r.Sym.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, r.Type)
                        }
                }
                if r.Sym != nil && r.Sym.Type != STLSBSS && r.Type != objabi.R_WEAKADDROFF && !r.Sym.Attr.Reachable() {
@@ -828,7 +828,7 @@ func dynrelocsym(ctxt *Link, s *Symbol) {
                                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 stype=%d)", r.Sym.Name, r.Type, r.Sym.Type)
+                               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)
                        }
                }
        }
index 78f8d6e70ea8fd28867a2d1c9174ad4355d454be..9ac55ada1dfd59455646a743fbe00df0edf5c88b 100644 (file)
@@ -1812,13 +1812,13 @@ func elfrelocsect(ctxt *Link, sect *Section, syms []*Symbol) {
                                continue
                        }
                        if r.Xsym.ElfsymForReloc() == 0 {
-                               Errorf(sym, "reloc %d to non-elf symbol %s (outer=%s) %d", r.Type, r.Sym.Name, r.Xsym.Name, r.Sym.Type)
+                               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)
                        }
                        if !r.Xsym.Attr.Reachable() {
                                Errorf(sym, "unreachable reloc %v target %v", 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/%d to %s", r.Type, r.Siz, r.Sym.Name)
+                               Errorf(sym, "unsupported obj reloc %d (%s)/%d to %s", r.Type, r.Type, r.Siz, r.Sym.Name)
                        }
                }
        }
index f26c83ee30e25537126a0e10eb9c48d121398e0f..caa3eabb511acc9ba210bc49d9ec015b3c096f0c 100644 (file)
@@ -839,10 +839,10 @@ func perelocsect(ctxt *Link, sect *Section, syms []*Symbol, base uint64) int {
                        }
 
                        if r.Xsym.Dynid < 0 {
-                               Errorf(sym, "reloc %d to non-coff symbol %s (outer=%s) %d", r.Type, r.Sym.Name, r.Xsym.Name, r.Sym.Type)
+                               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)
                        }
                        if !Thearch.PEreloc1(sym, r, int64(uint64(sym.Value+int64(r.Off))-base)) {
-                               Errorf(sym, "unsupported obj reloc %d/%d to %s", r.Type, r.Siz, r.Sym.Name)
+                               Errorf(sym, "unsupported obj reloc %d (%s)/%d to %s", r.Type, r.Type, r.Siz, r.Sym.Name)
                        }
 
                        relocs++
index 3649e6a8f82de463eb55eab5e79f2e09dbc89bbb..157b42697113ead9570b74d36f71cf2122baaa67 100644 (file)
@@ -416,7 +416,7 @@ func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
 
        if rs.Type == ld.SHOSTOBJ {
                if rs.Dynid < 0 {
-                       ld.Errorf(s, "reloc %d to non-macho symbol %s type=%d", r.Type, rs.Name, rs.Type)
+                       ld.Errorf(s, "reloc %d (%s) to non-macho symbol %s type=%d (%s)", r.Type, r.Type, rs.Name, rs.Type, rs.Type)
                        return -1
                }
 
@@ -425,7 +425,7 @@ func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
        } else {
                v = uint32(rs.Sect.Extnum)
                if v == 0 {
-                       ld.Errorf(s, "reloc %d to symbol %s in non-macho section %s type=%d", r.Type, rs.Name, rs.Sect.Name, rs.Type)
+                       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)
                        return -1
                }
        }
@@ -471,7 +471,7 @@ func pereloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) bool {
        rs := r.Xsym
 
        if rs.Dynid < 0 {
-               ld.Errorf(s, "reloc %d to non-coff symbol %s type=%d", r.Type, rs.Name, rs.Type)
+               ld.Errorf(s, "reloc %d (%s) to non-coff symbol %s type=%d (%s)", r.Type, r.Type, rs.Name, rs.Type, rs.Type)
                return false
        }