# Reproducer for qemu-i386 crash on aarch64
#
# taviso@gmail.com

.equ __NR_alarm, 27
.equ __NR_pause, 29
.equ __NR_sigaction, 67
.equ __NR_exit, 1

.equ SIGALRM, 14

.equ SA_NODEFER,   0x40000000
.equ SA_RESETHAND, 0x80000000
.equ SA_INTERRUPT, 0x20000000

.intel_syntax noprefix

.globl _start

.section .data

act:
    .int    handler                                     # sa_handler
    .int    0                                           # sa_mask
    .int    SA_NODEFER | SA_RESETHAND | SA_INTERRUPT    # sa_flags
    .int    0                                           # sa_restorer

.section .text

noop:
    ret

handler:
    ret

_start:
    mov     edx, 0
    lea     ecx, act
    mov     ebx, SIGALRM
    mov     eax, __NR_sigaction
    int     0x80
    mov     ebx, 1
    mov     eax, __NR_alarm
    int     0x80
    mov     eax, __NR_pause
    int     0x80
    call    noop
    mov     ebx, 0
    mov     eax, __NR_exit
    int     0x80
