From 6ed6001173345eae4c5f5e2492b830aabec967eb Mon Sep 17 00:00:00 2001 From: StefanoBelli Date: Mon, 28 Jan 2019 17:09:36 +0100 Subject: [PATCH] wrong offsets for siginfo_t, now fixed: correctly detects SEGV and program exit codes, 0.3.1 --- amd64/linux/main.S | 4 ++-- amd64/linux/sayexec.S | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/amd64/linux/main.S b/amd64/linux/main.S index 389ecd8..57d4d4f 100644 --- a/amd64/linux/main.S +++ b/amd64/linux/main.S @@ -1,7 +1,7 @@ .include "macros.S" .data -sz_sysh_banner: .string "sysh version 0.3.0\n" +sz_sysh_banner: .string "sysh version 0.3.1-emma\n" last_status_code_operation: .long 1 .extern install_sighandler @@ -23,7 +23,7 @@ main: movq $2, %rdi # SIGINT call install_sighandler - sys_write_stdout $sz_sysh_banner, $19 + sys_write_stdout $sz_sysh_banner, $24 xorw %bx, %bx movb $0x20, %bh diff --git a/amd64/linux/sayexec.S b/amd64/linux/sayexec.S index fd98bd1..d791732 100644 --- a/amd64/linux/sayexec.S +++ b/amd64/linux/sayexec.S @@ -13,6 +13,8 @@ segv_received: .asciz "sysh: segmentation fault\n" .global sayexec .text sayexec: + msysh_internal_setstatus $0 + xchgq %r11, %rdx sys_fork xchgq %r8, %r10 @@ -24,10 +26,13 @@ sayexec: subq $128, %rsp sys_waitid %rbx, %rsp - movl 24(%rsp), %eax # grazie riccardo per il suggerimento sull'offset + movl 24(%rsp), %ebx # return value + msysh_internal_setstatus %rbx + movl 8(%rsp), %ebx # why it terminated addq $128, %rsp - cmp $11, %eax +# check if it is segv + cmpl $3, %ebx jne __sayexec_finish __sayexec_child_segv: