* [PATCH 2/2] ArmPkg/AsmMacroIoLib: force word alignment for functions
@ 2016-09-13 17:27 Ard Biesheuvel
2016-09-13 17:45 ` Andrew Fish
0 siblings, 1 reply; 4+ messages in thread
From: Ard Biesheuvel @ 2016-09-13 17:27 UTC (permalink / raw)
To: edk2-devel, leif.lindholm; +Cc: Ard Biesheuvel
Without an explicit .align directive, the Clang assembler defaults to
no alignment, which may result in instructions appearing misaligned in
the final executable. So use word alignment in all cases.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmPkg/Include/AsmMacroIoLib.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/ArmPkg/Include/AsmMacroIoLib.h
index fb73ea9a4694..5e4de1f269c8 100644
--- a/ArmPkg/Include/AsmMacroIoLib.h
+++ b/ArmPkg/Include/AsmMacroIoLib.h
@@ -56,6 +56,7 @@
.global Name ; \
.section #Section, "ax" ; \
.type Name, %function ; \
+ .align 2 ; \
Name:
#define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name)
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] ArmPkg/AsmMacroIoLib: force word alignment for functions
2016-09-13 17:27 [PATCH 2/2] ArmPkg/AsmMacroIoLib: force word alignment for functions Ard Biesheuvel
@ 2016-09-13 17:45 ` Andrew Fish
2016-09-13 17:49 ` Ard Biesheuvel
0 siblings, 1 reply; 4+ messages in thread
From: Andrew Fish @ 2016-09-13 17:45 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel, leif.lindholm
> On Sep 13, 2016, at 10:27 AM, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
> Without an explicit .align directive, the Clang assembler defaults to
> no alignment, which may result in instructions appearing misaligned in
> the final executable. So use word alignment in all cases.
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmPkg/Include/AsmMacroIoLib.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/ArmPkg/Include/AsmMacroIoLib.h
> index fb73ea9a4694..5e4de1f269c8 100644
> --- a/ArmPkg/Include/AsmMacroIoLib.h
> +++ b/ArmPkg/Include/AsmMacroIoLib.h
> @@ -56,6 +56,7 @@
> .global Name ; \
> .section #Section, "ax" ; \
> .type Name, %function ; \
> + .align 2 ; \
Ard,
I've been burned in the past by as .align is bytes or power of 2 based on what the native assembler defaults to (over simplification). I'm not sure if that issues exists in the ARM world?
Thanks,
Andrew Fish
> Name:
>
> #define ASM_FUNC(Name) _ASM_FUNC(ASM_PFX(Name), .text. ## Name)
> --
> 2.7.4
>
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] ArmPkg/AsmMacroIoLib: force word alignment for functions
2016-09-13 17:45 ` Andrew Fish
@ 2016-09-13 17:49 ` Ard Biesheuvel
2016-09-13 17:52 ` Andrew Fish
0 siblings, 1 reply; 4+ messages in thread
From: Ard Biesheuvel @ 2016-09-13 17:49 UTC (permalink / raw)
To: Andrew Fish; +Cc: edk2-devel-01, Leif Lindholm
On 13 September 2016 at 18:45, Andrew Fish <afish@apple.com> wrote:
>
>> On Sep 13, 2016, at 10:27 AM, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>>
>> Without an explicit .align directive, the Clang assembler defaults to
>> no alignment, which may result in instructions appearing misaligned in
>> the final executable. So use word alignment in all cases.
>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>> ---
>> ArmPkg/Include/AsmMacroIoLib.h | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/ArmPkg/Include/AsmMacroIoLib.h
>> index fb73ea9a4694..5e4de1f269c8 100644
>> --- a/ArmPkg/Include/AsmMacroIoLib.h
>> +++ b/ArmPkg/Include/AsmMacroIoLib.h
>> @@ -56,6 +56,7 @@
>> .global Name ; \
>> .section #Section, "ax" ; \
>> .type Name, %function ; \
>> + .align 2 ; \
>
> Ard,
>
> I've been burned in the past by as .align is bytes or power of 2 based on what the native assembler defaults to (over simplification). I'm not sure if that issues exists in the ARM world?
>
The GNU assembler for ARM interprets this as power-of-2, and so does
Clang, according to my testing. Both support the .p2align directive as
well, which makes it 100% unambiguous, so I suppose I could use that
instead.
--
Ard.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] ArmPkg/AsmMacroIoLib: force word alignment for functions
2016-09-13 17:49 ` Ard Biesheuvel
@ 2016-09-13 17:52 ` Andrew Fish
0 siblings, 0 replies; 4+ messages in thread
From: Andrew Fish @ 2016-09-13 17:52 UTC (permalink / raw)
To: Ard Biesheuvel; +Cc: edk2-devel-01, Leif Lindholm
> On Sep 13, 2016, at 10:49 AM, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
> On 13 September 2016 at 18:45, Andrew Fish <afish@apple.com> wrote:
>>
>>> On Sep 13, 2016, at 10:27 AM, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>>>
>>> Without an explicit .align directive, the Clang assembler defaults to
>>> no alignment, which may result in instructions appearing misaligned in
>>> the final executable. So use word alignment in all cases.
>>>
>>> Contributed-under: TianoCore Contribution Agreement 1.0
>>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>>> ---
>>> ArmPkg/Include/AsmMacroIoLib.h | 1 +
>>> 1 file changed, 1 insertion(+)
>>>
>>> diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/ArmPkg/Include/AsmMacroIoLib.h
>>> index fb73ea9a4694..5e4de1f269c8 100644
>>> --- a/ArmPkg/Include/AsmMacroIoLib.h
>>> +++ b/ArmPkg/Include/AsmMacroIoLib.h
>>> @@ -56,6 +56,7 @@
>>> .global Name ; \
>>> .section #Section, "ax" ; \
>>> .type Name, %function ; \
>>> + .align 2 ; \
>>
>> Ard,
>>
>> I've been burned in the past by as .align is bytes or power of 2 based on what the native assembler defaults to (over simplification). I'm not sure if that issues exists in the ARM world?
>>
>
> The GNU assembler for ARM interprets this as power-of-2, and so does
> Clang, according to my testing. Both support the .p2align directive as
> well, which makes it 100% unambiguous, so I suppose I could use that
> instead.
>
I think all my pain has been the inconsistency on i386/IA32, but it left a mark. :).
Thanks,
Andrew Fish
> --
> Ard.
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-09-13 17:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-13 17:27 [PATCH 2/2] ArmPkg/AsmMacroIoLib: force word alignment for functions Ard Biesheuvel
2016-09-13 17:45 ` Andrew Fish
2016-09-13 17:49 ` Ard Biesheuvel
2016-09-13 17:52 ` Andrew Fish
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox