test,static-destruct: Use retain attribute to prevent linker garbage collection
Fixes: #21847
This commit is contained in:
@@ -24,12 +24,16 @@ typedef struct StaticDestructor {
|
||||
typeof(variable) *q = p; \
|
||||
func(q); \
|
||||
} \
|
||||
/* Older compilers don't know retain attribute. */ \
|
||||
_Pragma("GCC diagnostic ignored \"-Wattributes\"") \
|
||||
/* The actual destructor structure we place in a special section to find it */ \
|
||||
_section_("SYSTEMD_STATIC_DESTRUCT") \
|
||||
/* We pick pointer alignment, since that is apparently what gcc does for static variables */ \
|
||||
_alignptr_ \
|
||||
/* Make sure this is not dropped from the image because not explicitly referenced */ \
|
||||
_used_ \
|
||||
/* Prevent linker from garbage collection. */ \
|
||||
_retain_ \
|
||||
/* Make sure that AddressSanitizer doesn't pad this variable: we want everything in this section
|
||||
* packed next to each other so that we can enumerate it. */ \
|
||||
_variable_no_sanitize_address_ \
|
||||
|
||||
Reference in New Issue
Block a user