aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/internal/obj/x86/asm6.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/cmd/internal/obj/x86/asm6.go b/src/cmd/internal/obj/x86/asm6.go
index f3be6cdfc7..8159e5934f 100644
--- a/src/cmd/internal/obj/x86/asm6.go
+++ b/src/cmd/internal/obj/x86/asm6.go
@@ -1754,7 +1754,16 @@ func span6(ctxt *obj.Link, s *obj.LSym) {
c = naclpad(ctxt, s, c, -c&31)
}
- c += -c & (FuncAlign - 1)
+ // Pad functions with trap instruction, to catch invalid jumps
+ if c&(FuncAlign-1) != 0 {
+ v = -c & (FuncAlign - 1)
+ obj.Symgrow(ctxt, s, int64(c)+int64(v))
+ for i := c; i < c+v; i++ {
+ // 0xCC is INT $3 - breakpoint instruction
+ s.P[i] = uint8(0xCC)
+ }
+ c += v
+ }
s.Size = int64(c)
if false { /* debug['a'] > 1 */