Skip to content

Commit

Permalink
cmd/release: update checkRelocations for Go 1.16
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dmitshur committed Dec 15, 2020
1 parent 9ad13ba commit b0441a6
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions cmd/release/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,8 @@ func (b *Build) writeFile(name string, r io.Reader) error {
}

// checkRelocations runs readelf on pkg/linux_amd64/runtime/cgo.a and makes sure
// we don't see R_X86_64_REX_GOTPCRELX. See golang.org/issue/31293.
// we don't see R_X86_64_REX_GOTPCRELX in new Go 1.15 and Go 1.14 minor releases.
// See golang.org/issue/31293 and golang.org/issue/40561#issuecomment-731482962.
func (b *Build) checkRelocations(client *buildlet.Client) error {
if b.OS != "linux" || b.Arch != "amd64" || b.TestOnly {
// This check is only applicable to linux/amd64 builds.
Expand All @@ -876,11 +877,25 @@ func (b *Build) checkRelocations(client *buildlet.Client) error {
return fmt.Errorf("failed to run readelf: %v", err)
}
got := out.String()
if strings.Contains(got, "R_X86_64_REX_GOTPCRELX") {
return fmt.Errorf("%s contained a R_X86_64_REX_GOTPCRELX relocation", file)
}
if !strings.Contains(got, "R_X86_64_GOTPCREL") {
return fmt.Errorf("%s did not contain a R_X86_64_GOTPCREL relocation; remoteErr=%v, %s", file, remoteErr, got)
switch {
default: // Go 1.16 and newer.
// Note: This check was kept and updated for Go 1.16, since it wasn't hard.
// Remove it at some point in the future if it becomes no longer useful or
// overly expensive to maintain.
if strings.Contains(got, "R_X86_64_GOTPCREL") {
return fmt.Errorf("%s contained a R_X86_64_GOTPCREL relocation", file)
}
if !strings.Contains(got, "R_X86_64_REX_GOTPCRELX") {
return fmt.Errorf("%s did not contain a R_X86_64_REX_GOTPCRELX relocation; remoteErr=%v, %s", file, remoteErr, got)
}
case strings.HasPrefix(*version, "go1.15"),
strings.HasPrefix(*version, "go1.14"):
if strings.Contains(got, "R_X86_64_REX_GOTPCRELX") {
return fmt.Errorf("%s contained a R_X86_64_REX_GOTPCRELX relocation", file)
}
if !strings.Contains(got, "R_X86_64_GOTPCREL") {
return fmt.Errorf("%s did not contain a R_X86_64_GOTPCREL relocation; remoteErr=%v, %s", file, remoteErr, got)
}
}
return nil
}
Expand Down

0 comments on commit b0441a6

Please sign in to comment.