summaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2024-03-04 19:59:43 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2024-03-05 16:28:05 +0100
commita7e6cd8e3efa75b5625c1df3b9ae44c76dd51c0d (patch)
tree82eed4a92a9da46807a4f73bc8444ed835283de8 /include/linux
parent22ae71e69d20972f1f8bb80ba9fa971293d5d3f4 (diff)
downloadbarebox-a7e6cd8e3efa75b5625c1df3b9ae44c76dd51c0d.tar.gz
barebox-a7e6cd8e3efa75b5625c1df3b9ae44c76dd51c0d.tar.xz
pbl: introduce CONFIG_PBL_FULLY_PIC
In the quest for making barebox PBL code W^X mappable, we have now taken care to make the ARM64 assembly routines not emit code relocations, so let's do the same for the C code as well. We do this by setting pragma GCC visibility push(hidden) globally. This option is stronger than -fvisibility=hidden and ensures we are completely position-independent. See kernel commit e544ea57ac07 ("x86/boot/compressed: Force hidden visibility for all symbol references") for more information. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20240304190038.3486881-59-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/export.h2
-rw-r--r--include/linux/hidden.h19
2 files changed, 20 insertions, 1 deletions
diff --git a/include/linux/export.h b/include/linux/export.h
index 8f47742bea..a136d727d1 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -6,7 +6,7 @@
#define THIS_MODULE 0
-#ifdef CONFIG_MODULES
+#if defined(CONFIG_MODULES) && !defined(__DISABLE_EXPORTS)
struct kernel_symbol
{
diff --git a/include/linux/hidden.h b/include/linux/hidden.h
new file mode 100644
index 0000000000..49a17b6b59
--- /dev/null
+++ b/include/linux/hidden.h
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * When building position independent code with GCC using the -fPIC option,
+ * (or even the -fPIE one on older versions), it will assume that we are
+ * building a dynamic object (either a shared library or an executable) that
+ * may have symbol references that can only be resolved at load time. For a
+ * variety of reasons (ELF symbol preemption, the CoW footprint of the section
+ * that is modified by the loader), this results in all references to symbols
+ * with external linkage to go via entries in the Global Offset Table (GOT),
+ * which carries absolute addresses which need to be fixed up when the
+ * executable image is loaded at an offset which is different from its link
+ * time offset.
+ *
+ * Fortunately, there is a way to inform the compiler that such symbol
+ * references will be satisfied at link time rather than at load time, by
+ * giving them 'hidden' visibility.
+ */
+
+#pragma GCC visibility push(hidden)