tests: build on non-ELF platforms

Signed-off-by: Weijia Wang <contact@weijia.wang>
This commit is contained in:
Weijia Wang 2023-03-22 12:09:47 +02:00
parent 002e1f1d3a
commit addd8fbcb9
3 changed files with 22 additions and 2 deletions

View file

@ -37,11 +37,17 @@ struct test {
int must_fail;
} __attribute__ ((aligned (16)));
#ifdef __APPLE__
#define TEST_SECTION "__RODATA,test_section"
#else
#define TEST_SECTION "test_section"
#endif
#define TEST(name) \
static void name(void); \
\
const struct test test##name \
__attribute__ ((used, section ("test_section"))) = { \
__attribute__ ((used, section (TEST_SECTION))) = { \
#name, name, 0 \
}; \
\
@ -51,7 +57,7 @@ struct test {
static void name(void); \
\
const struct test test##name \
__attribute__ ((used, section ("test_section"))) = { \
__attribute__ ((used, section (TEST_SECTION))) = { \
#name, name, 1 \
}; \
\