diff options
author | Marvin Häuser <mhaeuser@posteo.de> | 2023-04-20 15:24:14 +0000 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2023-04-20 16:20:35 +0000 |
commit | f433fa59d22480f3ae60ea29e98a6b33227cbd7a (patch) | |
tree | ea69135116fa45655fba03b47072bca6764be3f4 /ArmPkg | |
parent | e3d2c08322bc61e9c5b87b3c282dd2af3d52aec6 (diff) | |
download | edk2-f433fa59d22480f3ae60ea29e98a6b33227cbd7a.tar.gz edk2-f433fa59d22480f3ae60ea29e98a6b33227cbd7a.tar.bz2 edk2-f433fa59d22480f3ae60ea29e98a6b33227cbd7a.zip |
ArmPkg/AsmMacroIoLibV8: Introduce ASM_FUNC_ALIGN()
With the current ASM_FUNC() macro, there is no good way to declare an
alignment constraint for a function. As ASM_FUNC() switches sections,
declaring the constraint before the macro invocation applies it to the
current location in the previous section. Declaring the constraint after
the macro invocation lets the function label point to the location prior
to alignment. Depending on toolchain behaviour, this may cause the label
to point to alignment padding preceding the actual function definition.
To address these issues, introduce the ASM_FUNC_ALIGN() macro, which
declares the alignment constraint right before the function label.
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'ArmPkg')
-rw-r--r-- | ArmPkg/Include/AsmMacroIoLibV8.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ArmPkg/Include/AsmMacroIoLibV8.h b/ArmPkg/Include/AsmMacroIoLibV8.h index 135aaeca5d..81164ea9c9 100644 --- a/ArmPkg/Include/AsmMacroIoLibV8.h +++ b/ArmPkg/Include/AsmMacroIoLibV8.h @@ -41,8 +41,19 @@ Name: ; \
AARCH64_BTI(c)
+#define _ASM_FUNC_ALIGN(Name, Section, Align) \
+ .global Name ; \
+ .section #Section, "ax" ; \
+ .type Name, %function ; \
+ .balign Align ; \
+ Name: ; \
+ AARCH64_BTI(c)
+
#define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name)
+#define ASM_FUNC_ALIGN(Name, Align) \
+ _ASM_FUNC_ALIGN(ASM_PFX(Name), .text. ## Name, Align)
+
#define MOV32(Reg, Val) \
movz Reg, (Val) >> 16, lsl #16 ; \
movk Reg, (Val) & 0xffff
|