compel: rewrite parasite cmd and args manipulation from assembly to C

Previously, __export_parasite_cmd was located in parasite-head.S, and
__export_parasite_args located exactly at the end of the parasite blob.
This is not ideal for various reasons:
1) These two variables work together. It would be preferrable to have
them in the same location
2) This prevent us from allocating another section betweeen the parasite
blob and the args area. We'll need this to allocate a GOT table

This commit changes the allocation of these symbols from assembly/linker
script to a C file.

Moreover, the assembly entry points that invoke parasite_service()
prepares arguments with hand crafted assembly. This is unecessary.
This commit rewrite this logic with regular C code.

Note: if it wasn't for the x86 compat mode, we could remove all
parasite-head.S files and directly jump to parasite_service() via
ptrace.  An int3 architecture specific equivalent could be called at the
end of parasite_service() with an inline asm statement.

Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com>
This commit is contained in:
Nicolas Viennot 2020-07-16 23:14:35 +00:00 committed by Dmitry Safonov
parent 67965cb836
commit d7353b9bb7
18 changed files with 54 additions and 107 deletions

View file

@ -4,7 +4,10 @@
#include "common/compiler.h"
extern int parasite_get_rpc_sock(void);
extern int __must_check parasite_service(unsigned int cmd, void *args);
extern unsigned int __export_parasite_service_cmd;
extern void * __export_parasite_service_args_ptr;
extern int __must_check parasite_service(void);
/*
* Must be supplied by user plugins.