mirror of
https://github.com/golang/go
synced 2024-11-23 16:50:06 -07:00
cmd/link: don't overalign ELF reloc sections
Internal linking on an ELF system creates two reloc sections, which must be adjacent. The default is to base section alignment on the section size, but doing that for ELF reloc sections can introduce a gap. Set the reloc section alignment explicitly to avoid that. Fixes #18044. Change-Id: I8ccc131e60937d30c5f715a34c7803258833fc2f Reviewed-on: https://go-review.googlesource.com/33872 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
9e0f3a1459
commit
130ad87ab7
@ -3718,3 +3718,12 @@ func TestLinkXImportPathEscape(t *testing.T) {
|
||||
tg.t.Fatal(`incorrect output: expected "linkXworked\n"`)
|
||||
}
|
||||
}
|
||||
|
||||
// Issue 18044.
|
||||
func TestLdBindNow(t *testing.T) {
|
||||
tg := testgo(t)
|
||||
defer tg.cleanup()
|
||||
tg.parallel()
|
||||
tg.setenv("LD_BIND_NOW", "1")
|
||||
tg.run("help")
|
||||
}
|
||||
|
@ -1976,6 +1976,13 @@ func dodataSect(ctxt *Link, symn obj.SymKind, syms []*Symbol) (result []*Symbol,
|
||||
copy(syms[first+2:], syms[first+1:second])
|
||||
syms[first+0] = rel
|
||||
syms[first+1] = plt
|
||||
|
||||
// Make sure alignment doesn't introduce a gap.
|
||||
// Setting the alignment explicitly prevents
|
||||
// symalign from basing it on the size and
|
||||
// getting it wrong.
|
||||
rel.Align = int32(SysArch.RegSize)
|
||||
plt.Align = int32(SysArch.RegSize)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user