summaryrefslogtreecommitdiff
path: root/src/basic/alloc-util.h
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@gotplt.org>2023-01-07 19:30:32 -0500
committerDaan De Meyer <daan.j.demeyer@gmail.com>2023-01-08 16:26:39 +0100
commit4f79f545b3c46c358666c9f5f2b384fe50aac4b4 (patch)
treed97ae762c3e22c11bc2551616d1c103c564e9df5 /src/basic/alloc-util.h
parent9907a7e00b7c57f56020eeec3247e0f75799435d (diff)
downloadsystemd-4f79f545b3c46c358666c9f5f2b384fe50aac4b4.tar.gz
alloc-util: Disallow inlining of expand_to_usable
Explicitly set __attribute__ ((noinline)) so that the compiler does not attempt to inline expand_to_usable, even with LTO.
Diffstat (limited to 'src/basic/alloc-util.h')
-rw-r--r--src/basic/alloc-util.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/basic/alloc-util.h b/src/basic/alloc-util.h
index eb53aae6f3..bf783b15a2 100644
--- a/src/basic/alloc-util.h
+++ b/src/basic/alloc-util.h
@@ -186,10 +186,11 @@ void* greedy_realloc0(void **p, size_t need, size_t size);
#endif
/* Dummy allocator to tell the compiler that the new size of p is newsize. The implementation returns the
- * pointer as is; the only reason for its existence is as a conduit for the _alloc_ attribute. This cannot be
- * a static inline because gcc then loses the attributes on the function.
+ * pointer as is; the only reason for its existence is as a conduit for the _alloc_ attribute. This must not
+ * be inlined (hence a non-static function with _noinline_ because LTO otherwise tries to inline it) because
+ * gcc then loses the attributes on the function.
* See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96503 */
-void *expand_to_usable(void *p, size_t newsize) _alloc_(2) _returns_nonnull_;
+void *expand_to_usable(void *p, size_t newsize) _alloc_(2) _returns_nonnull_ _noinline_;
static inline size_t malloc_sizeof_safe(void **xp) {
if (_unlikely_(!xp || !*xp))