Skip to content

Commit c54ae79

Browse files
committed
cmd/internal/obj: symbol redeclared panics during InitTextSym
Now the linker reports the following error message /go/test/fixedbugs/issue68962.go:11:6: symbol main.c redeclared at /go/test/fixedbugs/issue68962.go:13:6 Fixes #68962
1 parent 7fcd4a7 commit c54ae79

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/cmd/internal/obj/plist.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,16 @@ func (ctxt *Link) InitTextSym(s *LSym, flag int, start src.XPos) {
183183
return
184184
}
185185
if s.Func() != nil {
186-
ctxt.Diag("%s: symbol %s redeclared\n\t%s: other declaration of symbol %s", ctxt.PosTable.Pos(start), s.Name, ctxt.PosTable.Pos(s.Func().Text.Pos), s.Name)
186+
ctxt.Diag("symbol %s redeclared at %s", s.Name, ctxt.PosTable.Pos(start))
187187
return
188188
}
189189
s.NewFuncInfo()
190190
if s.OnList() {
191-
ctxt.Diag("%s: symbol %s redeclared", ctxt.PosTable.Pos(start), s.Name)
191+
ctxt.Diag("symbol %s redeclared at %s", s.Name, ctxt.PosTable.Pos(start))
192192
return
193193
}
194194
if strings.HasPrefix(s.Name, `"".`) {
195-
ctxt.Diag("%s: unqualified symbol name: %s", ctxt.PosTable.Pos(start), s.Name)
195+
ctxt.Diag("unqualified symbol name %s at %s", s.Name, ctxt.PosTable.Pos(start))
196196
}
197197

198198
// startLine should be the same line number that would be displayed via

test/fixedbugs/issue68962.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// compile
2+
3+
// Copyright 2024 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
package main
7+
8+
import _ "unsafe"
9+
10+
//go:linkname a main.c
11+
func a() {}
12+
13+
func c() {}

0 commit comments

Comments
 (0)