[PATCH] linux/init.h: Always omit __exit code and data for in-kernel compilation

From: Josh Triplett
Date: Tue Oct 21 2014 - 19:14:19 EST


__exit code and data only exists for module removal; when compiling such
code in the kernel, omit the __exit functions to save space. For x86
defconfig this saves about 9k, and significantly more in the compiled
binary size.

Signed-off-by: Josh Triplett <josh@xxxxxxxxxxxxxxxx>
---
include/linux/init.h | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/linux/init.h b/include/linux/init.h
index 2df8e8d..daa329d 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -42,8 +42,14 @@
#define __init __section(.init.text) __cold notrace
#define __initdata __section(.init.data)
#define __initconst __constsection(.init.rodata)
+
+#ifdef MODULE
#define __exitdata __section(.exit.data)
#define __exit_call __used __section(.exitcall.exit)
+#else
+#define __exitdata __always_unused
+#define __exit_call __always_unused
+#endif

/*
* Some architecture have tool chains which do not handle rodata attributes
@@ -89,7 +95,11 @@
#define __exitused __used
#endif

-#define __exit __section(.exit.text) __exitused __cold notrace
+#ifdef MODULE
+#define __exit __section(.exit.text) __cold notrace
+#else
+#define __exit __always_unused
+#endif

/* temporary, until all users are removed */
#define __cpuinit
--
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/