Skip to content

Commit c994a3d

Browse files
committed
Use template-style syntax to select call ABI
e.g.: f<naked>(...)
1 parent 716d0a0 commit c994a3d

8 files changed

Lines changed: 41 additions & 7 deletions

File tree

src/e9tool/e9tool.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,11 +1234,12 @@ static Patch *parsePatch(const ELF &elf, const char *str)
12341234

12351235
case PATCH_CALL:
12361236
{
1237-
t = parser.expectToken2('(', '.');
1238-
if (t == '.')
1237+
t = parser.expectToken2('(', '<');
1238+
if (t == '<')
12391239
{
12401240
t = parser.expectToken2(TOKEN_CLEAN, TOKEN_NAKED);
12411241
abi = (t == TOKEN_CLEAN? ABI_CLEAN: ABI_NAKED);
1242+
parser.expectToken('>');
12421243
parser.expectToken('(');
12431244
}
12441245
while (true)

test/regtest/clean.exp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
push %r15
2+
movq 0x5e(%rip), %rax
3+
cmp %rax, %rbx
4+
nop
5+
nopl %eax, (%rax)
6+
cmp $0x33, %ebx
7+
movq 0x28(%rip), %r8
8+
movq 0x19a(%rip), %rcx
9+
cmp %r8, %rcx
10+
nopl %eax, (%rax)
11+
jmp 0xa000163
12+
jmp 0xa00016d
13+
jmp 0xa000177
14+
lea 0x14(%rip), %r10
15+
push %r10
16+
push %r11
17+
jmpq *0x777f(%rsp,%rcx,1)
18+
add $0x8, %rsp
19+
lea 0x2(%rip), %rdx
20+
pop %r14
21+
push %r13
22+
pxor %xmm0, %xmm0
23+
cmp $0x85, %rax
24+
movq -0x100(%rsp), %rax
25+
movq -0x100(%rsp,%rsi,8), %rax
26+
movq %cs:-0x100(%rsp,%rsi,8), %rax
27+
movq %ds:-0x100(%rsp,%rsi,8), %rcx
28+
cmp %rax, %rcx
29+
cmp %rcx, %rdx
30+
cmp %rcx, %rdx
31+
lea 0x54(%rip), %rsi
32+
PASSED

test/regtest/clean.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./test -M 'asm=.*p.*' -P 'naked<clean>(asm)@patch'

test/regtest/naked.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
./test -M true -P 'naked.naked(asm)@patch'
1+
./test -M true -P 'naked<naked>(asm)@patch'

test/regtest/naked_2.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
./test -M true -P 'naked.naked(asm,state,rsp,rax,&rax,trampoline,target,next)@patch'
1+
./test -M true -P 'naked<naked>(asm,state,rsp,rax,&rax,trampoline,target,next)@patch'

test/regtest/naked_3.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
./test -M true -P 'if ret_0x0.naked(asm,state,rsp,rax,&rax,trampoline,target,next)@patch break'
1+
./test -M true -P 'if ret_0x0<naked>(asm,state,rsp,rax,&rax,trampoline,target,next)@patch break'

test/regtest/naked_4.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
./test -M true -P 'nop.naked(op[0],op[1],op[2],&op[0],&op[1],&op[2],state,addr)@patch'
1+
./test -M true -P 'nop<naked>(op[0],op[1],op[2],&op[0],&op[1],&op[2],state,addr)@patch'

test/regtest/naked_bug.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
./test -M 'rax in regs' -P 'naked_bug.naked(rax,state)@patch'
1+
./test -M 'rax in regs' -P 'naked_bug<naked>(rax,state)@patch'

0 commit comments

Comments
 (0)