feat(asm): emit the arm64 stack-split guard and morestack block
This commit is contained in:
+11
-8
@@ -27,6 +27,8 @@ func parseArm64File(t *testing.T, src string) *Image {
|
||||
// TestArm64RelocOffsetsIncludePrologue pins the function-relative relocation
|
||||
// offsets of a framed function: the offsets used to exclude the prologue, so
|
||||
// every relocation landed on a prologue instruction in the GOOBJ/ELF output.
|
||||
// The function calls an external, so it is a non-leaf and carries the
|
||||
// stack-split guard (12 bytes, small class) before the prologue.
|
||||
func TestArm64RelocOffsetsIncludePrologue(t *testing.T) {
|
||||
img := parseArm64File(t, "TEXT \u00b7f(SB), $16-0\n"+
|
||||
"\tBL ext\u00b7foo(SB)\n"+
|
||||
@@ -36,8 +38,8 @@ func TestArm64RelocOffsetsIncludePrologue(t *testing.T) {
|
||||
"GLOBL gdata(SB), $8\n")
|
||||
fn := img.Funcs[0]
|
||||
|
||||
// Layout: 12-byte prologue, BL (12), ADRP+ADD (16, 20), ADRP+ADD (24, 28),
|
||||
// 12-byte epilogue with RET.
|
||||
// Layout: 12-byte guard, 12-byte prologue, BL (24), ADRP+ADD (28, 32),
|
||||
// ADRP+ADD (36, 40), 12-byte epilogue with RET, 12-byte morestack block.
|
||||
want := []struct {
|
||||
off int
|
||||
after int
|
||||
@@ -45,11 +47,12 @@ func TestArm64RelocOffsetsIncludePrologue(t *testing.T) {
|
||||
kind RelocKind
|
||||
external bool
|
||||
}{
|
||||
{12, 16, "foo", RelArm64Branch, true},
|
||||
{16, 16, "gdata", RelArm64Addr, false},
|
||||
{20, 20, "gdata", RelArm64Addr, false},
|
||||
{24, 24, "extsym", RelArm64Addr, true},
|
||||
{28, 28, "extsym", RelArm64Addr, true},
|
||||
{24, 28, "foo", RelArm64Branch, true},
|
||||
{28, 28, "gdata", RelArm64Addr, false},
|
||||
{32, 32, "gdata", RelArm64Addr, false},
|
||||
{36, 36, "extsym", RelArm64Addr, true},
|
||||
{40, 40, "extsym", RelArm64Addr, true},
|
||||
{60, 64, "runtime\u00b7morestack_noctxt", RelArm64Branch, true},
|
||||
}
|
||||
if len(fn.Relocs) != len(want) {
|
||||
t.Fatalf("relocs = %d, want %d", len(fn.Relocs), len(want))
|
||||
@@ -64,7 +67,7 @@ func TestArm64RelocOffsetsIncludePrologue(t *testing.T) {
|
||||
|
||||
// The BL with a zero offset sits exactly at the first reloc site.
|
||||
code := img.Code[fn.Offset : fn.Offset+fn.Size]
|
||||
if w := binary.LittleEndian.Uint32(code[12:16]); w != 0x94000000 {
|
||||
if w := binary.LittleEndian.Uint32(code[24:28]); w != 0x94000000 {
|
||||
t.Errorf("BL word = %08x, want 94000000", w)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user