[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 {
+ CLASS(c) { *(.rodata.earlier) }
----------------
mysterymath wrote:
Yes, any syntax that can be used inside an output section description can be used in a section class description. `CLASS` references are more limited; it's not presently possible to e.g. change the `SORT` ordering at point of reference from that of the class's definition or add `EXCLUDE_FILE`, since LLD currently only accepts these inside of the parenthesized wildcard section, and there's nothing analogous for class references. (We may be able to invent some syntax for this kind of thing though.)
You can still use `INPUT_SECTION_FLAGS`, since that appears outside input section descriptions.
https://github.com/llvm/llvm-project/pull/95323
More information about the llvm-commits
mailing list