Skip to content

Commit bced369

Browse files
committed
cmd/link: minor code cleanup in dwarf gen
Minor code cleanup to get rid of a few unused parameters and return values in the linker's dwarf generation code. No functional changes. Change-Id: I1a68ebe0f08d8d32ca7adfdd2fb9db573a4fd5f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/332070 Trust: Than McIntosh <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Run-TryBot: Than McIntosh <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent c3b217a commit bced369

File tree

1 file changed

+62
-71
lines changed

1 file changed

+62
-71
lines changed

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

Lines changed: 62 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,6 @@ type dwctxt struct {
6767
dwmu *sync.Mutex
6868
}
6969

70-
func newdwctxt(linkctxt *Link, forTypeGen bool) dwctxt {
71-
d := dwctxt{
72-
linkctxt: linkctxt,
73-
ldr: linkctxt.loader,
74-
arch: linkctxt.Arch,
75-
tmap: make(map[string]loader.Sym),
76-
tdmap: make(map[loader.Sym]loader.Sym),
77-
rtmap: make(map[loader.Sym]loader.Sym),
78-
}
79-
d.typeRuntimeEface = d.lookupOrDiag("type.runtime.eface")
80-
d.typeRuntimeIface = d.lookupOrDiag("type.runtime.iface")
81-
return d
82-
}
83-
8470
// dwSym wraps a loader.Sym; this type is meant to obey the interface
8571
// rules for dwarf.Sym from the cmd/internal/dwarf package. DwDie and
8672
// DwAttr objects contain references to symbols via this type.
@@ -249,15 +235,14 @@ var dwtypes dwarf.DWDie
249235
// up all attrs in a single large table, then store indices into the
250236
// table in the DIE. This would allow us to common up storage for
251237
// attributes that are shared by many DIEs (ex: byte size of N).
252-
func newattr(die *dwarf.DWDie, attr uint16, cls int, value int64, data interface{}) *dwarf.DWAttr {
238+
func newattr(die *dwarf.DWDie, attr uint16, cls int, value int64, data interface{}) {
253239
a := new(dwarf.DWAttr)
254240
a.Link = die.Attr
255241
die.Attr = a
256242
a.Atr = attr
257243
a.Cls = uint8(cls)
258244
a.Value = value
259245
a.Data = data
260-
return a
261246
}
262247

263248
// Each DIE (except the root ones) has at least 1 attribute: its
@@ -290,18 +275,17 @@ func getattr(die *dwarf.DWDie, attr uint16) *dwarf.DWAttr {
290275
// The compiler does create nameless DWARF DIEs (ex: concrete subprogram
291276
// instance).
292277
// FIXME: it would be more efficient to bulk-allocate DIEs.
293-
func (d *dwctxt) newdie(parent *dwarf.DWDie, abbrev int, name string, version int) *dwarf.DWDie {
278+
func (d *dwctxt) newdie(parent *dwarf.DWDie, abbrev int, name string) *dwarf.DWDie {
294279
die := new(dwarf.DWDie)
295280
die.Abbrev = abbrev
296281
die.Link = parent.Child
297282
parent.Child = die
298283

299284
newattr(die, dwarf.DW_AT_name, dwarf.DW_CLS_STRING, int64(len(name)), name)
300285

301-
// Sanity check: all DIEs created in the linker should have a non-empty
302-
// name and be version zero.
303-
if name == "" || version != 0 {
304-
panic("nameless or version non-zero DWARF DIE")
286+
// Sanity check: all DIEs created in the linker should be named.
287+
if name == "" {
288+
panic("nameless DWARF DIE")
305289
}
306290

307291
var st sym.SymKind
@@ -321,7 +305,7 @@ func (d *dwctxt) newdie(parent *dwarf.DWDie, abbrev int, name string, version in
321305
// this also includes loose ends such as STRUCT_FIELD.
322306
st = sym.SDWARFTYPE
323307
}
324-
ds := d.ldr.LookupOrCreateSym(dwarf.InfoPrefix+name, version)
308+
ds := d.ldr.LookupOrCreateSym(dwarf.InfoPrefix+name, 0)
325309
dsu := d.ldr.MakeSymbolUpdater(ds)
326310
dsu.SetType(st)
327311
d.ldr.SetAttrNotInSymbolTable(ds, true)
@@ -397,22 +381,20 @@ func (d *dwctxt) mustFind(name string) loader.Sym {
397381
return r
398382
}
399383

400-
func (d *dwctxt) adddwarfref(sb *loader.SymbolBuilder, t loader.Sym, size int) int64 {
401-
var result int64
384+
func (d *dwctxt) adddwarfref(sb *loader.SymbolBuilder, t loader.Sym, size int) {
402385
switch size {
403386
default:
404387
d.linkctxt.Errorf(sb.Sym(), "invalid size %d in adddwarfref\n", size)
405388
case d.arch.PtrSize, 4:
406389
}
407-
result = sb.AddSymRef(d.arch, t, 0, objabi.R_DWARFSECREF, size)
408-
return result
390+
sb.AddSymRef(d.arch, t, 0, objabi.R_DWARFSECREF, size)
409391
}
410392

411-
func (d *dwctxt) newrefattr(die *dwarf.DWDie, attr uint16, ref loader.Sym) *dwarf.DWAttr {
393+
func (d *dwctxt) newrefattr(die *dwarf.DWDie, attr uint16, ref loader.Sym) {
412394
if ref == 0 {
413-
return nil
395+
return
414396
}
415-
return newattr(die, attr, dwarf.DW_CLS_REFERENCE, 0, dwSym(ref))
397+
newattr(die, attr, dwarf.DW_CLS_REFERENCE, 0, dwSym(ref))
416398
}
417399

418400
func (d *dwctxt) dtolsym(s dwarf.Sym) loader.Sym {
@@ -481,7 +463,7 @@ func (d *dwctxt) lookupOrDiag(n string) loader.Sym {
481463
return symIdx
482464
}
483465

484-
func (d *dwctxt) dotypedef(parent *dwarf.DWDie, gotype loader.Sym, name string, def *dwarf.DWDie) *dwarf.DWDie {
466+
func (d *dwctxt) dotypedef(parent *dwarf.DWDie, name string, def *dwarf.DWDie) *dwarf.DWDie {
485467
// Only emit typedefs for real names.
486468
if strings.HasPrefix(name, "map[") {
487469
return nil
@@ -513,7 +495,7 @@ func (d *dwctxt) dotypedef(parent *dwarf.DWDie, gotype loader.Sym, name string,
513495
// so that future lookups will find the typedef instead
514496
// of the real definition. This hooks the typedef into any
515497
// circular definition loops, so that gdb can understand them.
516-
die := d.newdie(parent, dwarf.DW_ABRV_TYPEDECL, name, 0)
498+
die := d.newdie(parent, dwarf.DW_ABRV_TYPEDECL, name)
517499

518500
d.newrefattr(die, dwarf.DW_AT_type, tds)
519501

@@ -558,7 +540,7 @@ func (d *dwctxt) newtype(gotype loader.Sym) *dwarf.DWDie {
558540
var die, typedefdie *dwarf.DWDie
559541
switch kind {
560542
case objabi.KindBool:
561-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name, 0)
543+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name)
562544
newattr(die, dwarf.DW_AT_encoding, dwarf.DW_CLS_CONSTANT, dwarf.DW_ATE_boolean, 0)
563545
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
564546

@@ -567,7 +549,7 @@ func (d *dwctxt) newtype(gotype loader.Sym) *dwarf.DWDie {
567549
objabi.KindInt16,
568550
objabi.KindInt32,
569551
objabi.KindInt64:
570-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name, 0)
552+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name)
571553
newattr(die, dwarf.DW_AT_encoding, dwarf.DW_CLS_CONSTANT, dwarf.DW_ATE_signed, 0)
572554
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
573555

@@ -577,72 +559,72 @@ func (d *dwctxt) newtype(gotype loader.Sym) *dwarf.DWDie {
577559
objabi.KindUint32,
578560
objabi.KindUint64,
579561
objabi.KindUintptr:
580-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name, 0)
562+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name)
581563
newattr(die, dwarf.DW_AT_encoding, dwarf.DW_CLS_CONSTANT, dwarf.DW_ATE_unsigned, 0)
582564
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
583565

584566
case objabi.KindFloat32,
585567
objabi.KindFloat64:
586-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name, 0)
568+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name)
587569
newattr(die, dwarf.DW_AT_encoding, dwarf.DW_CLS_CONSTANT, dwarf.DW_ATE_float, 0)
588570
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
589571

590572
case objabi.KindComplex64,
591573
objabi.KindComplex128:
592-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name, 0)
574+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name)
593575
newattr(die, dwarf.DW_AT_encoding, dwarf.DW_CLS_CONSTANT, dwarf.DW_ATE_complex_float, 0)
594576
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
595577

596578
case objabi.KindArray:
597-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_ARRAYTYPE, name, 0)
598-
typedefdie = d.dotypedef(&dwtypes, gotype, name, die)
579+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_ARRAYTYPE, name)
580+
typedefdie = d.dotypedef(&dwtypes, name, die)
599581
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
600582
s := decodetypeArrayElem(d.ldr, d.arch, gotype)
601583
d.newrefattr(die, dwarf.DW_AT_type, d.defgotype(s))
602-
fld := d.newdie(die, dwarf.DW_ABRV_ARRAYRANGE, "range", 0)
584+
fld := d.newdie(die, dwarf.DW_ABRV_ARRAYRANGE, "range")
603585

604586
// use actual length not upper bound; correct for 0-length arrays.
605587
newattr(fld, dwarf.DW_AT_count, dwarf.DW_CLS_CONSTANT, decodetypeArrayLen(d.ldr, d.arch, gotype), 0)
606588

607589
d.newrefattr(fld, dwarf.DW_AT_type, d.uintptrInfoSym)
608590

609591
case objabi.KindChan:
610-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_CHANTYPE, name, 0)
592+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_CHANTYPE, name)
611593
s := decodetypeChanElem(d.ldr, d.arch, gotype)
612594
d.newrefattr(die, dwarf.DW_AT_go_elem, d.defgotype(s))
613595
// Save elem type for synthesizechantypes. We could synthesize here
614596
// but that would change the order of DIEs we output.
615597
d.newrefattr(die, dwarf.DW_AT_type, s)
616598

617599
case objabi.KindFunc:
618-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_FUNCTYPE, name, 0)
600+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_FUNCTYPE, name)
619601
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
620-
typedefdie = d.dotypedef(&dwtypes, gotype, name, die)
602+
typedefdie = d.dotypedef(&dwtypes, name, die)
621603
data := d.ldr.Data(gotype)
622604
// FIXME: add caching or reuse reloc slice.
623605
relocs := d.ldr.Relocs(gotype)
624606
nfields := decodetypeFuncInCount(d.arch, data)
625607
for i := 0; i < nfields; i++ {
626608
s := decodetypeFuncInType(d.ldr, d.arch, gotype, &relocs, i)
627609
sn := d.ldr.SymName(s)
628-
fld := d.newdie(die, dwarf.DW_ABRV_FUNCTYPEPARAM, sn[5:], 0)
610+
fld := d.newdie(die, dwarf.DW_ABRV_FUNCTYPEPARAM, sn[5:])
629611
d.newrefattr(fld, dwarf.DW_AT_type, d.defgotype(s))
630612
}
631613

632614
if decodetypeFuncDotdotdot(d.arch, data) {
633-
d.newdie(die, dwarf.DW_ABRV_DOTDOTDOT, "...", 0)
615+
d.newdie(die, dwarf.DW_ABRV_DOTDOTDOT, "...")
634616
}
635617
nfields = decodetypeFuncOutCount(d.arch, data)
636618
for i := 0; i < nfields; i++ {
637619
s := decodetypeFuncOutType(d.ldr, d.arch, gotype, &relocs, i)
638620
sn := d.ldr.SymName(s)
639-
fld := d.newdie(die, dwarf.DW_ABRV_FUNCTYPEPARAM, sn[5:], 0)
621+
fld := d.newdie(die, dwarf.DW_ABRV_FUNCTYPEPARAM, sn[5:])
640622
d.newrefattr(fld, dwarf.DW_AT_type, d.defptrto(d.defgotype(s)))
641623
}
642624

643625
case objabi.KindInterface:
644-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_IFACETYPE, name, 0)
645-
typedefdie = d.dotypedef(&dwtypes, gotype, name, die)
626+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_IFACETYPE, name)
627+
typedefdie = d.dotypedef(&dwtypes, name, die)
646628
data := d.ldr.Data(gotype)
647629
nfields := int(decodetypeIfaceMethodCount(d.arch, data))
648630
var s loader.Sym
@@ -654,7 +636,7 @@ func (d *dwctxt) newtype(gotype loader.Sym) *dwarf.DWDie {
654636
d.newrefattr(die, dwarf.DW_AT_type, d.defgotype(s))
655637

656638
case objabi.KindMap:
657-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_MAPTYPE, name, 0)
639+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_MAPTYPE, name)
658640
s := decodetypeMapKey(d.ldr, d.arch, gotype)
659641
d.newrefattr(die, dwarf.DW_AT_go_key, d.defgotype(s))
660642
s = decodetypeMapValue(d.ldr, d.arch, gotype)
@@ -664,26 +646,26 @@ func (d *dwctxt) newtype(gotype loader.Sym) *dwarf.DWDie {
664646
d.newrefattr(die, dwarf.DW_AT_type, gotype)
665647

666648
case objabi.KindPtr:
667-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_PTRTYPE, name, 0)
668-
typedefdie = d.dotypedef(&dwtypes, gotype, name, die)
649+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_PTRTYPE, name)
650+
typedefdie = d.dotypedef(&dwtypes, name, die)
669651
s := decodetypePtrElem(d.ldr, d.arch, gotype)
670652
d.newrefattr(die, dwarf.DW_AT_type, d.defgotype(s))
671653

672654
case objabi.KindSlice:
673-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_SLICETYPE, name, 0)
674-
typedefdie = d.dotypedef(&dwtypes, gotype, name, die)
655+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_SLICETYPE, name)
656+
typedefdie = d.dotypedef(&dwtypes, name, die)
675657
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
676658
s := decodetypeArrayElem(d.ldr, d.arch, gotype)
677659
elem := d.defgotype(s)
678660
d.newrefattr(die, dwarf.DW_AT_go_elem, elem)
679661

680662
case objabi.KindString:
681-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_STRINGTYPE, name, 0)
663+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_STRINGTYPE, name)
682664
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
683665

684666
case objabi.KindStruct:
685-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_STRUCTTYPE, name, 0)
686-
typedefdie = d.dotypedef(&dwtypes, gotype, name, die)
667+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_STRUCTTYPE, name)
668+
typedefdie = d.dotypedef(&dwtypes, name, die)
687669
newattr(die, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, bytesize, 0)
688670
nfields := decodetypeStructFieldCount(d.ldr, d.arch, gotype)
689671
for i := 0; i < nfields; i++ {
@@ -693,7 +675,7 @@ func (d *dwctxt) newtype(gotype loader.Sym) *dwarf.DWDie {
693675
sn := d.ldr.SymName(s)
694676
f = sn[5:] // skip "type."
695677
}
696-
fld := d.newdie(die, dwarf.DW_ABRV_STRUCTFIELD, f, 0)
678+
fld := d.newdie(die, dwarf.DW_ABRV_STRUCTFIELD, f)
697679
d.newrefattr(fld, dwarf.DW_AT_type, d.defgotype(s))
698680
offsetAnon := decodetypeStructFieldOffsAnon(d.ldr, d.arch, gotype, i)
699681
newmemberoffsetattr(fld, int32(offsetAnon>>1))
@@ -703,11 +685,11 @@ func (d *dwctxt) newtype(gotype loader.Sym) *dwarf.DWDie {
703685
}
704686

705687
case objabi.KindUnsafePointer:
706-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BARE_PTRTYPE, name, 0)
688+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_BARE_PTRTYPE, name)
707689

708690
default:
709691
d.linkctxt.Errorf(gotype, "dwarf: definition of unknown kind %d", kind)
710-
die = d.newdie(&dwtypes, dwarf.DW_ABRV_TYPEDECL, name, 0)
692+
die = d.newdie(&dwtypes, dwarf.DW_ABRV_TYPEDECL, name)
711693
d.newrefattr(die, dwarf.DW_AT_type, d.mustFind("<unspecified>"))
712694
}
713695

@@ -754,7 +736,7 @@ func (d *dwctxt) defptrto(dwtype loader.Sym) loader.Sym {
754736
return die
755737
}
756738

757-
pdie := d.newdie(&dwtypes, dwarf.DW_ABRV_PTRTYPE, ptrname, 0)
739+
pdie := d.newdie(&dwtypes, dwarf.DW_ABRV_PTRTYPE, ptrname)
758740
d.newrefattr(pdie, dwarf.DW_AT_type, dwtype)
759741

760742
// The DWARF info synthesizes pointer types that don't exist at the
@@ -782,7 +764,7 @@ func (d *dwctxt) copychildrenexcept(ctxt *Link, dst *dwarf.DWDie, src *dwarf.DWD
782764
if src == except {
783765
continue
784766
}
785-
c := d.newdie(dst, src.Abbrev, getattr(src, dwarf.DW_AT_name).Data.(string), 0)
767+
c := d.newdie(dst, src.Abbrev, getattr(src, dwarf.DW_AT_name).Data.(string))
786768
for a := src.Attr; a != nil; a = a.Link {
787769
newattr(c, a.Atr, int(a.Cls), a.Value, a.Data)
788770
}
@@ -877,7 +859,7 @@ func (d *dwctxt) mkinternaltype(ctxt *Link, abbrev int, typename, keyname, valna
877859
if s != 0 && d.ldr.SymType(s) == sym.SDWARFTYPE {
878860
return s
879861
}
880-
die := d.newdie(&dwtypes, abbrev, name, 0)
862+
die := d.newdie(&dwtypes, abbrev, name)
881863
f(die)
882864
return d.dtolsym(die.Sym)
883865
}
@@ -922,7 +904,7 @@ func (d *dwctxt) synthesizemaptypes(ctxt *Link, die *dwarf.DWDie) {
922904
t = d.defptrto(keytype)
923905
}
924906
d.newrefattr(dwhk, dwarf.DW_AT_type, t)
925-
fld := d.newdie(dwhk, dwarf.DW_ABRV_ARRAYRANGE, "size", 0)
907+
fld := d.newdie(dwhk, dwarf.DW_ABRV_ARRAYRANGE, "size")
926908
newattr(fld, dwarf.DW_AT_count, dwarf.DW_CLS_CONSTANT, BucketSize, 0)
927909
d.newrefattr(fld, dwarf.DW_AT_type, d.uintptrInfoSym)
928910
})
@@ -936,7 +918,7 @@ func (d *dwctxt) synthesizemaptypes(ctxt *Link, die *dwarf.DWDie) {
936918
t = d.defptrto(valtype)
937919
}
938920
d.newrefattr(dwhv, dwarf.DW_AT_type, t)
939-
fld := d.newdie(dwhv, dwarf.DW_ABRV_ARRAYRANGE, "size", 0)
921+
fld := d.newdie(dwhv, dwarf.DW_ABRV_ARRAYRANGE, "size")
940922
newattr(fld, dwarf.DW_AT_count, dwarf.DW_CLS_CONSTANT, BucketSize, 0)
941923
d.newrefattr(fld, dwarf.DW_AT_type, d.uintptrInfoSym)
942924
})
@@ -947,17 +929,17 @@ func (d *dwctxt) synthesizemaptypes(ctxt *Link, die *dwarf.DWDie) {
947929
// bucket. "data" will be replaced with keys/values below.
948930
d.copychildrenexcept(ctxt, dwhb, bucket, findchild(bucket, "data"))
949931

950-
fld := d.newdie(dwhb, dwarf.DW_ABRV_STRUCTFIELD, "keys", 0)
932+
fld := d.newdie(dwhb, dwarf.DW_ABRV_STRUCTFIELD, "keys")
951933
d.newrefattr(fld, dwarf.DW_AT_type, dwhks)
952934
newmemberoffsetattr(fld, BucketSize)
953-
fld = d.newdie(dwhb, dwarf.DW_ABRV_STRUCTFIELD, "values", 0)
935+
fld = d.newdie(dwhb, dwarf.DW_ABRV_STRUCTFIELD, "values")
954936
d.newrefattr(fld, dwarf.DW_AT_type, dwhvs)
955937
newmemberoffsetattr(fld, BucketSize+BucketSize*int32(keysize))
956-
fld = d.newdie(dwhb, dwarf.DW_ABRV_STRUCTFIELD, "overflow", 0)
938+
fld = d.newdie(dwhb, dwarf.DW_ABRV_STRUCTFIELD, "overflow")
957939
d.newrefattr(fld, dwarf.DW_AT_type, d.defptrto(d.dtolsym(dwhb.Sym)))
958940
newmemberoffsetattr(fld, BucketSize+BucketSize*(int32(keysize)+int32(valsize)))
959941
if d.arch.RegSize > d.arch.PtrSize {
960-
fld = d.newdie(dwhb, dwarf.DW_ABRV_STRUCTFIELD, "pad", 0)
942+
fld = d.newdie(dwhb, dwarf.DW_ABRV_STRUCTFIELD, "pad")
961943
d.newrefattr(fld, dwarf.DW_AT_type, d.uintptrInfoSym)
962944
newmemberoffsetattr(fld, BucketSize+BucketSize*(int32(keysize)+int32(valsize))+int32(d.arch.PtrSize))
963945
}
@@ -1672,7 +1654,7 @@ func dwarfEnabled(ctxt *Link) bool {
16721654
// newly created builtin type DIE 'typeDie'.
16731655
func (d *dwctxt) mkBuiltinType(ctxt *Link, abrv int, tname string) *dwarf.DWDie {
16741656
// create type DIE
1675-
die := d.newdie(&dwtypes, abrv, tname, 0)
1657+
die := d.newdie(&dwtypes, abrv, tname)
16761658

16771659
// Look up type symbol.
16781660
gotype := d.lookupOrDiag("type." + tname)
@@ -1765,7 +1747,16 @@ func dwarfGenerateDebugInfo(ctxt *Link) {
17651747
return
17661748
}
17671749

1768-
d := newdwctxt(ctxt, true)
1750+
d := &dwctxt{
1751+
linkctxt: ctxt,
1752+
ldr: ctxt.loader,
1753+
arch: ctxt.Arch,
1754+
tmap: make(map[string]loader.Sym),
1755+
tdmap: make(map[loader.Sym]loader.Sym),
1756+
rtmap: make(map[loader.Sym]loader.Sym),
1757+
}
1758+
d.typeRuntimeEface = d.lookupOrDiag("type.runtime.eface")
1759+
d.typeRuntimeIface = d.lookupOrDiag("type.runtime.iface")
17691760

17701761
if ctxt.HeadType == objabi.Haix {
17711762
// Initial map used to store package size for each DWARF section.
@@ -1776,7 +1767,7 @@ func dwarfGenerateDebugInfo(ctxt *Link) {
17761767
newattr(&dwtypes, dwarf.DW_AT_name, dwarf.DW_CLS_STRING, int64(len("dwtypes")), "dwtypes")
17771768

17781769
// Unspecified type. There are no references to this in the symbol table.
1779-
d.newdie(&dwtypes, dwarf.DW_ABRV_NULLTYPE, "<unspecified>", 0)
1770+
d.newdie(&dwtypes, dwarf.DW_ABRV_NULLTYPE, "<unspecified>")
17801771

17811772
// Some types that must exist to define other ones (uintptr in particular
17821773
// is needed for array size)
@@ -1841,7 +1832,7 @@ func dwarfGenerateDebugInfo(ctxt *Link) {
18411832
if len(unit.Textp) == 0 {
18421833
cuabrv = dwarf.DW_ABRV_COMPUNIT_TEXTLESS
18431834
}
1844-
unit.DWInfo = d.newdie(&dwroot, cuabrv, unit.Lib.Pkg, 0)
1835+
unit.DWInfo = d.newdie(&dwroot, cuabrv, unit.Lib.Pkg)
18451836
newattr(unit.DWInfo, dwarf.DW_AT_language, dwarf.DW_CLS_CONSTANT, int64(dwarf.DW_LANG_Go), 0)
18461837
// OS X linker requires compilation dir or absolute path in comp unit name to output debug info.
18471838
compDir := getCompilationDir()

0 commit comments

Comments
 (0)