}
datsize = Rnd(datsize, int64(sect.Align))
for _, symn := range sym.ReadOnly {
+ symnStartValue := datsize
for _, s := range data[symn] {
datsize = aligndatsize(datsize, s)
s.Sect = sect
datsize += s.Size
}
checkdatsize(ctxt, datsize, symn)
+ if ctxt.HeadType == objabi.Haix {
+ // Read-only symbols might be wrapped inside their outer
+ // symbol.
+ // XCOFF symbol table needs to know the size of
+ // these outer symbols.
+ xcoffUpdateOuterSize(ctxt, datsize-symnStartValue, symn)
+ }
}
sect.Length = uint64(datsize) - sect.Vaddr
datsize = Rnd(datsize, int64(sect.Align))
for _, symnro := range sym.ReadOnly {
symn := sym.RelROMap[symnro]
+ symnStartValue := datsize
for _, s := range data[symn] {
datsize = aligndatsize(datsize, s)
if s.Outer != nil && s.Outer.Sect != nil && s.Outer.Sect != sect {
datsize += s.Size
}
checkdatsize(ctxt, datsize, symn)
+ if ctxt.HeadType == objabi.Haix {
+ // Read-only symbols might be wrapped inside their outer
+ // symbol.
+ // XCOFF symbol table needs to know the size of
+ // these outer symbols.
+ xcoffUpdateOuterSize(ctxt, datsize-symnStartValue, symn)
+ }
}
sect.Length = uint64(datsize) - sect.Vaddr
}
checkdatsize(ctxt, datsize, sym.SITABLINK)
sect.Length = uint64(datsize) - sect.Vaddr
+ if ctxt.HeadType == objabi.Haix {
+ // Store .itablink size because its symbols are wrapped
+ // under an outer symbol: runtime.itablink.
+ xcoffUpdateOuterSize(ctxt, int64(sect.Length), sym.SITABLINK)
+ }
/* gosymtab */
sect = addrelrosection(".gosymtab")
var (
currDwscnoff = make(map[string]uint64) // Needed to create C_DWARF symbols
currSymSrcFile xcoffSymSrcFile
+ outerSymSize = make(map[string]int64)
)
+// xcoffUpdateOuterSize stores the size of outer symbols in order to have it
+// in the symbol table.
+func xcoffUpdateOuterSize(ctxt *Link, size int64, stype sym.SymKind) {
+ if size == 0 {
+ return
+ }
+
+ switch stype {
+ default:
+ Errorf(nil, "unknown XCOFF outer symbol for type %s", stype.String())
+ case sym.SRODATA, sym.SRODATARELRO, sym.SFUNCTAB, sym.SSTRING:
+ // Nothing to do
+ case sym.STYPERELRO:
+ if ctxt.UseRelro() && (ctxt.BuildMode == BuildModeCArchive || ctxt.BuildMode == BuildModeCShared || ctxt.BuildMode == BuildModePIE) {
+ outerSymSize["typerel.*"] = size
+ return
+ }
+ fallthrough
+ case sym.STYPE:
+ if !ctxt.DynlinkingGo() {
+ outerSymSize["type.*"] = size
+ }
+ case sym.SGOSTRING:
+ outerSymSize["go.string.*"] = size
+ case sym.SGOFUNC:
+ if !ctxt.DynlinkingGo() {
+ outerSymSize["go.func.*"] = size
+ }
+ case sym.SGOFUNCRELRO:
+ outerSymSize["go.funcrel.*"] = size
+ case sym.SGCBITS:
+ outerSymSize["runtime.gcbits.*"] = size
+ case sym.SITABLINK:
+ outerSymSize["runtime.itablink"] = size
+
+ }
+
+}
+
// addSymbol writes a symbol or an auxiliary symbol entry on ctxt.out.
func (f *xcoffFile) addSymbol(sym xcoffSym) {
f.symtabSym = append(f.symtabSym, sym)
// It will be written in out file in Asmbxcoff, because it must be
// at the very end, especially after relocation sections which needs symbols' index.
func (f *xcoffFile) asmaixsym(ctxt *Link) {
+ // Get correct size for symbols wrapping others symbols like go.string.*
+ // sym.Size can be used directly as the symbols have already been written.
+ for name, size := range outerSymSize {
+ sym := ctxt.Syms.ROLookup(name, 0)
+ if sym == nil {
+ Errorf(nil, "unknown outer symbol with name %s", name)
+ } else {
+ sym.Size = size
+ }
+ }
+
genasmsym(ctxt, putaixsym)
xfile.updatePreviousFile(ctxt, true)
}