So I added the register calling conventions for the architectures that
scripts/mcm-buildall.sh builds toolchains for (I.E. the ones I'm testing under
qemu with scripts/mkroot.sh), but when I tried to build strace for the sh4
target it went "boing" a lot because the available syscalls don't entirely match
up between architectures.

Sigh. I knew this was coming. That's why it was still on my todo list.

I've been looking at the kernel syscall plumbing anyway due to
http://lkml.iu.edu/hypermail/linux/kernel/2111.3/00074.html and it turns out the
toolchain has a full manifest of available syscalls in
/usr/include/asm-generic/unistd.h (which seems an odd place for it, but sure,
why not). That header is installed in each toolchain, so we can just reach out
and grab it at build time.

That information maps the system call number to the system call function name,
but where do we get the function prototypes for each system call? Answer:
they're in include/linux/syscalls.h in the kernel source, but THAT file is
architecture indepdendent so we only need one copy for all architectures. The
following Horrible Sed Invocation rips them out, cleans them up, and sorts them
with duplicates eliminated:

sed -E '/^asmlinkage long sys_/!d;:l;/;/b e;N;b l;:e;s/\n/ /g;s/[ \t][
\t]*(__user|)[ \t*]/ /g;p' include/linux/syscalls.h | sort -u

(The result is almost certainly scenes a faire, I.E. there is no creativity in
this data arrangement, and thus the result is not copyrightable. Modulo the
stupid oratroll "API copyright" nonsense, which we'd already be screwed by
including any part of /usr/include/linux if that was true. But you can fish 95%
of the same info out of https://man7.org/linux/man-pages/man2/syscalls.2.html if
you follow the links.)

The NEXT question is where we get the structure definitions, with all types
squashed to primitive types, for conversion into the "banana|{potato}" strings
the plumbing is trying to parse. Unfortunately THIS part may vary by
architecture again; the file #includes a bunch of things and is an #ifdef salad.
Still working on that...

Rob
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to