feat(amd64): LOCK and REP prefixes, literal data pseudo-ops and ADJSP
Assisted-by: GLM 5.3 Flash
This commit is contained in:
Vendored
+62
@@ -0,0 +1,62 @@
|
||||
// Literal data emission: BYTE, WORD, LONG and QUAD write the immediate
|
||||
// into the text stream as 1, 2, 4 or 8 little-endian bytes with no opcode
|
||||
// lookup, truncated to the width rather than range-checked; END is
|
||||
// accepted and ignored, contributing no bytes and ending nothing. The
|
||||
// shapes mirror the runtime's hand-laid markers
|
||||
// (crypto/internal/boring/sig/sig_amd64.s) and its syscall stubs
|
||||
// (runtime/sys_linux_amd64.s).
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func marker()
|
||||
// A boring/crypto-style marker: a hand-laid forward branch whose skip
|
||||
// distance is patched at runtime. One BYTE per statement, as the
|
||||
// runtime's own file spells it: the semicolon-separated one-liner the
|
||||
// sys_linux_amd64.s stub uses does not survive gasm fmt, which drops the
|
||||
// statement separators.
|
||||
TEXT ·marker(SB), NOSPLIT, $0-0
|
||||
BYTE $0xEB
|
||||
BYTE $0x1D
|
||||
BYTE $0xF4
|
||||
BYTE $0x48
|
||||
BYTE $0xF4
|
||||
BYTE $0x4B
|
||||
BYTE $0xC3
|
||||
RET
|
||||
|
||||
// func stub()
|
||||
// The sys_linux_amd64.s stub bytes: the sign-extended
|
||||
// "48 c7 c0 0f 00 00 00" form of MOVQ $rt_sigreturn, AX.
|
||||
TEXT ·stub(SB), NOSPLIT, $0-0
|
||||
BYTE $0x48
|
||||
BYTE $0xc7
|
||||
BYTE $0xc0
|
||||
BYTE $0x0f
|
||||
BYTE $0x00
|
||||
BYTE $0x00
|
||||
BYTE $0x00
|
||||
RET
|
||||
|
||||
// func words()
|
||||
// The wider literals, and an END that ends nothing: the WORD after it
|
||||
// still lands in this function.
|
||||
TEXT ·words(SB), NOSPLIT, $0-0
|
||||
WORD $0x1234
|
||||
WORD $-1
|
||||
LONG $0x11223344
|
||||
LONG $-1
|
||||
QUAD $0x1122334455667788
|
||||
QUAD $-2
|
||||
END
|
||||
WORD $0xBEEF
|
||||
RET
|
||||
|
||||
// func trunc()
|
||||
// Truncation, not a range check: each literal keeps its low bytes, exactly
|
||||
// as go tool asm emits them.
|
||||
TEXT ·trunc(SB), NOSPLIT, $0-0
|
||||
BYTE $0x1FF
|
||||
WORD $0x12345
|
||||
LONG $0x123456789
|
||||
QUAD $-2
|
||||
RET
|
||||
Reference in New Issue
Block a user