Skip to content

Commit 657aafb

Browse files
committed
runtime, tests: require -Werror=strict-prototypes so every function has a prototype
In order to have C callgate wrappers, we need to know function prototypes, but `ReturnType foo()` functions have no prototype, as `foo(void)` is required. ABI determination (and soon to be API, too) is done eagerly for all functions, so this errors when a function has no prototype. We can later relax this to only requiring prototypes on functions with callgates. Furthermore, often projects enable `-Werror=strict-prototypes` themselves, like `dav1d`. Turning this on here for the IA2 runtime and tests means that we don't have to disable it in other projects like `dav1d`.
1 parent 5eaa9bc commit 657aafb

File tree

33 files changed

+56
-55
lines changed

33 files changed

+56
-55
lines changed

cmake/ia2.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ function(add_ia2_compartment NAME TYPE)
5252
set_target_properties(${NAME} PROPERTIES PKEY ${ARG_PKEY})
5353
target_compile_options(${NAME} PRIVATE
5454
"-Werror=incompatible-pointer-types"
55+
"-Werror=strict-prototypes"
5556
"-fPIC"
5657
)
5758

docs/compartmentalizing_dav1d.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ Then there are overrides:
151151
First just disabling some warnings/errors that `dav1d` enabled but IA2's runtime doesn't follow
152152
(so this would be different for another project):
153153

154-
* `-Wno-strict-prototypes`
155154
* `-Wno-missing-prototypes`
156155
* `-Wno-unused-function`
157156
* `-Wno-unknown-warning-option`

docs/usage.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ are also required:
205205
-I $IA2_PATH/runtime/libia2/include
206206
-I $IA2_PATH/runtime/partition-alloc/include
207207
-Werror=incompatible-pointer-types
208+
-Werror=strict-prototypes
208209
-Wl,--wrap=pthread_create
209210
-Wl,--wrap=calloc
210211
-Wl,--wrap=free

runtime/libia2/include/ia2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ extern "C" {
152152
#endif
153153

154154
/// Returns the raw PKRU register value
155-
uint32_t ia2_get_pkru();
155+
uint32_t ia2_get_pkru(void);
156156

157157
/// Returns the current compartment pkey
158-
size_t ia2_get_pkey();
158+
size_t ia2_get_pkey(void);
159159

160160
#ifdef __cplusplus
161161
}

runtime/libia2/include/ia2_compartment_init.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ extern char __start_ia2_shared_data __attribute__((visibility("hidden"))),
4545
__stop_ia2_shared_data __attribute__((visibility("hidden")));
4646

4747
void ia2_set_up_tags(int *n_to_alloc);
48-
__attribute__((constructor)) static void COMPARTMENT_IDENT(init_pkey)() {
48+
__attribute__((constructor)) static void COMPARTMENT_IDENT(init_pkey)(void) {
4949
ia2_set_up_tags(&ia2_n_pkeys_to_alloc);
5050
struct IA2SharedSection shared_sections[2] = {{
5151
&__start_ia2_shared_data,

runtime/libia2/include/ia2_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ static int ia2_mprotect_with_tag(void *addr, size_t len, int prot, int tag) {
339339
#endif
340340
#endif
341341
char *allocate_stack(int i);
342-
void allocate_stack_0();
342+
void allocate_stack_0(void);
343343
void verify_tls_padding(void);
344344
void ia2_set_up_tags(int *n_to_alloc);
345345
__attribute__((__noreturn__)) void ia2_reinit_stack_err(int i);

runtime/libia2/init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ char *allocate_stack(int i) {
3636
return stack + STACK_SIZE - 8;
3737
}
3838

39-
void allocate_stack_0() {
39+
void allocate_stack_0(void) {
4040
ia2_stackptr_0[0] = allocate_stack(0);
4141
}
4242

runtime/partition-alloc/src/get_pkey.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
#ifdef __x86_64__
88
__attribute__((__visibility__("hidden")))
9-
uint32_t ia2_get_pkru() {
9+
uint32_t ia2_get_pkru(void) {
1010
uint32_t pkru = 0;
1111
__asm__ volatile("rdpkru" : "=a"(pkru) : "a"(0), "d"(0), "c"(0));
1212
return pkru;
1313
}
1414

1515
__attribute__((__visibility__("hidden")))
16-
size_t ia2_get_pkey() {
16+
size_t ia2_get_pkey(void) {
1717
uint32_t pkru;
1818
__asm__("rdpkru" : "=a"(pkru) : "a"(0), "d"(0), "c"(0));
1919
switch (pkru) {

tests/abi/abi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ void arg1(int x) {
1212
}
1313

1414
// LINKARGS: --wrap=foo
15-
void foo() {
15+
void foo(void) {
1616
cr_log_info("foo");
1717
}
1818

1919
// LINKARGS: --wrap=return_val
20-
int return_val() {
20+
int return_val(void) {
2121
cr_log_info("return_val");
2222
return 1;
2323
}

tests/abi/include/abi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ struct in_memory {
55
};
66

77
// This function does nothing
8-
void foo();
8+
void foo(void);
99

1010
// This returns an integer 1
11-
int return_val();
11+
int return_val(void);
1212

1313
// This takes an integer, expects value 1
1414
void arg1(int x);

0 commit comments

Comments
 (0)