below/HelloSilicon

openat syscall not working

below opened this issue · 1 comments

below commented

I tried to adapt the openat call to Darwin, but it returns 9, regardless of the input file (i.e. even when I would be expecting an error).

I have disassembled libsystem_kernel.dylib, and didn't really get wiser:

   15548:       b7 13 40 b9     ldr     w23, [x29, #16]
   1554c:       e3 3e 00 12     and     w3, w23, #0xffff
   15550:       e0 03 15 aa     mov     x0, x21
   15554:       e1 03 14 aa     mov     x1, x20
   15558:       e2 03 13 aa     mov     x2, x19
   1555c:       27 b7 ff 97     bl      ___openat

___openat:      
    31f8:       f0 39 80 d2     mov     x16, #463 
    31fc:       01 10 00 d4     svc     #0x80
    3200:       e3 00 00 54     b.lo    0x321c

I can't really see a big difference in my call:

mov X16, #463 // openat, see bsd/kern/syscalls.master

If anyone has an idea …

below commented

The AT_FDCWD value was the problem. It's -2 on Darwin