[lld] [LLD] Add CLASS syntax to SECTIONS (PR #95323)

Daniel Thornburgh via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 15:13:38 PDT 2024


================
@@ -198,13 +198,52 @@ the current location to a max-page-size boundary, ensuring that the next
 LLD will insert ``.relro_padding`` immediately before the symbol assignment
 using ``DATA_SEGMENT_RELRO_END``.
 
+Section Classes
+~~~~~~~~~~~~~~~
+
+``SECTIONS`` commands can define classes of input sections:
+
+::
+
+  SECTIONS {
+    CLASS(class_name) {
+      input-section-description
+      input-section-description
+      ...
+    }
+  }
+
+Input section descriptions can refer to a class using ``CLASS(class_name)``
+instead of the usual filename and section name patterns. For example:
+
+::
+
+  SECTIONS {
+    CLASS(c) { *(.rodata.earlier) }
+    .rodata { *(.rodata) CLASS(c) (*.rodata.later) }
----------------
mysterymath wrote:

The comment stands; I'd tend defer to @MaskRay about LLD's policy about possibly changing the interpretation of preexisting linker scripts, and how the likelihood of that weighs in. The various matching modifiers all tend to take the form `<keyword>(<arguments>)`, so it seems desirable to keep that syntax, but `CLASS` may also be riskier as a filename than others, since it's a short common term.

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


More information about the llvm-commits mailing list