Skip to content

Commit b0441a6

Browse files
committed
cmd/release: update checkRelocations for Go 1.16
The plan in https://golang.org/issue/40561#issuecomment-731482962 involved updating the linux-amd64 target from Debian Jessie to Debian Stretch, which in turn comes with a newer version of GCC. checkRelocations was added in CL 171317 in response to a bad minor release that was accidentally issued without the intended fix, and needs to be updated for Go 1.16 and newer releases. It's not clear if we want to maintain it indefinitely for future Go versions, but keep it for a bit longer. Add a note to make it clear that it can be removed as needed in the future. For golang/go#40561. Updates golang/go#31293. Change-Id: I2da419eff6379575eb2648787f0dac6bba07b304 Reviewed-on: https://go-review.googlesource.com/c/build/+/278357 Trust: Dmitri Shuralyov <[email protected]> Run-TryBot: Dmitri Shuralyov <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Alexander Rakoczy <[email protected]> Reviewed-by: Carlos Amedee <[email protected]>
1 parent 9ad13ba commit b0441a6

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

cmd/release/release.go

+21-6
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,8 @@ func (b *Build) writeFile(name string, r io.Reader) error {
857857
}
858858

859859
// checkRelocations runs readelf on pkg/linux_amd64/runtime/cgo.a and makes sure
860-
// we don't see R_X86_64_REX_GOTPCRELX. See golang.org/issue/31293.
860+
// we don't see R_X86_64_REX_GOTPCRELX in new Go 1.15 and Go 1.14 minor releases.
861+
// See golang.org/issue/31293 and golang.org/issue/40561#issuecomment-731482962.
861862
func (b *Build) checkRelocations(client *buildlet.Client) error {
862863
if b.OS != "linux" || b.Arch != "amd64" || b.TestOnly {
863864
// This check is only applicable to linux/amd64 builds.
@@ -876,11 +877,25 @@ func (b *Build) checkRelocations(client *buildlet.Client) error {
876877
return fmt.Errorf("failed to run readelf: %v", err)
877878
}
878879
got := out.String()
879-
if strings.Contains(got, "R_X86_64_REX_GOTPCRELX") {
880-
return fmt.Errorf("%s contained a R_X86_64_REX_GOTPCRELX relocation", file)
881-
}
882-
if !strings.Contains(got, "R_X86_64_GOTPCREL") {
883-
return fmt.Errorf("%s did not contain a R_X86_64_GOTPCREL relocation; remoteErr=%v, %s", file, remoteErr, got)
880+
switch {
881+
default: // Go 1.16 and newer.
882+
// Note: This check was kept and updated for Go 1.16, since it wasn't hard.
883+
// Remove it at some point in the future if it becomes no longer useful or
884+
// overly expensive to maintain.
885+
if strings.Contains(got, "R_X86_64_GOTPCREL") {
886+
return fmt.Errorf("%s contained a R_X86_64_GOTPCREL relocation", file)
887+
}
888+
if !strings.Contains(got, "R_X86_64_REX_GOTPCRELX") {
889+
return fmt.Errorf("%s did not contain a R_X86_64_REX_GOTPCRELX relocation; remoteErr=%v, %s", file, remoteErr, got)
890+
}
891+
case strings.HasPrefix(*version, "go1.15"),
892+
strings.HasPrefix(*version, "go1.14"):
893+
if strings.Contains(got, "R_X86_64_REX_GOTPCRELX") {
894+
return fmt.Errorf("%s contained a R_X86_64_REX_GOTPCRELX relocation", file)
895+
}
896+
if !strings.Contains(got, "R_X86_64_GOTPCREL") {
897+
return fmt.Errorf("%s did not contain a R_X86_64_GOTPCREL relocation; remoteErr=%v, %s", file, remoteErr, got)
898+
}
884899
}
885900
return nil
886901
}

0 commit comments

Comments
 (0)