[llvm] [AArch64][ELF] Section alignment of 4 for AArch64 instruction (PR #114031)
Sam Elliott via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 04:32:17 PDT 2024
================
@@ -697,6 +697,15 @@ bool ELFAsmParser::ParseSectionArguments(bool IsPush, SMLoc loc) {
getContext().getELFSection(SectionName, Type, Flags, Size, GroupName,
IsComdat, UniqueID, LinkedToSym);
getStreamer().switchSection(Section, Subsection);
+
+ // Section alignment of 4 if an AArch64 instruction is used when $x mapping
+ // symbol is added Match GNU Assembler
+ const Triple &TT = getContext().getTargetTriple();
+ if ((Section->getFlags() & ELF::SHF_EXECINSTR) && (TT.isAArch64())) {
+ if (Section->getAlign() < 4)
+ getStreamer().emitValueToAlignment(Align(4));
+ }
----------------
lenary wrote:
You don't need to do this in target-independent code - `MCStreamer::switchSection` will call `MCStreamer::changeSection` (the latter is `virtual`, and `AArch64ELFStreamer` has an override of it already, where you can add logic like this (Note this code is also handling the mapping symbols):
https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp#L191-L205
https://github.com/llvm/llvm-project/pull/114031
More information about the llvm-commits
mailing list