clarify the purpose of this project
[nyanglibc.git] / malloc / scratch_buffer_grow.s
blob362aeb18a97f042a896dd149afa69793681f60f4
1 .text
2 .p2align 4,,15
3 .globl __libc_scratch_buffer_grow
4 .hidden __libc_scratch_buffer_grow
5 .type __libc_scratch_buffer_grow, @function
6 __libc_scratch_buffer_grow:
7 pushq %r12
8 pushq %rbp
9 pushq %rbx
10 movq %rdi, %rbx
11 movq 8(%rdi), %rax
12 movq (%rdi), %rdi
13 leaq 16(%rbx), %r12
14 leaq (%rax,%rax), %rbp
15 cmpq %r12, %rdi
16 je .L2
17 call free@PLT
18 movq 8(%rbx), %rax
19 .L2:
20 cmpq %rbp, %rax
21 ja .L3
22 movq %rbp, %rdi
23 call malloc@PLT
24 testq %rax, %rax
25 je .L4
26 movq %rax, (%rbx)
27 movq %rbp, 8(%rbx)
28 movl $1, %eax
29 popq %rbx
30 popq %rbp
31 popq %r12
32 ret
33 .p2align 4,,10
34 .p2align 3
35 .L3:
36 movq __libc_errno@gottpoff(%rip), %rax
37 movl $12, %fs:(%rax)
38 .L4:
39 movq %r12, (%rbx)
40 movq $1024, 8(%rbx)
41 xorl %eax, %eax
42 popq %rbx
43 popq %rbp
44 popq %r12
45 ret
46 .size __libc_scratch_buffer_grow, .-__libc_scratch_buffer_grow