if (AIsWritable != BIsWritable)
return BIsWritable;
- if (!ScriptConfig->HasSections) {
+ if (!Config->SingleRoRx) {
// For a corresponding reason, put non exec sections first (the program
// header PT_LOAD is not executable).
// We only do that if we are not using linker scripts, since with linker
// scripts ro and rx sections are in the same PT_LOAD, so their relative
- // order is not important.
+ // order is not important. The same applies for -no-rosegment.
bool AIsExec = A->Flags & SHF_EXECINSTR;
bool BIsExec = B->Flags & SHF_EXECINSTR;
if (AIsExec != BIsExec)
--- /dev/null
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t
+
+# RUN: ld.lld -no-rosegment -o %t1 %t -shared
+# RUN: llvm-readobj -elf-output-style=GNU -s %t1 | FileCheck %s
+
+# CHECK: .text {{.*}} AX
+# CHECK-NEXT: .dynsym {{.*}} A
+# CHECK-NEXT: .hash {{.*}} A
+# CHECK-NEXT: .dynstr {{.*}} A
+# CHECK-NEXT: .dynamic {{.*}} WA
+# CHECK-NEXT: foo {{.*}} WA
+
+.section foo, "aw"
+.byte 0