While .align 0 may be converted to .balign 1 for x86_64 elf, on THUMB2
it's converted to .balign 4.
pr/51929.
Link: https://github.com/ClangBuiltLinux/linux/issues/1447
Differential D110660
[AsmParser] handle .align 0 per MCAsmInfo nickdesaulniers on Sep 28 2021, 2:36 PM. Authored by
Details While .align 0 may be converted to .balign 1 for x86_64 elf, on THUMB2 pr/51929.
Diff Detail
Unit Tests Event TimelineComment Actions Hey @peter.smith , I'm not sure if you have cycles to look at this, but I could use some help. I've been trying to understand why the fragments created seem to have an offset of zero (I suspect the offset should be 2B into the function?) but I don't quite understand the fragment layout process very well. The added test case is failing on the Size: check; GAS passes this test.
Comment Actions ARMAsmParser::parseDirectiveAlign falls back to AsmParser::parseDirectiveAlign, which doesn't handle .align 0 correctly for THUMB. Comment Actions (oh, this is actually good enough to fix pr/51929). Maybe I can add a fixme to the test on the Size noting that GAS adds explicit nops. We don't necessarily need the nops; we need to not treat .align 0 as .align 1 on THUMB2 (and probably ARM; unverified).
Comment Actions
Does gas do so? This is a surprising behavior. I hope we don't follow. The user should be fixed instead. https://sourceware.org/binutils/docs/as/Align.html#Align says a default value is used. If thumb typically uses 2-byte alignment, .align 0 meaning .balign 4 seems unexpected. Comment Actions I really don't want to see that MC adopts such a behavior. I will disappear for a few days and be back next ~Wednesday. Comment Actions I don't disagree. It looks like the 32b ARM linux kernel is using .align 0 by default for all symbol descriptions; I think changing it to .align 2 (to match aarch64) would be NFC for GAS and fix the underlying THUMB2 related boot failure for clang. Let me submit such a patch on the kernel side for comment+review. Thanks for the feedback. |
Why not make Alignment a reference?