}
// writepcranges generates the DW_AT_ranges table for compilation unit cu.
-func writepcranges(ctxt *Link, cu *dwarf.DWDie, base *sym.Symbol, pcs []dwarf.Range, ranges *sym.Symbol) {
+func writepcranges(ctxt *Link, unit *compilationUnit, base *sym.Symbol, pcs []dwarf.Range, ranges *sym.Symbol) {
var dwarfctxt dwarf.Context = dwctxt{ctxt}
+ unitLengthOffset := ranges.Size
+
// Create PC ranges for this CU.
- newattr(cu, dwarf.DW_AT_ranges, dwarf.DW_CLS_PTR, ranges.Size, ranges)
- newattr(cu, dwarf.DW_AT_low_pc, dwarf.DW_CLS_ADDRESS, base.Value, base)
+ newattr(unit.dwinfo, dwarf.DW_AT_ranges, dwarf.DW_CLS_PTR, ranges.Size, ranges)
+ newattr(unit.dwinfo, dwarf.DW_AT_low_pc, dwarf.DW_CLS_ADDRESS, base.Value, base)
dwarf.PutRanges(dwarfctxt, ranges, nil, pcs)
+
+ if ctxt.HeadType == objabi.Haix {
+ addDwsectCUSize(".debug_ranges", unit.lib.String(), uint64(ranges.Size-unitLengthOffset))
+ }
+
}
/*
fs.AddAddr(ctxt.Arch, s)
fs.AddUintXX(ctxt.Arch, uint64(s.Size), ctxt.Arch.PtrSize) // address range
fs.AddBytes(deltaBuf)
+
+ if ctxt.HeadType == objabi.Haix {
+ addDwsectCUSize(".debug_frame", s.File, fdeLength+uint64(lengthFieldSize))
+ }
}
return syms
}
}
if ctxt.LinkMode == LinkExternal {
- // TODO(aix): enable DWARF
switch {
case ctxt.IsELF:
case ctxt.HeadType == objabi.Hdarwin:
case ctxt.HeadType == objabi.Hwindows:
+ case ctxt.HeadType == objabi.Haix:
default:
return false
}
return
}
+ if ctxt.HeadType == objabi.Haix {
+ // Initial map used to store package size for each DWARF section.
+ dwsectCUSize = make(map[string]uint64)
+ }
+
ctxt.compUnitByPackage = make(map[*sym.Library]*compilationUnit)
// Forctxt.Diagnostic messages.
if ctxt.HeadType == objabi.Hdarwin {
removeDwarfAddrListBaseAddress(ctxt, dsym, rangeSym, false)
}
+ if ctxt.HeadType == objabi.Haix {
+ addDwsectCUSize(".debug_ranges", unit.lib.String(), uint64(rangeSym.Size))
+
+ }
unit.rangeSyms = append(unit.rangeSyms, rangeSym)
}
continue
}
writelines(ctxt, u, debugLine)
- writepcranges(ctxt, u.dwinfo, u.lib.Textp[0], u.pcs, debugRanges)
+ writepcranges(ctxt, u, u.lib.Textp[0], u.pcs, debugRanges)
}
// newdie adds DIEs to the *beginning* of the parent's DIE list.
dwsectCUSize[sname+"."+pkgname] = size
}
+func addDwsectCUSize(sname string, pkgname string, size uint64) {
+ dwsectCUSize[sname+"."+pkgname] += size
+}
+
// getPkgFromCUSym returns the package name for the compilation unit
// represented by s.
// The prefix dwarf.InfoPrefix+".pkg." needs to be removed in order to get
case ".debug_pubtypes":
return ".dwpbtyp", SSUBTYP_DWPBTYP
case ".debug_ranges":
- return ".dwrnge", SSUBTYP_DWRNGES
+ return ".dwrnges", SSUBTYP_DWRNGES
}
// never used
return "", 0
/* Dwarf */
for _, sect := range Segdwarf.Sections {
- // Find the size of this corresponding package DWARF compilation unit.
- // This size is set during DWARF generation (see dwarf.go).
- dwsize := getDwsectCUSize(sect.Name, name)
- // .debug_abbrev is commun to all packages and not found with the previous function
- if sect.Name == ".debug_abbrev" {
- s := ctxt.Syms.Lookup(sect.Name, 0)
- dwsize = uint64(s.Size)
+ var dwsize uint64
+ if ctxt.LinkMode == LinkInternal {
+ // Find the size of this corresponding package DWARF compilation unit.
+ // This size is set during DWARF generation (see dwarf.go).
+ dwsize = getDwsectCUSize(sect.Name, name)
+ // .debug_abbrev is commun to all packages and not found with the previous function
+ if sect.Name == ".debug_abbrev" {
+ s := ctxt.Syms.ROLookup(sect.Name, 0)
+ dwsize = uint64(s.Size)
+
+ }
+ } else {
+ // There is only one .FILE with external linking.
+ dwsize = sect.Length
}
// get XCOFF name
Nscnum: f.getXCOFFscnum(sect),
Nnumaux: 1,
}
+
+ if currSymSrcFile.csectAux == nil {
+ // Dwarf relocations need the symbol number of .dw* symbols.
+ // It doesn't need to know it for each package, one is enough.
+ // currSymSrcFile.csectAux == nil means first package.
+ dws := ctxt.Syms.Lookup(sect.Name, 0)
+ dws.Dynid = int32(f.symbolCount)
+
+ if sect.Name == ".debug_frame" && ctxt.LinkMode != LinkExternal {
+ // CIE size must be added to the first package.
+ dwsize += 48
+ }
+ }
+
f.addSymbol(s)
// update the DWARF section offset in this file
} else {
// Current file has changed. New C_FILE, C_DWARF, etc must be generated.
if currSymSrcFile.name != x.File {
- // update previous file values
- xfile.updatePreviousFile(ctxt, false)
- currSymSrcFile.name = x.File
- f.writeSymbolNewFile(ctxt, x.File, uint64(x.Value), xfile.getXCOFFscnum(x.Sect))
+ if ctxt.LinkMode == LinkInternal {
+ // update previous file values
+ xfile.updatePreviousFile(ctxt, false)
+ currSymSrcFile.name = x.File
+ f.writeSymbolNewFile(ctxt, x.File, uint64(x.Value), xfile.getXCOFFscnum(x.Sect))
+ } else {
+ // With external linking, ld will crash if there is several
+ // .FILE and DWARF debugging enable, somewhere during
+ // the relocation phase.
+ // Therefore, all packages are merged under a fake .FILE
+ // "go_functions".
+ // TODO(aix); remove once ld has been fixed or the triggering
+ // relocation has been found and fixed.
+ if currSymSrcFile.name == "" {
+ currSymSrcFile.name = x.File
+ f.writeSymbolNewFile(ctxt, "go_functions", uint64(x.Value), xfile.getXCOFFscnum(x.Sect))
+ }
+ }
+
}
}
Exitf("-d is not available on AIX")
}
- // Initial map used to store compilation unit size for each DWARF section (see dwarf.go).
- dwsectCUSize = make(map[string]uint64)
-
// TOC
toc := ctxt.Syms.Lookup("TOC", 0)
toc.Type = sym.SXCOFFTOC
s.xcoffSect.Snreloc += n
}
- // TODO(aix): DWARF relocations
+dwarfLoop:
+ for _, sect := range Segdwarf.Sections {
+ for _, xcoffSect := range f.sections {
+ _, subtyp := xcoffGetDwarfSubtype(sect.Name)
+ if xcoffSect.Sflags&0xF0000 == subtyp {
+ xcoffSect.Srelptr = uint64(ctxt.Out.Offset())
+ xcoffSect.Snreloc = relocsect(sect, dwarfp, sect.Vaddr)
+ continue dwarfLoop
+ }
+ }
+ Errorf(nil, "emitRelocations: could not find %q section", sect.Name)
+ }
}
// xcoffCreateExportFile creates a file with exported symbols for