]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: set alignment of compressed section based on arch
authorMeng Zhuo <mzh@golangcn.org>
Fri, 18 Mar 2022 09:36:52 +0000 (17:36 +0800)
committerCherry Mui <cherryyz@google.com>
Mon, 21 Mar 2022 18:29:06 +0000 (18:29 +0000)
The ELF compression header(Chdr) has Addralign field that is set to the
alignment of the uncompressed section which makes section able to have
a different alignment than the decompressed section. However `file` and
other tools require both Chdr.Addralign and Addralign to be equal.

Ref https://sourceware.org/bugzilla/show_bug.cgi?id=23919
Related #42136

Fixes #51769

Change-Id: I3cf99dbd2359932576420a3c0d342c7e91b99227
Reviewed-on: https://go-review.googlesource.com/c/go/+/393916
Trust: mzh <mzh@golangcn.org>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Fangrui Song <maskray@google.com>
src/cmd/link/internal/ld/dwarf.go

index 289ebcb59580e66c8356ad34f8d19b784eb1c3d1..2e209d0c6b7dfa090103122cf205630ac6a047ab 100644 (file)
@@ -2234,7 +2234,7 @@ func dwarfcompress(ctxt *Link) {
                                compressedSegName = ".zdebug_" + ldr.SymSect(s).Name[len(".debug_"):]
                        }
                        sect := addsection(ctxt.loader, ctxt.Arch, &Segdwarf, compressedSegName, 04)
-                       sect.Align = 1
+                       sect.Align = int32(ctxt.Arch.Alignment)
                        sect.Length = uint64(len(z.compressed))
                        sect.Compressed = true
                        newSym := ldr.MakeSymbolBuilder(compressedSegName)