[lld] r288022 - [ELF] - Do not put non exec sections first when -no-rosegment
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 28 02:26:22 PST 2016
Author: grimar
Date: Mon Nov 28 04:26:21 2016
New Revision: 288022
URL: http://llvm.org/viewvc/llvm-project?rev=288022&view=rev
Log:
[ELF] - Do not put non exec sections first when -no-rosegment
That unifies handling cases when we have SECTIONS and when
-no-rosegment is given in compareSectionsNonScript()
Now Config->SingleRoRx is used for check, testcase is provided.
Added:
lld/trunk/test/ELF/sort-norosegment.s
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=288022&r1=288021&r2=288022&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Nov 28 04:26:21 2016
@@ -492,12 +492,12 @@ static bool compareSectionsNonScript(con
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)
Added: lld/trunk/test/ELF/sort-norosegment.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/sort-norosegment.s?rev=288022&view=auto
==============================================================================
--- lld/trunk/test/ELF/sort-norosegment.s (added)
+++ lld/trunk/test/ELF/sort-norosegment.s Mon Nov 28 04:26:21 2016
@@ -0,0 +1,15 @@
+# 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
More information about the llvm-commits
mailing list