[llvm-branch-commits] MC: Add ELF section and directive for specifying a section's preferred alignment. (PR #150151)

Peter Collingbourne via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jul 22 18:30:21 PDT 2025


https://github.com/pcc created https://github.com/llvm/llvm-project/pull/150151

The new ``SHT_LLVM_MIN_ADDRALIGN`` section is used to specify the
minimum alignment of a section where that differs from its preferred
alignment. Its ``sh_link`` field identifies the section whose alignment is
being specified, its ``sh_addralign`` field specifies the linked section's
minimum alignment and the ``sh_addralign`` field of the linked section's
section header specifies its preferred alignment. This section has the
``SHF_EXCLUDE`` flag so that it is stripped from the final executable or
shared library, and the ``SHF_LINK_ORDER`` flag so that the ``sh_link``
field is updated by tools such as ``ld -r`` and ``objcopy``. The contents
of the section must be empty.

The new asm directive:

.prefalign n

specifies that the preferred alignment of the current section is
determined by taking the maximum of ``n`` and the section's minimum
alignment, and causes an ``SHT_LLVM_MIN_ADDRALIGN`` section to be emitted
if necessary.





More information about the llvm-branch-commits mailing list