[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) {
+ 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 {
----------------
mysterymath wrote:
I didn't have a particular practical reason to spell them inside `SECTIONS`, just one in terms of mental models. (Well, it's *really* that this design was cribbed wholesale from Roland, but I do agree with it.) `SECTIONS` naturally namespaces `CLASS`, and class definitions seem more like symbol assignments, `ENTRY`, output section descriptions, and `OVERLAY` than they do the other top level objects (`MEMORY`, `PHDR`, and `VERSION`). There's also a natural analogy between output sections and class definitions, and most output sections are defined in `SECTIONS`.
https://github.com/llvm/llvm-project/pull/95323
More information about the llvm-commits
mailing list