From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 8/8] kallsyms: allow kallsyms data to reside in the .data section
Date: Fri, 13 Mar 2015 13:07:32 +0100 [thread overview]
Message-ID: <1426248452-4773-9-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1426248452-4773-1-git-send-email-ard.biesheuvel@linaro.org>
On architectures such as ARM, the default location of the kallsyms
data in the rodata section may be problematic, as it then sits right
between the .text and .init.text/.exit.text sections. This is usually
not a problem, but as soon as the code size exceeds a certain threshold,
the linker will start adding trampolines to ensure the two code regions
can reach each other through ordinary relative branches. This causes
inconsistencies between subsequent versions of the kallsyms data,
causing the build to fail.
This adds a Kconfig symbol that, when set, causes the kallsyms data
regions to be moved to the .data section instead, which works around
this problem.
Cc: linux-arch at vger.kernel.org
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
arch/arm/Kconfig | 1 +
include/asm-generic/vmlinux.lds.h | 12 +++++++++++-
init/Kconfig | 4 ++++
scripts/kallsyms.c | 2 +-
4 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9f1f09a2bc9b..639e215bd9a1 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -11,6 +11,7 @@ config ARM
select ARCH_USE_BUILTIN_BSWAP
select ARCH_USE_CMPXCHG_LOCKREF
select ARCH_WANT_IPC_PARSE_VERSION
+ select ARCH_HAVE_KALLSYMS_IN_DATA_SECTION
select BUILDTIME_EXTABLE_SORT if MMU
select CLONE_BACKWARDS
select CPU_PM if (SUSPEND || CPU_IDLE)
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 463231d5bfc7..09f93bfaad0e 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -150,6 +150,14 @@
#define TRACE_SYSCALLS()
#endif
+#ifdef CONFIG_ARCH_HAVE_KALLSYMS_IN_DATA_SECTION
+#define KALLSYMS_RODATA
+#define KALLSYMS_DATA *(.kallsyms_data)
+#else
+#define KALLSYMS_RODATA *(.kallsyms_data)
+#define KALLSYMS_DATA
+#endif
+
#define ___OF_TABLE(cfg, name) _OF_TABLE_##cfg(name)
#define __OF_TABLE(cfg, name) ___OF_TABLE(cfg, name)
@@ -197,7 +205,8 @@
LIKELY_PROFILE() \
BRANCH_PROFILE() \
TRACE_PRINTKS() \
- TRACEPOINT_STR()
+ TRACEPOINT_STR() \
+ KALLSYMS_DATA
/*
* Data section helpers
@@ -234,6 +243,7 @@
.rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
VMLINUX_SYMBOL(__start_rodata) = .; \
*(.rodata) *(.rodata.*) \
+ KALLSYMS_RODATA \
*(__vermagic) /* Kernel version magic */ \
. = ALIGN(8); \
VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
diff --git a/init/Kconfig b/init/Kconfig
index 058e3671fa11..d6f4920f3487 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1410,6 +1410,10 @@ config KALLSYMS_ALL
Say N unless you really need all symbols.
+config ARCH_HAVE_KALLSYMS_IN_DATA_SECTION
+ bool
+ depends on KALLSYMS
+
config PRINTK
default y
bool "Enable support for printk" if EXPERT
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index c6d33bd15b04..b23682a967e0 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -333,7 +333,7 @@ static void write_src(void)
printf("#define ALGN .align 4\n");
printf("#endif\n");
- printf("\t.section .rodata, \"a\"\n");
+ printf("\t.section .kallsyms_data, \"a\"\n");
/* Provide proper symbols relocatability by their '_text'
* relativeness. The symbol names cannot be used to construct
--
1.8.3.2
next prev parent reply other threads:[~2015-03-13 12:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-13 12:07 [PATCH v2 0/8] ARM kernel size fixes Ard Biesheuvel
2015-03-13 12:07 ` [PATCH v2 1/8] ARM: replace PROCINFO embedded branch with relative offset Ard Biesheuvel
2015-04-19 16:59 ` Joachim Eastwood
2015-04-19 17:08 ` Russell King - ARM Linux
2015-04-19 17:41 ` Ard Biesheuvel
2015-04-19 19:28 ` Russell King - ARM Linux
2015-04-19 19:45 ` Joachim Eastwood
2015-04-19 21:52 ` Ard Biesheuvel
2015-04-19 19:24 ` Joachim Eastwood
2015-03-13 12:07 ` [PATCH v2 2/8] ARM: move HYP text to end of .text section Ard Biesheuvel
2015-03-13 12:07 ` [PATCH v2 3/8] ARM: add macro to perform far branches (b/bl) Ard Biesheuvel
2015-03-13 16:40 ` Russell King - ARM Linux
2015-03-17 20:35 ` Ard Biesheuvel
2015-03-18 10:07 ` Ard Biesheuvel
2015-03-19 9:01 ` [PATCH] " Ard Biesheuvel
2015-03-13 12:07 ` [PATCH v2 4/8] ARM: use bl_far to call __hyp_stub_install_secondary from the .data section Ard Biesheuvel
2015-03-13 12:07 ` [PATCH v2 5/8] ARM: move the .idmap.text section closer to .head.text Ard Biesheuvel
2015-03-13 12:07 ` [PATCH v2 6/8] asm-generic: introduce .text.fixup input section Ard Biesheuvel
2015-03-18 18:58 ` Arnd Bergmann
2015-03-13 12:07 ` [PATCH v2 7/8] ARM: keep .text and .fixup regions together Ard Biesheuvel
2015-03-13 12:07 ` Ard Biesheuvel [this message]
2015-03-18 7:54 ` [PATCH v2 0/8] ARM kernel size fixes Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1426248452-4773-9-git-send-email-ard.biesheuvel@linaro.org \
--to=ard.biesheuvel@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).