]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: consider alignment in carrier symbol size calculation
authorCherry Mui <cherryyz@google.com>
Thu, 16 Jun 2022 15:35:40 +0000 (11:35 -0400)
committerCherry Mui <cherryyz@google.com>
Thu, 16 Jun 2022 16:27:17 +0000 (16:27 +0000)
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>
src/cmd/link/internal/ld/data.go

index f12cb78fb8ecaa9a3d199df09dc8bb32b94a8231..cb2afeaa9ac5c8429c93400d85bb086ed361b695 100644 (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)