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

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 11:42:29 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:
----------------
smithp35 wrote:

I think the intention is that CLASS can only refer to one class_name. If multiple classes are needed they would need to be given sequentially.
```
.rodata { *(.rodata) CLASS(c) CLASS(d) (*.rodata.later) }
```

As opposed to `CLASS(c d)` as someone might write thinking that they can combine classes. Will be worth adding a test case to check the error messages from doing something like `CLASS(c d)` are sensible.

Could be worth mentioning in the doc that only one class can be referenced, although it should be obvious from the singular `class_name`

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


More information about the llvm-commits mailing list