syscalls icon indicating copy to clipboard operation
syscalls copied to clipboard

Implementing `sparc` and `sparc64` support

Open cottnn opened this issue 3 years ago • 1 comments

Hi, it seems like there's no support for sparc or sparc64 architectures currently. What would be the steps to implement support for making syscalls on them? Would it be possible to incorporate the required assembly code from similar Rust libraries?

cottnn avatar Oct 29 '22 18:10 cottnn

As long as Rust supports inline assembly on sparc and sparc64, there's nothing blocking it.

If you're interested in implementing this yourself, here's what needs to be done:

  1. Add building/testing for sparc/sparc64 to CI: https://github.com/jasonwhite/syscalls/blob/288d146210fd378999d0f825ffef9cb3a002f38e/.github/workflows/ci.yml#L40-L41 It looks like cargo-cross now supports sparc64 with sparc64-unknown-linux-gnu, but not sparc.
  2. Modify src/syscall/sparc.rs and src/syscall/sparc64.rs to add the implementation.

Here are some helpful references when implementing syscalls with inline assembly:

  • https://man7.org/linux/man-pages/man2/syscall.2.html
  • glibc generic stuff for sparc32/sparc64: https://elixir.bootlin.com/glibc/latest/source/sysdeps/unix/sysv/linux/sparc/sysdep.h
  • glibc sparc32-specific stuff: https://elixir.bootlin.com/glibc/latest/source/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h
  • glibc sparc64-specific stuff: https://elixir.bootlin.com/glibc/latest/source/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h

Normally the musl libc code is a better reference than glibc, but they don't have support for sparc/sparc64 it seems.

jasonwhite avatar Oct 30 '22 18:10 jasonwhite