]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: reduce alignment requirement for symtab/elfstr
authorThan McIntosh <thanm@google.com>
Mon, 15 Jun 2020 19:16:51 +0000 (15:16 -0400)
committerThan McIntosh <thanm@google.com>
Wed, 17 Jun 2020 11:15:12 +0000 (11:15 +0000)
The linker's asmb phase for ELF has a chunk of code that decides where
to place the .symtab and .strtab sections, which appear after after
the DWARF data; this code currently tries to align the start of the
.symtab section using the value of -R (stored in *FlagRound). This
patch gets rid of this additional alignment and instead just aligns
.symtab by pointer size. The -R value is needed for loadable
segments/sections (such as text or data), not for non-loadable
sections (e.g. symtab). On most architectures the *FlagRound value is
4k, however on ARM64 it is 64k, meaning that aligning symtab on this
boundary can waste a good chunk of space.

Change-Id: Ib51f3ad5611f5614768355eb8533084ba117a8e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/238019
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/link/internal/ld/elf.go

index b100d07e6f7356a9f2e637b95be97f633a1a4bc3..f5a57cb96e1a5f01a93e45a1eb0edf55d78b98af 100644 (file)
@@ -1783,7 +1783,7 @@ func asmbElf(ctxt *Link) {
        var symo int64
        if !*FlagS {
                symo = int64(Segdwarf.Fileoff + Segdwarf.Filelen)
-               symo = Rnd(symo, int64(*FlagRound))
+               symo = Rnd(symo, int64(ctxt.Arch.PtrSize))
                ctxt.Out.SeekSet(symo)
                asmElfSym(ctxt)
                ctxt.Out.Write(Elfstrdat)