[lld] [lld][ELF] Introduce an option to keep data section prefix. (PR #148985)
Mingming Liu via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 23 12:24:36 PDT 2025
================
@@ -0,0 +1,127 @@
+# REQUIRES: x86
+## -z keep-data-section-prefix separates static data sections with prefix
+## .<section>.hot, .<section>.unlikely in the absence of a SECTIONS command.
+
+# RUN: rm -rf %t && split-file %s %t && cd %t
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
+
+# RUN: ld.lld a.o -o out1
+# RUN: llvm-readelf -S out1 | FileCheck --check-prefix=BASIC %s
+# RUN: ld.lld -z nokeep-text-section-prefix a.o -o out2
+# RUN: cmp out1 out2
+
+# RUN: ld.lld -z keep-data-section-prefix a.o -o out3
+# RUN: llvm-readelf -S out3 | FileCheck --check-prefix=KEEP %s
+
+## With a SECTIONS command, orphan sections are created verbatim.
+## No grouping is performed for them.
+# RUN: ld.lld -T x.lds -z keep-data-section-prefix a.o -o out4
+# RUN: llvm-readelf -S out4 | FileCheck --check-prefix=SCRIPT %s
+
+# BASIC: [Nr] Name Type Address Off Size
+# BASIC: [ 1] .text
+# BASIC-NEXT: [ 2] .data.rel.ro PROGBITS 00000000002021c9 0001c9 00000f
----------------
mingmingl-llvm wrote:
> The addresses are not useful. They could cause complexity when lld's address assignment changes
Got it. I replaced `Address` and `Off` columns with {{.*}} and kept `Size` column.
https://github.com/llvm/llvm-project/pull/148985
More information about the llvm-commits
mailing list