Skip to content

Commit a2c54ef

Browse files
committed
fix type name
1 parent 182a289 commit a2c54ef

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,16 @@ func (d *dwctxt) newdie(parent *dwarf.DWDie, abbrev int, name string) *dwarf.DWD
286286
die.Link = parent.Child
287287
parent.Child = die
288288

289-
newattr(die, dwarf.DW_AT_name, dwarf.DW_CLS_STRING, int64(len(name)), name)
290-
291289
// Sanity check: all DIEs created in the linker should be named.
292290
if name == "" {
293291
panic("nameless DWARF DIE")
294292
}
295293

294+
// for constant string types, we emit the nams later since it didn't use symbol name as DW_AT_name
295+
if abbrev != dwarf.DW_ABRV_CONSTANT_STRINGTYPE {
296+
newattr(die, dwarf.DW_AT_name, dwarf.DW_CLS_STRING, int64(len(name)), name)
297+
}
298+
296299
var st sym.SymKind
297300
switch abbrev {
298301
case dwarf.DW_ABRV_FUNCTYPEPARAM, dwarf.DW_ABRV_FUNCTYPEOUTPARAM, dwarf.DW_ABRV_DOTDOTDOT, dwarf.DW_ABRV_STRUCTFIELD, dwarf.DW_ABRV_ARRAYRANGE:
@@ -1196,7 +1199,9 @@ func (d *dwctxt) genConstStringType(name string) {
11961199
if err != nil {
11971200
log.Fatalf("error: invalid constant string type name %q: %v", name, err)
11981201
}
1202+
atname := name[len(dwarf.ConstStringInfoPrefix):i]
11991203
die := d.newdie(&dwtypes, dwarf.DW_ABRV_CONSTANT_STRINGTYPE, name)
1204+
newattr(die, dwarf.DW_AT_name, dwarf.DW_CLS_STRING, int64(len(atname)), atname)
12001205
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, size, 0)
12011206
}
12021207

0 commit comments

Comments
 (0)