mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/link: align sections, not symbols after DWARF compress
After DWARF compression, we recompute the symbol and section addresses. On Windows, we need to align the sections to PEFILEALIGN. But the code actually apply the alignment to every symbol. This works mostly fine as after compression a section usually contains a single symbol (the compressed data). But if the compression is not beneficial, it leaves with the original set of symbols, which could be more than one. Applying alignment to every symbol causing the section size too big, no longer matching the size we computed before compression. Fixes #76022. Change-Id: I2246045955405997c77e54001bbb83f9ccd1ee7c Reviewed-on: https://go-review.googlesource.com/c/go/+/721340 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
c93766007d
commit
8806d53c10
1 changed files with 4 additions and 4 deletions
|
|
@ -2507,19 +2507,19 @@ func dwarfcompress(ctxt *Link) {
|
||||||
var prevSect *sym.Section
|
var prevSect *sym.Section
|
||||||
for _, si := range dwarfp {
|
for _, si := range dwarfp {
|
||||||
for _, s := range si.syms {
|
for _, s := range si.syms {
|
||||||
ldr.SetSymValue(s, int64(pos))
|
|
||||||
sect := ldr.SymSect(s)
|
sect := ldr.SymSect(s)
|
||||||
if sect != prevSect {
|
if sect != prevSect {
|
||||||
|
if ctxt.IsWindows() {
|
||||||
|
pos = uint64(Rnd(int64(pos), PEFILEALIGN))
|
||||||
|
}
|
||||||
sect.Vaddr = pos
|
sect.Vaddr = pos
|
||||||
prevSect = sect
|
prevSect = sect
|
||||||
}
|
}
|
||||||
|
ldr.SetSymValue(s, int64(pos))
|
||||||
if ldr.SubSym(s) != 0 {
|
if ldr.SubSym(s) != 0 {
|
||||||
log.Fatalf("%s: unexpected sub-symbols", ldr.SymName(s))
|
log.Fatalf("%s: unexpected sub-symbols", ldr.SymName(s))
|
||||||
}
|
}
|
||||||
pos += uint64(ldr.SymSize(s))
|
pos += uint64(ldr.SymSize(s))
|
||||||
if ctxt.IsWindows() {
|
|
||||||
pos = uint64(Rnd(int64(pos), PEFILEALIGN))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Segdwarf.Length = pos - Segdwarf.Vaddr
|
Segdwarf.Length = pos - Segdwarf.Vaddr
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue