Commit 130ad87a authored by Ian Lance Taylor's avatar Ian Lance Taylor

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: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 9e0f3a14
......@@ -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)
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment