[lld] [LLD] Add CLASS syntax to SECTIONS (PR #95323)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 13:31:33 PDT 2024
================
@@ -0,0 +1,432 @@
+# REQUIRES: x86
+
+# RUN: rm -rf %t && split-file %s %t && cd %t
+
+#--- matching.s
+.section .rodata.a,"a", at progbits
+.byte 1
+
+.section .rodata.b,"a", at progbits
+.byte 2
+
+.section .rodata.c,"ax", at progbits
+.byte 3
+
+.section .rodata.d,"a", at progbits
+.byte 4
+
+.section .rodata.e,"a", at progbits
+.byte 5
+
+.section .rodata.f,"a", at progbits
+.balign 2
+.byte 6
+
+.section .rodata.g,"a", at progbits
+.byte 7
+
+.section .rodata.h,"a", at progbits
+.byte 8
+
+# RUN: llvm-mc -n -filetype=obj -triple=x86_64 matching.s -o matching.o
+
+#--- matching.lds
+## CLASS definitions match sections in linker script order. The sections may be
+## placed in a different order. Classes may derive from one another. Class # #
+## references can be restricted by INPUT_SECTION_FLAGS. Classes can be referenced
+## in /DISCARD/ and INSERT.
+SECTIONS {
+ CLASS(a) { *(.rodata.a) }
+ CLASS(cd) { *(.rodata.c) *(.rodata.d) }
+ CLASS(ef) { *(SORT_BY_ALIGNMENT(.rodata.e .rodata.f)) }
+ CLASS(g) { *(.rodata.g) }
+ CLASS(h) { *(.rodata.h) }
+ .rodata : {
+ *(.rodata.*)
+ INPUT_SECTION_FLAGS(SHF_EXECINSTR) CLASS( cd)
+ CLASS(a)
----------------
MaskRay wrote:
Perhaps use `CLASS(a)CLASS(ef )` to show that the space is unneeded.
https://github.com/llvm/llvm-project/pull/95323
More information about the llvm-commits
mailing list