aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2024-04-26 13:10:36 +0000
committerThan McIntosh <thanm@google.com>2024-04-26 15:38:14 +0000
commitdeeebf5655eeb91e93e60dbda5c3df294b4d5130 (patch)
tree71c45ea959785796234ab3d45195c02898649a1c
parent2dd82d97b67a538700e30d808122a521e3207c3e (diff)
downloadgo-deeebf5655eeb91e93e60dbda5c3df294b4d5130.tar.gz
go-deeebf5655eeb91e93e60dbda5c3df294b4d5130.zip
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>
-rw-r--r--src/cmd/link/internal/ld/elf_test.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/cmd/link/internal/ld/elf_test.go b/src/cmd/link/internal/ld/elf_test.go
index 46af7625f3..843b067e19 100644
--- a/src/cmd/link/internal/ld/elf_test.go
+++ b/src/cmd/link/internal/ld/elf_test.go
@@ -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"},
},
}