mirror of
https://github.com/golang/go
synced 2024-11-14 19:50:21 -07:00
cmd/link/internal/ld: more fixes to TestElfBindNow readonly .got check
Second try at fixing the TestElfBindNow testpoint: don't try to check for readonly ".got" section when using the external linker, since there is code in some linkers (BFD in particular) that will skip placing ".got" in relro if the section is below a specific size threshold. Revised version of the test checks only for readonly ".dynamic" in the external linking case. Fixes #67063. Change-Id: Idb6b82ec7893baddf171654775587f6050fc6258 Reviewed-on: https://go-review.googlesource.com/c/go/+/581995 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: abner chenc <chenguoqi@loongson.cn> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
2dd82d97b6
commit
deeebf5655
@ -194,12 +194,18 @@ func TestElfBindNow(t *testing.T) {
|
||||
progC = `package main; import "C"; func main() {}`
|
||||
)
|
||||
|
||||
// Note: for linux/amd64 and linux/arm64, for relro we'll always see
|
||||
// a .got section when building with -buildmode=pie (in addition
|
||||
// to .dynamic); for some other less mainstream archs (ppc64le,
|
||||
// s390) this is not the case (on ppc64le for example we only see
|
||||
// got refs from C objects). Hence we put ".dynamic" in the 'want RO'
|
||||
// list below and ".got" in the 'want RO if present".
|
||||
// Notes:
|
||||
// - for linux/amd64 and linux/arm64, for relro we'll always see a
|
||||
// .got section when building with -buildmode=pie (in addition
|
||||
// to .dynamic); for some other less mainstream archs (ppc64le,
|
||||
// s390) this is not the case (on ppc64le for example we only
|
||||
// see got refs from C objects). Hence we put ".dynamic" in the
|
||||
// 'want RO' list below and ".got" in the 'want RO if present".
|
||||
// - when using the external linker, checking for read-only ".got"
|
||||
// is problematic since some linkers will only make the .got
|
||||
// read-only if its size is above a specific threshold, e.g.
|
||||
// https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=ld/scripttempl/elf.sc;h=d5022fa502f24db23f396f337a6c8978fbc8415b;hb=6fde04116b4b835fa9ec3b3497fcac4e4a0637e2#l74 . For this reason, don't try to verify read-only .got
|
||||
// in the external linking case.
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -256,8 +262,6 @@ func TestElfBindNow(t *testing.T) {
|
||||
wantDf1Now: true,
|
||||
wantDf1Pie: true,
|
||||
wantSecsRO: []string{".dynamic"},
|
||||
// NB: external linker produces .plt.got, not .got.plt
|
||||
wantSecsROIfPresent: []string{".got", ".got.plt"},
|
||||
},
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user