Structs containing capabilities are not handled correctly when passed by value as variadic arguments. For example:
#include <stdarg.h>
typedef struct {
void * a;
int b;
char c[4];
} bar_t;
extern int onward(void*, int, char*);
int foo(va_list ap) {
bar_t x = va_arg(ap, bar_t);
return onward(x.a, x.b, x.c);
}
compiles (with -std=c2x -nostdlib -target riscv32-unknown-unknown -mcpu=cheriot -mabi=cheriot -mxcheri-rvc -mrelax -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-builtin -fno-exceptions -fno-asynchronous-unwind-tables -S and using the stdarg.h header from the cheriot-rtos project) to:
In particular, it uses the LC.DDC instruction which is invalid on CHERIoT as a purecap-only architecture. Structs which do not contain capabilities appear to be handled correctly.
Structs containing capabilities are not handled correctly when passed by value as variadic arguments. For example:
compiles (with
-std=c2x -nostdlib -target riscv32-unknown-unknown -mcpu=cheriot -mabi=cheriot -mxcheri-rvc -mrelax -ffunction-sections -fdata-sections -fomit-frame-pointer -fno-builtin -fno-exceptions -fno-asynchronous-unwind-tables -S
and using thestdarg.h
header from the cheriot-rtos project) to:In particular, it uses the
LC.DDC
instruction which is invalid on CHERIoT as a purecap-only architecture. Structs which do not contain capabilities appear to be handled correctly.