test,static-destruct: Use retain attribute to prevent linker garbage collection

Fixes: #21847
This commit is contained in:
Jan Janssen
2021-12-22 12:14:08 +09:00
committed by Yu Watanabe
parent 8470a16d6f
commit a3aff1c47f
4 changed files with 8 additions and 2 deletions
+2 -1
View File
@@ -57,7 +57,8 @@ typedef struct TestFunc {
/* See static-destruct.h for an explanation of how this works. */
#define REGISTER_TEST(func, ...) \
_section_("SYSTEMD_TEST_TABLE") _alignptr_ _used_ _variable_no_sanitize_address_ \
_Pragma("GCC diagnostic ignored \"-Wattributes\"") \
_section_("SYSTEMD_TEST_TABLE") _alignptr_ _used_ _retain_ _variable_no_sanitize_address_ \
static const TestFunc UNIQ_T(static_test_table_entry, UNIQ) = { \
.f = (union f) &(func), \
.name = STRINGIFY(func), \