Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

MIPS: End asm function prologue macros with .insn

When building a kernel targeting a microMIPS ISA, recent GNU linkers
will fail the link if they cannot determine that the target of a branch
or jump is microMIPS code, with errors such as the following:

mips-img-linux-gnu-ld: arch/mips/built-in.o: .text+0x542c:
Unsupported jump between ISA modes; consider recompiling with
interlinking enabled.
mips-img-linux-gnu-ld: final link failed: Bad value

or:

./arch/mips/include/asm/uaccess.h:1017: warning: JALX to a
non-word-aligned address

Placing anything other than an instruction at the start of a function
written in assembly appears to trigger such errors. In order to prepare
for allowing us to follow function prologue macros with an EXPORT_SYMBOL
invocation, end the prologue macros (LEAD, NESTED & FEXPORT) with a
.insn directive. This ensures that the start of the function is marked
as code, which always makes sense for functions & safely prevents us
from hitting the link errors described above.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Reviewed-by: Maciej W. Rozycki <macro@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/14508/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>

authored by

Paul Burton and committed by
Ralf Baechle
08889582 2c0e57ea

+6 -4
+6 -4
arch/mips/include/asm/asm.h
··· 54 54 .align 2; \ 55 55 .type symbol, @function; \ 56 56 .ent symbol, 0; \ 57 - symbol: .frame sp, 0, ra 57 + symbol: .frame sp, 0, ra; \ 58 + .insn 58 59 59 60 /* 60 61 * NESTED - declare nested routine entry point ··· 64 63 .globl symbol; \ 65 64 .align 2; \ 66 65 .type symbol, @function; \ 67 - .ent symbol, 0; \ 68 - symbol: .frame sp, framesize, rpc 66 + .ent symbol, 0; \ 67 + symbol: .frame sp, framesize, rpc; \ 68 + .insn 69 69 70 70 /* 71 71 * END - mark end of function ··· 88 86 #define FEXPORT(symbol) \ 89 87 .globl symbol; \ 90 88 .type symbol, @function; \ 91 - symbol: 89 + symbol: .insn 92 90 93 91 /* 94 92 * ABS - export absolute symbol