Skip to contentSkip to conversation

arm: set alignment properly for asm funcs

PATCH In review Sam Edwards 2 participants 2 messages May 13, 2023 – Jun 1, 2023 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm: set alignment properly for asm funcs

ARM requires a 4-byte alignment on all ARM code (though this requirement is relaxed to 2-byte for some THUMB code) and we should be explicit about that here.

GAS has its own fix for this[1] that forces proper alignment on any section containing assembled instructions, but this is not universal: Clang's and other gaslike assemblers lack this implicit alignment. Whether or not this is considered a bug in those assemblers, it is better to ask directly for what we want.

[1]: https://sourceware.org/bugzilla/show_bug.cgi?id=12931

---
 arch/arm/include/asm/linkage.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/include/asm/linkage.h +2 -2
index dbe4b4e31a..73bf25ba4e 100644
@@ -1,7 +1,7 @@
 #ifndef __ASM_LINKAGE_H
 #define __ASM_LINKAGE_H
 
-#define __ALIGN .align 0
-#define __ALIGN_STR ".align 0"
+#define __ALIGN .p2align 2
+#define __ALIGN_STR ".p2align 2"
 
 #endif
Signature · 1 line
2.39.2
#1 lore raw
Quoted 10 lines · Sam Edwards

ARM requires a 4-byte alignment on all ARM code (though this requirement is relaxed to 2-byte for some THUMB code) and we should be explicit about that here.

GAS has its own fix for this[1] that forces proper alignment on any section containing assembled instructions, but this is not universal: Clang's and other gaslike assemblers lack this implicit alignment. Whether or not this is considered a bug in those assemblers, it is better to ask directly for what we want.

Quoted 3 lines

[1]: https://sourceware.org/bugzilla/show_bug.cgi?id=12931

Applied to u-boot/next, thanks!

Signature · 1 line
Tom