Adds support for the clone3 syscall, similar to existing support for the clone syscall. The functionality provided by clone3 is a superset of clone. It uses a struct to encapsulate all args. Also, the stack address is expected to be the lowest one in the stack (inclusive); this is unlike clone where it is expected to be the highest one (non-inclusive).
Creates a copy of the kernel's clone_args struct so that it is available on all Linux versions, which simplifies some code.
For clone3, we need to be more careful about restoring any clone args that were modified by DR. As clone3 accepts a pointer to the clone_args struct, any changes we make need to be reverted in the struct. The strategy we follow here is to create a copy of app's clone_args to make the syscall; this way the app's original copy remains intact. After the syscall, we modify the syscall arg reg so that it again contains the pointer to the app's original clone_args instead of DR's modified copy. This restoration is done in the parent and the child both.
Also adds a missing restore for the reg that holds the child's stack ptr arg, after the clone syscall, in the parent thread.
On AArchXX, the syscall reg for clone_args is the same as the one that contains the result of the syscall, so we skip writing the app's clone_args pointer in that case.
Extends the existing linux.clone test to verify behaviour on clone3 as well. As there is no glibc wrapper for clone3 yet, the test has to add a wrapper on its own.
Issue: #5131 (closed)