[llvm] [AArch64][ELF] Section alignment of 4 for AArch64 instruction (PR #114031)

Sam Elliott via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 22 13:07:08 PST 2024


================
@@ -202,6 +202,12 @@ class AArch64ELFStreamer : public MCELFStreamer {
       LastEMS = EMS_None;
 
     MCELFStreamer::changeSection(Section, Subsection);
+
+    // Section alignment of 4 to match GNU Assembler
+    if ((Section->getAlign() < 4) && Section->isText()) {
+      Section->setAlignment(Align(4));
+      emitValueToAlignment(Align(4), 0, 1, 0);
----------------
lenary wrote:

Can you clarify why you need both the `setAlignment` on the section, and the `emitValueToAlignment` (which will insert bytes until the offset in the section is so aligned)

Am I missing when the latter is needed?

https://github.com/llvm/llvm-project/pull/114031


More information about the llvm-commits mailing list