From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout01.posteo.de (mout01.posteo.de [185.67.36.65]) by mx.groups.io with SMTP id smtpd.web10.10082.1681767699337391198 for ; Mon, 17 Apr 2023 14:41:40 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@posteo.de header.s=2017 header.b=SfNdOAGo; spf=pass (domain: posteo.de, ip: 185.67.36.65, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 97A4B2401D9 for ; Mon, 17 Apr 2023 23:41:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1681767697; bh=t7YIoyVYiU2uE98SZKRAM0k8FBmEexGNtnV4su989OI=; h=From:To:Cc:Subject:Date:From; b=SfNdOAGo/c41W0jtnH6oBXkEHPgqENhmsz7C2g+x432HXNMOvouXWKbP/XX5CxUYg OwEqxNayoHlc7MKt+lL+wAWOAN1rmGDkxrLI67gm3gOB/qiVaH/Kn6VzlM6GWt/XLk hG3Ni5fkGHUNmJDYTMGascFtkyH+yZGmQuznCl//xDMnO5desoGgh/aTBwKsg6Y+W6 +A/zl9ydpHVzJalgaRcWMg012qyZQWNFSq2H61X0n8DSpCTY1UmlrTPOfdNWWiRZ7k sVbfD6WugZsdYSvDFc6Vb0hBRFGUu9PAajgMXB/eeKu3fYTMhlD3J0WKJ6GfgGuQol UUCPz2h/MBokQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Q0gVS4xPqz6tsj; Mon, 17 Apr 2023 23:41:36 +0200 (CEST) From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20Ha=CC=88user?= , Leif Lindholm , Ard Biesheuvel , Sami Mujawar , Vitaly Cheptsov Subject: [PATCH v2 1/2] ArmPkg/AsmMacroIoLibV8: Introduce ASM_FUNC_ALIGN() Date: Mon, 17 Apr 2023 21:41:25 +0000 Message-Id: <20230417214126.46767-1-mhaeuser@posteo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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=C3=A4user Cc: Leif Lindholm Cc: Ard Biesheuvel Cc: Sami Mujawar Cc: Vitaly Cheptsov --- ArmPkg/Include/AsmMacroIoLibV8.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ArmPkg/Include/AsmMacroIoLibV8.h b/ArmPkg/Include/AsmMacroIo= LibV8.h index 135aaeca5d0b..81164ea9c9e7 100644 --- a/ArmPkg/Include/AsmMacroIoLibV8.h +++ b/ArmPkg/Include/AsmMacroIoLibV8.h @@ -41,8 +41,19 @@ Name: ; \ AARCH64_BTI(c) =20 +#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) =20 +#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 --=20 2.40.0