Skip to content

Commit 182a289

Browse files
committed
keep type name
1 parent 900bf7e commit 182a289

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

src/cmd/compile/internal/gc/obj.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func dumpGlobalConst(n *ir.Name) {
199199
if t.IsInteger() {
200200
base.Ctxt.DwarfIntConst(n.Sym().Name, types.TypeSymName(t), ir.IntVal(t, v))
201201
} else if t.IsString() {
202-
base.Ctxt.DwarfStringConst(n.Sym().Name, ir.StringVal(n))
202+
base.Ctxt.DwarfStringConst(n.Sym().Name, types.TypeSymName(t), ir.StringVal(n))
203203
}
204204
}
205205

src/cmd/internal/dwarf/dwarf.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ const InfoPrefix = "go:info."
2828
const ConstInfoPrefix = "go:constinfo."
2929

3030
// ConstStringInfoPrefix is the prefix for all symbols containing
31-
// DWARF info entries that referred by string constants.
32-
const ConstStringInfoPrefix = "string$const."
31+
// DWARF info entries that are referred by string constants.
32+
const ConstStringInfoPrefix = "$const."
3333

3434
// CUInfoPrefix is the prefix for symbols containing information to
3535
// populate the DWARF compilation unit info entries.

src/cmd/internal/obj/dwarf.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,12 +419,12 @@ func (ctxt *Link) DwarfIntConst(name, typename string, val int64) {
419419

420420
// DwarfStringConst creates a link symbol for a string constant with the
421421
// given name and value.
422-
func (ctxt *Link) DwarfStringConst(name, value string) {
422+
func (ctxt *Link) DwarfStringConst(name, typename, value string) {
423423
s := ctxt.ensureConstInfoSym()
424424
if s == nil {
425425
return
426426
}
427-
typSym := ctxt.Lookup(dwarf.InfoPrefix + dwarf.ConstStringInfoPrefix + strconv.Itoa(len(value)))
427+
typSym := ctxt.Lookup(dwarf.InfoPrefix + dwarf.ConstStringInfoPrefix + typename + "." + strconv.Itoa(len(value)))
428428
dwarf.PutStringConst(dwCtxt{ctxt}, s, typSym, ctxt.Pkgpath+"."+name, value)
429429
}
430430

src/cmd/link/internal/ld/dwarf.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,12 +1188,16 @@ func (d *dwctxt) genConstStringType(name string) {
11881188
if d.find(name) != 0 {
11891189
return
11901190
}
1191-
size, err := strconv.Atoi(name[len(dwarf.ConstStringInfoPrefix):])
1191+
i := strings.LastIndex(name, ".")
1192+
if i < 0 {
1193+
log.Fatalf("error: invalid constant string type name %q", name)
1194+
}
1195+
size, err := strconv.ParseInt(name[i+1:], 10, 64)
11921196
if err != nil {
1193-
log.Fatalf("error: invalid constant string size %q: %v", name, err)
1197+
log.Fatalf("error: invalid constant string type name %q: %v", name, err)
11941198
}
11951199
die := d.newdie(&dwtypes, dwarf.DW_ABRV_CONSTANT_STRINGTYPE, name)
1196-
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, int64(size), 0)
1200+
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, size, 0)
11971201
}
11981202

11991203
func (d *dwctxt) importInfoSymbol(dsym loader.Sym) {

0 commit comments

Comments
 (0)