Skip to content

Commit 200036a

Browse files
committed
parisc: Allow building 64-bit kernel without -mlong-calls compiler option
A 64-bit kernel built without CONFIG_MLONGCALLS (-mlong-calls compiler option) usually fails to link because of unreachable functions. Try to work around that linking issue by moving the *.init and *.exit text segments closer to the main text segment. With that change those segments now don't get freed at runtime any longer, but since we in most cases run with huge-page enabled, we ignore the lost memory in preference of better performance. This change will not guarantee that every kernel config will now sucessfully build with short calls and without linking issues. Signed-off-by: Helge Deller <deller@gmx.de>
1 parent 7a95aab commit 200036a

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

‎arch/parisc/Kconfig‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ config PREFETCH
194194

195195
config MLONGCALLS
196196
bool "Enable the -mlong-calls compiler option for big kernels"
197-
default y
197+
default y if !MODULES || UBSAN || FTRACE
198+
default n
198199
depends on PA8X00
199200
help
200201
If you configure the kernel to include many drivers built-in instead

‎arch/parisc/kernel/vmlinux.lds.S‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ OUTPUT_FORMAT("elf64-hppa-linux")
3535
OUTPUT_ARCH(hppa:hppa2.0w)
3636
#endif
3737

38+
#define EXIT_TEXT_SECTIONS() .exit.text : { EXIT_TEXT }
39+
#if !defined(CONFIG_64BIT) || defined(CONFIG_MLONGCALLS)
40+
#define MLONGCALL_KEEP(x)
41+
#define MLONGCALL_DISCARD(x) x
42+
#else
43+
#define MLONGCALL_KEEP(x) x
44+
#define MLONGCALL_DISCARD(x)
45+
#endif
46+
3847
ENTRY(parisc_kernel_start)
3948
#ifndef CONFIG_64BIT
4049
jiffies = jiffies_64 + 4;
@@ -47,15 +56,11 @@ SECTIONS
4756

4857
__init_begin = .;
4958
HEAD_TEXT_SECTION
50-
INIT_TEXT_SECTION(8)
59+
MLONGCALL_DISCARD(INIT_TEXT_SECTION(8))
5160

5261
. = ALIGN(PAGE_SIZE);
5362
INIT_DATA_SECTION(PAGE_SIZE)
54-
/* we have to discard exit text and such at runtime, not link time */
55-
.exit.text :
56-
{
57-
EXIT_TEXT
58-
}
63+
MLONGCALL_DISCARD(EXIT_TEXT_SECTIONS())
5964
.exit.data :
6065
{
6166
EXIT_DATA
@@ -73,11 +78,12 @@ SECTIONS
7378

7479
_text = .; /* Text and read-only data */
7580
_stext = .;
81+
MLONGCALL_KEEP(INIT_TEXT_SECTION(8))
7682
.text ALIGN(PAGE_SIZE) : {
7783
TEXT_TEXT
84+
LOCK_TEXT
7885
SCHED_TEXT
7986
CPUIDLE_TEXT
80-
LOCK_TEXT
8187
KPROBES_TEXT
8288
IRQENTRY_TEXT
8389
SOFTIRQENTRY_TEXT
@@ -92,6 +98,7 @@ SECTIONS
9298
*(.lock.text) /* out-of-line lock text */
9399
*(.gnu.warning)
94100
}
101+
MLONGCALL_KEEP(EXIT_TEXT_SECTIONS())
95102
. = ALIGN(PAGE_SIZE);
96103
_etext = .;
97104
/* End of text section */

0 commit comments

Comments
 (0)