From 188e995ae9de004322d3f822f70dc9d814e2c03b Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Mon, 15 Jun 2020 15:16:51 -0400 Subject: [PATCH] [dev.link] cmd/link: reduce alignment requirement for symtab/elfstr 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 Reviewed-by: Cherry Zhang --- src/cmd/link/internal/ld/elf.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmd/link/internal/ld/elf.go b/src/cmd/link/internal/ld/elf.go index b100d07e6f..f5a57cb96e 100644 --- a/src/cmd/link/internal/ld/elf.go +++ b/src/cmd/link/internal/ld/elf.go @@ -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) -- 2.48.1