summaryrefslogtreecommitdiff
path: root/tools/objtool/tests/generic/fixtures/cold_function.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/objtool/tests/generic/fixtures/cold_function.c')
-rw-r--r--tools/objtool/tests/generic/fixtures/cold_function.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/objtool/tests/generic/fixtures/cold_function.c b/tools/objtool/tests/generic/fixtures/cold_function.c
new file mode 100644
index 000000000000..f6d410983ce2
--- /dev/null
+++ b/tools/objtool/tests/generic/fixtures/cold_function.c
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Function the compiler may split into a hot part and a foo.cold part. */
+
+static const char __modinfo[]
+ __attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux";
+
+static void __attribute__((cold, noinline)) slow_path(int x)
+{
+ __asm__ volatile("" :: "r"(x));
+}
+
+int target(int x)
+{
+ if (__builtin_expect(x < 0, 0))
+ slow_path(x);
+#ifdef PATCHED
+ return x + 2;
+#else
+ return x + 1;
+#endif
+}