Skip to content

Commit 71f82df

Browse files
xen0nmengzhuo
authored andcommitted
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 <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent 7789966 commit 71f82df

File tree

1 file changed

+1
-0
lines changed
  • src/cmd/link/internal/loong64

1 file changed

+1
-0
lines changed

src/cmd/link/internal/loong64/obj.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ func Init() (*sys.Arch, ld.Arch) {
1919
Minalign: minAlign,
2020
Dwarfregsp: dwarfRegSP,
2121
Dwarfreglr: dwarfRegLR,
22+
CodePad: []byte{0x00, 0x00, 0x2a, 0x00}, // BREAK 0
2223
Adddynrel: adddynrel,
2324
Archinit: archinit,
2425
Archreloc: archreloc,

0 commit comments

Comments
 (0)