ARM uses the low order bit of a branch target address to decide in
which execution mode (ARM or Thumb) a function needs to be called.
In order for this to work across object files, ELF function symbols
will have the low bit set if they were emitted in Thumb mode and
cleared otherwise. This annotation is only emitted if the ELF symbols
are annotated as function, since taking the address of some data
symbol (e.g., a literal) should not produce a value with the low bit
set, even if it appears in an object file containing Thumb code.
This means that all functions coded in assembler must have this
function annotation, or they may end up getting called in the
wrong mode, crashing the program.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>
.thumb\r
.syntax unified\r
.align 5\r
.thumb\r
.syntax unified\r
.align 5\r
+ .type ASM_PFX(InternalMemCompareGuid), %function\r
ASM_GLOBAL ASM_PFX(InternalMemCompareGuid)\r
ASM_PFX(InternalMemCompareGuid):\r
push {r4, lr}\r
ASM_GLOBAL ASM_PFX(InternalMemCompareGuid)\r
ASM_PFX(InternalMemCompareGuid):\r
push {r4, lr}\r
.thumb\r
.syntax unified\r
.align 5\r
.thumb\r
.syntax unified\r
.align 5\r
+ .type ASM_PFX(InternalMemCompareMem), %function\r
ASM_GLOBAL ASM_PFX(InternalMemCompareMem)\r
ASM_PFX(InternalMemCompareMem):\r
push {r4-r8, lr}\r
ASM_GLOBAL ASM_PFX(InternalMemCompareMem)\r
ASM_PFX(InternalMemCompareMem):\r
push {r4-r8, lr}\r
IN UINTN Length\r
)\r
**/\r
IN UINTN Length\r
)\r
**/\r
+ .type ASM_PFX(InternalMemCopyMem), %function\r
ASM_GLOBAL ASM_PFX(InternalMemCopyMem)\r
ASM_PFX(InternalMemCopyMem):\r
push {r4-r11, lr}\r
ASM_GLOBAL ASM_PFX(InternalMemCopyMem)\r
ASM_PFX(InternalMemCopyMem):\r
push {r4-r11, lr}\r
.thumb\r
.syntax unified\r
.align 5\r
.thumb\r
.syntax unified\r
.align 5\r
+ .type ASM_PFX(InternalMemSetMem16), %function\r
ASM_GLOBAL ASM_PFX(InternalMemSetMem16)\r
ASM_PFX(InternalMemSetMem16):\r
uxth r2, r2\r
ASM_GLOBAL ASM_PFX(InternalMemSetMem16)\r
ASM_PFX(InternalMemSetMem16):\r
uxth r2, r2\r
orr r2, r2, r2, lsl #16\r
b 0f\r
\r
orr r2, r2, r2, lsl #16\r
b 0f\r
\r
+ .type ASM_PFX(InternalMemSetMem32), %function\r
ASM_GLOBAL ASM_PFX(InternalMemSetMem32)\r
ASM_PFX(InternalMemSetMem32):\r
lsl r1, r1, #2\r
b 0f\r
\r
ASM_GLOBAL ASM_PFX(InternalMemSetMem32)\r
ASM_PFX(InternalMemSetMem32):\r
lsl r1, r1, #2\r
b 0f\r
\r
+ .type ASM_PFX(InternalMemSetMem64), %function\r
ASM_GLOBAL ASM_PFX(InternalMemSetMem64)\r
ASM_PFX(InternalMemSetMem64):\r
lsl r1, r1, #3\r
b 1f\r
\r
.align 5\r
ASM_GLOBAL ASM_PFX(InternalMemSetMem64)\r
ASM_PFX(InternalMemSetMem64):\r
lsl r1, r1, #3\r
b 1f\r
\r
.align 5\r
+ .type ASM_PFX(InternalMemSetMem), %function\r
ASM_GLOBAL ASM_PFX(InternalMemSetMem)\r
ASM_PFX(InternalMemSetMem):\r
uxtb r2, r2\r
ASM_GLOBAL ASM_PFX(InternalMemSetMem)\r
ASM_PFX(InternalMemSetMem):\r
uxtb r2, r2\r
orr r2, r2, r2, lsl #16\r
b 0f\r
\r
orr r2, r2, r2, lsl #16\r
b 0f\r
\r
+ .type ASM_PFX(InternalMemZeroMem), %function\r
ASM_GLOBAL ASM_PFX(InternalMemZeroMem)\r
ASM_PFX(InternalMemZeroMem):\r
movs r2, #0\r
ASM_GLOBAL ASM_PFX(InternalMemZeroMem)\r
ASM_PFX(InternalMemZeroMem):\r
movs r2, #0\r