Skip to content

Commit b9d6cea

Browse files
mengzhuocherrymui
authored andcommitted
cmd/link: set alignment of compressed section based on arch
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 <[email protected]> Reviewed-by: Alessandro Arzilli <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Run-TryBot: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Fangrui Song <[email protected]>
1 parent b810a74 commit b9d6cea

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cmd/link/internal/ld/dwarf.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2234,7 +2234,7 @@ func dwarfcompress(ctxt *Link) {
22342234
compressedSegName = ".zdebug_" + ldr.SymSect(s).Name[len(".debug_"):]
22352235
}
22362236
sect := addsection(ctxt.loader, ctxt.Arch, &Segdwarf, compressedSegName, 04)
2237-
sect.Align = 1
2237+
sect.Align = int32(ctxt.Arch.Alignment)
22382238
sect.Length = uint64(len(z.compressed))
22392239
sect.Compressed = true
22402240
newSym := ldr.MakeSymbolBuilder(compressedSegName)

0 commit comments

Comments
 (0)