Closed hbcam closed 8 years ago
Does this work with all functions, or just ones that are part of the C specification? I suspect that it's a bad idea to add attributes on standard library functions, as it's undefined behaviour in C (programs are allowed to declare void *malloc()
without including headers and so having mismatched calling conventions would be Very Bad™.
It only happens with some stl functions (malloc-related, printf-related, exit, maybe more). I will avoid those names. Might be worth improving the error message?
The error message is not very informative, but this is caused by providing a definition of a standard function that conflicts with the definition from the standard. Doing so is undefined behaviour.
Testcase: (a.c)
__attribute__((cheri_ccallee)) void malloc(void);
The name malloc is important here.
Command:
clang --target=cheri-unknown-freebsd -mabi=sandbox -fcolor-diagnostics -c a.c
Result: