cmd/link: fix deferreturn detector [1.12 backport] #32484
Our backport policy is to only backport fixes for security issues, serious problems with no workaround, and documentation fixes. @randall77 I understand this is a serious issue, but can you please confirm there's no workaround for this in 1.12? If so, we should approve this cherry-pick candidate, otherwise we should not.
The logic for detecting deferreturn calls is wrong. We used to look for a relocation whose symbol is runtime.deferreturn and has an offset of 0. But on some architectures, the relocation offset is not zero. These include arm (the offset is 0xebfffffe) and s390x (the offset is 6). This ends up setting the deferreturn offset at 0, so we end up using the entry point live map instead of the deferreturn live map in a frame which defers and then segfaults. Instead, use the IsDirectJump helper to find calls. Fixes #32484 Change-Id: Iecb530a7cf6eabd7233be7d0731ffa78873f3a54 Reviewed-on: https://go-review.googlesource.com/c/go/+/181258 Run-TryBot: Keith Randall <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-by: Cherry Zhang <email@example.com> (cherry picked from commit 9eb4031) Reviewed-on: https://go-review.googlesource.com/c/go/+/181262 Reviewed-by: Emmanuel Odeke <firstname.lastname@example.org> Run-TryBot: Emmanuel Odeke <email@example.com>