cmd/link: consider alignment in carrier symbol size calculation

Currently, when we calculate the size of a carrier symbol, we use
the previous symbol's end address as the start. But the symbol
actually starts after applying the alignment. Do this in the
size calculation.

Should fix AIX build.

Updates #53372.

Change-Id: I17942b1fe8027dce12b78c8e8c80ea6cebcee240
Reviewed-on: https://go-review.googlesource.com/c/go/+/412734
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Cherry Mui 2022-06-16 11:35:40 -04:00
parent bcce8ef498
commit 1d9d99b7ce

View file

@ -1854,6 +1854,9 @@ func (state *dodataState) allocateDataSections(ctxt *Link) {
}
for _, symn := range sym.ReadOnly {
symnStartValue := state.datsize
if len(state.data[symn]) != 0 {
symnStartValue = aligndatsize(state, symnStartValue, state.data[symn][0])
}
state.assignToSection(sect, symn, sym.SRODATA)
setCarrierSize(symn, state.datsize-symnStartValue)
if ctxt.HeadType == objabi.Haix {
@ -1935,6 +1938,9 @@ func (state *dodataState) allocateDataSections(ctxt *Link) {
symn := sym.RelROMap[symnro]
symnStartValue := state.datsize
if len(state.data[symn]) != 0 {
symnStartValue = aligndatsize(state, symnStartValue, state.data[symn][0])
}
for _, s := range state.data[symn] {
outer := ldr.OuterSym(s)