bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Need help with assembly code


From: Svante Signell
Subject: Need help with assembly code
Date: Mon, 29 Nov 2021 18:40:48 +0100
User-agent: Evolution 3.30.5-1.1

Hello,

I've been working lately with on how to port valgrind to GNU/Hurd, and found out
that this is not a trivial task. Seems like one have to make a suitable mix of
linux and darwin code (and to some extent freebsd/solaris code). Being a novice
on assembly programming I need some help on modifying the Darwin code for 
syscall-x86-darwin.S to GNU. The following code snippet fails to compile with
gcc/gas:

#define VKI_SIG_SETMASK 3
/* DO_SYSCALL MACH|MDEP|UNIX */
#define MACH 1
#define MDEP 2
#define UNIX 3
        
.macro DO_SYSCALL
        /* establish stack frame */
        push    %ebp
        mov     %esp, %ebp
        subl    $$8, %esp       /* 16-byte align stack */
        
L_$0_1: /* Even though we can't take a signal until the
           __pthread_sigmask completes, start the range early.
           If eip is in the range [1,2), the syscall hasn't been started yet */

        /* Set the signal mask which should be current during the syscall. */
        /* Set up for __pthread_sigmask(SIG_SETMASK, sysmask, postmask) */
        pushl   20(%ebp)
        pushl   16(%ebp)
        pushl   $$VKI_SIG_SETMASK
        pushl   $$0xcafebabe    /* totally fake return address */
        movl    $$__NR___pthread_sigmask, %eax
        int     $$0x80  /* should be sysenter? */
        jc      L_$0_7  /* __pthread_sigmask failed */
        addl    $$16,%esp
....
L_$0_2:
.if $0 == UNIX
        int     $$0x80          /* UNIX (GrP fixme should be sysenter?) */
.elseif $0 == MACH
        int     $$0x81
.elseif $0 == MDEP
        int     $$0x82
.else
        error$0 x
.endif

L_ $0_3: ...

.endm (.endmacro gives: Error: unexpected end of file in macro `do_syscall'
 definition)

.globl ML_(do_syscall_for_client_unix_WRK)
ML_(do_syscall_for_client_unix_WRK):
        DO_SYSCALL UNIX
(additional code for DO_SYSCALL MACH/MDEP)

.data
#define FOO(scclass,labelno) L_##scclass##_##labelno
#define MK_L_SCCLASS_N(scclass,labelno) FOO(scclass,labelno)

.globl ML_(blksys_setup_UNIX)
.globl ML_(blksys_restart_UNIX)
.globl ML_(blksys_complete_UNIX)
.globl ML_(blksys_committed_UNIX)
.globl ML_(blksys_finished_UNIX)
ML_(blksys_setup_UNIX): .long MK_L_SCCLASS_N(UNIX,1)
ML_(blksys_restart_UNIX):       .long MK_L_SCCLASS_N(UNIX,2)
ML_(blksys_complete_UNIX):      .long MK_L_SCCLASS_N(UNIX,3)
ML_(blksys_committed_UNIX):     .long MK_L_SCCLASS_N(UNIX,4)
ML_(blksys_finished_UNIX):      .long MK_L_SCCLASS_N(UNIX,5)

(additional code for MACH/MDEP)

Compiling results in: 
m_syswrap/syscall-x86-gnu.S:196: Error: too many positional arguments (3 times)

How to change the macro definition to accept aruments?
Is the code OK also for GNU/Hurd?

Thanks!




reply via email to

[Prev in Thread] Current Thread [Next in Thread]