On 5 Mar 2023, at 20:46, Sergey Bugaev <buga...@gmail.com> wrote: > > Speaking of wrapping the syscall and INTR_MSG_TRAP, I might need a > little help — is there a proper way to tell GCC that my inline > assembly needs a specific register as input _and_ clobbers it? In > Rust, this would be, for instance, > > asm!("whatever", inout("rdi") msg => _) > > but GCC doesn't like > > asm volatile ("whatever" : : "D"(msg) : "rdi"); > > and it's explicitly documented to not work. I guess I could try either > > void *clobber; > asm volatile ("whatever" : "=D"(clobber) : "D"(msg)); > // Never use clobber again > > or > > void *tmp = msg; > asm volatile ("whatever" : "+D"(tmp)); > // Never use tmp again
This one, unless I’m missing something. (Potentially with an early clobber & if needed) Jess > but I'm wondering if there's a proper way to do this. Any tips? If > not, any preference among the two above options? > > Sergey >