'syscall: unknown syscall trap' with assembler program

Valery valery at magicErmine.com
Mon Jun 16 11:05:53 UTC 2008


ood day,

I recently discovered following problem with strace on ARM
(QEMU, with kernel 2.6.18-5-versatile, OABI, strace both 4.5.14-2 and 4.5.16.

When I run any "normal" program under strace both statically and  
dynamically linked -
like /sbin/ldconfig, /bin/dd, etc - everything is OK.

When I run my own program written in assembler, which doesn't linked with libc
I got:
strace ./bad1
execve("./bad1", ["./bad1"], [/* 19 vars */]) = 0
syscall: unknown syscall trap 0x00008000

Attached is a tar with makefile and 4 assembler programs: 2 of them  
(good1 and good2) run
under strace and another 2 (bad1 and bad2) fail with a message above.

When I was trying to understand what is a problem I added some debug output to
the strace (4.5.16)
In the file syscall.c (line 1058)
  scno = ptrace(PTRACE_PEEKTEXT, pid, (void *)(regs.ARM_pc - 4), NULL);
I printed regs.ARM_pc and was surprised to see, that it for some reason not
address of syscall instruction but executable's entry point !).

In the line 1063:
                         if (scno == 0 && (tcp->flags & TCB_WAITEXECVE)) {
                                 tcp->flags &= ~TCB_WAITEXECVE;
                                 return 0;
                         }

I.e if regs.ARM_pc - 4 points to the word with content 0, this  
"syscall" ignored
(like in case with glibc-linked programs) otherwise - it's processed.
Value in this address is implementation depended.
I was able to fix my tests (and real program too) and now I can to run them
under strace.
But it's still looks like some problem with strace.
May be condition in line 1063 should be changed to something like
                         if ( ((scno == 0) || (regs.ARM_pc ==  
entry_point)) && (tcp->flags
& TCB_WAITEXECVE)) {


My test programs are following:
good1.S - very basic test program - run under strace
bad1.S  - slightly modified test program - failed under strace
good2.S - when I realized, that word before program's entry point should be 0
          I added it. Run under strace.
bad2.S   - Just to verify that I got it right - this word changed from  0 to 1
         and oops - as expected it's failed.

Regards,
Valery.

http://magicErmine.com
Tools for Professional Software Deployment





More information about the Strace-devel mailing list