ARM assembly "retne" instruction ARM assembly "retne" instruction linux linux

ARM assembly "retne" instruction


The architectural assembly language is one thing, real world code is another. Once assembler pseudo-ops and macros come into play, a familiarity with both the toolchain and the codebase in question helps a lot. Linux is particularly nasty as much of the assembly source contains multiple layers of both assembler macros and CPP macros. If you know what to look for, and follow the header trail to arch/arm/include/asm/assembler.h, you eventually find this complicated beast:

.irp    c,,eq,ne,cs,cc,mi,pl,vs,vc,hi,ls,ge,lt,gt,le,hs,lo.macro  ret\c, reg#if __LINUX_ARM_ARCH__ < 6        mov\c   pc, \reg#else        .ifeqs  "\reg", "lr"        bx\c    \reg        .else        mov\c   pc, \reg        .endif#endif        .endm        .endr

The purpose of this is to emit the architecturally-preferred return instruction for the benefit of microarchitectures with a return stack, whilst allowing the same code to still compile for older architectures.