From: WANG Xuerui Date: Sat, 11 Mar 2023 14:38:01 +0000 (+0800) Subject: cmd/link/internal/loong64: use BREAK 0 as the code pad sequence X-Git-Tag: go1.21rc1~1277 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=71f82df19a7595b422d9dbc7d05530bd824a9114;p=gostls13.git cmd/link/internal/loong64: use BREAK 0 as the code pad sequence As the comment on CodePad goes, we "might want to pad with a trap instruction to catch wayward programs". The current behavior of zero-padding is equivalent to padding with an instruction of 0x00000000, which is invalid according to the LoongArch manuals nevertheless, but rumor has it that some early and/or engineering samples of Loongson 3A5000 recognized it (maybe behaving like NOP). It is better to avoid undocumented behavior and ensure execution flow would not overflow the pads. Change-Id: I531b1eabeb355e9ad4a2d5340e61f2fe71349297 Reviewed-on: https://go-review.googlesource.com/c/go/+/475616 Reviewed-by: abner chenc Reviewed-by: Ian Lance Taylor Run-TryBot: Cherry Mui TryBot-Result: Gopher Robot Reviewed-by: Cherry Mui --- diff --git a/src/cmd/link/internal/loong64/obj.go b/src/cmd/link/internal/loong64/obj.go index 0f2ca2ebc7..c3f6ed9386 100644 --- a/src/cmd/link/internal/loong64/obj.go +++ b/src/cmd/link/internal/loong64/obj.go @@ -19,6 +19,7 @@ func Init() (*sys.Arch, ld.Arch) { Minalign: minAlign, Dwarfregsp: dwarfRegSP, Dwarfreglr: dwarfRegLR, + CodePad: []byte{0x00, 0x00, 0x2a, 0x00}, // BREAK 0 Adddynrel: adddynrel, Archinit: archinit, Archreloc: archreloc,