Skip to content

Commit a7ec177

Browse files
sparc32: Fix truncated relocation errors when linking large kernels
Use jumps instead of branches when jumping from one section to another to avoid branches to addresses further away than 22 bit offsets can handle that results in errors such as arch/sparc/kernel/signal_32.o:(.fixup+0x0): relocation truncated to fit: R_SPARC_WDISP22 against `.text' This is the same approach that was taken for sparc64 in commit 52eb053 ("[SPARC64]: Fix linkage of enormous kernels.") Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andreas Larsson <[email protected]>
1 parent e51f125 commit a7ec177

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

arch/sparc/include/asm/uaccess_32.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ __asm__ __volatile__( \
9595
".section .fixup,#alloc,#execinstr\n\t" \
9696
".align 4\n" \
9797
"3:\n\t" \
98-
"b 2b\n\t" \
98+
"sethi %%hi(2b), %0\n\t" \
99+
"jmpl %0 + %%lo(2b), %%g0\n\t" \
99100
" mov %3, %0\n\t" \
100101
".previous\n\n\t" \
101102
".section __ex_table,#alloc\n\t" \
@@ -163,8 +164,9 @@ __asm__ __volatile__( \
163164
".section .fixup,#alloc,#execinstr\n\t" \
164165
".align 4\n" \
165166
"3:\n\t" \
167+
"sethi %%hi(2b), %0\n\t" \
166168
"clr %1\n\t" \
167-
"b 2b\n\t" \
169+
"jmpl %0 + %%lo(2b), %%g0\n\t" \
168170
" mov %3, %0\n\n\t" \
169171
".previous\n\t" \
170172
".section __ex_table,#alloc\n\t" \

arch/sparc/kernel/head_32.S

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,12 @@ current_pc:
118118
mov %o7, %g3
119119

120120
tst %o0
121-
be no_sun4u_here
121+
bne 2f
122122
mov %g4, %o7 /* Previous %o7. */
123-
123+
sethi %hi(no_sun4u_here), %l1
124+
jmpl %l1 + %lo(no_sun4u_here), %g0
125+
nop
126+
2:
124127
mov %o0, %l0 ! stash away romvec
125128
mov %o0, %g7 ! put it here too
126129
mov %o1, %l1 ! stash away debug_vec too
@@ -195,7 +198,8 @@ halt_notsup:
195198
sub %o0, %l6, %o0
196199
call %o1
197200
nop
198-
ba halt_me
201+
sethi %hi(halt_me), %o0
202+
jmpl %o0 + %lo(halt_me), %g0
199203
nop
200204

201205
not_a_sun4:
@@ -431,8 +435,11 @@ leon_init:
431435
#ifdef CONFIG_SMP
432436
ldub [%g2 + %lo(boot_cpu_id)], %g1
433437
cmp %g1, 0xff ! unset means first CPU
434-
bne leon_smp_cpu_startup ! continue only with master
438+
be 1f
439+
sethi %hi(leon_smp_cpu_startup), %g1
440+
jmpl %g1 + %lo(leon_smp_cpu_startup), %g0
435441
nop
442+
1:
436443
#endif
437444
/* Get CPU-ID from most significant 4-bit of ASR17 */
438445
rd %asr17, %g1

0 commit comments

Comments
 (0)