[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:39 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) {
----------------
mysterymath wrote:

Classes can be referenced within an overlay, but I'm not sure it makes sense to define one there. The analogy between classes and output sections breaks down there: there's a specific relationship between the container (the overlay) and the output sections contained within, but there would be no such relationship with the classes. I hadn't allowed for class definition in `OVERWRITE_SECTIONS` for the same reason. In both cases it would require some data structure generalization, too.

There's definitely an orthogonality argument to always being able to write output section descriptions and class descriptions in the same contexts, but I'm still left with a slight preference to only allow them in the relatively agnostic `SECTIONS` context.

I had also forgotten to add a test for class references in `OVERLAY`, and it was broken. Added a test and fixed.

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


More information about the llvm-commits mailing list