[lld] r277706 - [ELF] - Linkerscript: Fixed SORT_BY_ALIGNMENT sorting order.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 4 01:56:18 PDT 2016
Author: grimar
Date: Thu Aug 4 03:56:17 2016
New Revision: 277706
URL: http://llvm.org/viewvc/llvm-project?rev=277706&view=rev
Log:
[ELF] - Linkerscript: Fixed SORT_BY_ALIGNMENT sorting order.
According to spec:
"SORT_BY_ALIGNMENT will sort sections into descending order by
alignment before placing them in the output file"
Previously they were sorted into ascending order.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/linkerscript-sort-nested.s
lld/trunk/test/ELF/linkerscript/linkerscript-sort.s
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=277706&r1=277705&r2=277706&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Thu Aug 4 03:56:17 2016
@@ -136,14 +136,14 @@ template <class ELFT> struct SectionsSor
bool operator()(InputSectionBase<ELFT> *A, InputSectionBase<ELFT> *B) {
int AlignmentCmp = A->Alignment - B->Alignment;
if (Kind == SortKind::Align || (Kind == SortKind::AlignName && AlignmentCmp != 0))
- return AlignmentCmp < 0;
+ return AlignmentCmp > 0;
int NameCmp = A->getSectionName().compare(B->getSectionName());
if (Kind == SortKind::Name || (Kind == SortKind::NameAlign && NameCmp != 0))
return NameCmp < 0;
if (Kind == SortKind::NameAlign)
- return AlignmentCmp < 0;
+ return AlignmentCmp > 0;
if (Kind == SortKind::AlignName)
return NameCmp < 0;
Modified: lld/trunk/test/ELF/linkerscript/linkerscript-sort-nested.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/linkerscript-sort-nested.s?rev=277706&r1=277705&r2=277706&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/linkerscript-sort-nested.s (original)
+++ lld/trunk/test/ELF/linkerscript/linkerscript-sort-nested.s Thu Aug 4 03:56:17 2016
@@ -8,22 +8,20 @@
# RUN: ld.lld -o %t1 --script %t1.script %t1.o %t2.o
# RUN: llvm-objdump -s %t1 | FileCheck -check-prefix=SORTED_AN %s
# SORTED_AN: Contents of section .aaa:
-# SORTED_AN-NEXT: 0120 02000000 00000000 22000000 00000000
-# SORTED_AN-NEXT: 0130 11000000 00000000 00000000 00000000
-# SORTED_AN-NEXT: 0140 55000000 00000000 00000000 00000000
-# SORTED_AN-NEXT: 0150 00000000 00000000 00000000 00000000
-# SORTED_AN-NEXT: 0160 01000000 00000000
+# SORTED_AN-NEXT: 0120 01000000 00000000 00000000 00000000
+# SORTED_AN-NEXT: 0130 11000000 00000000 00000000 00000000
+# SORTED_AN-NEXT: 0140 55000000 00000000 22000000 00000000
+# SORTED_AN-NEXT: 0150 02000000 00000000
## Check sorting first by name and then by alignment.
# RUN: echo "SECTIONS { .aaa : { *(SORT_BY_NAME(SORT_BY_ALIGNMENT(.aaa.*))) } }" > %t2.script
# RUN: ld.lld -o %t2 --script %t2.script %t1.o %t2.o
# RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=SORTED_NA %s
-# SORTED_NA: Contents of section .aaa:
-# SORTED_NA-NEXT: 0120 11000000 00000000 00000000 00000000
-# SORTED_NA-NEXT: 0130 00000000 00000000 00000000 00000000
-# SORTED_NA-NEXT: 0140 01000000 00000000 02000000 00000000
-# SORTED_NA-NEXT: 0150 22000000 00000000 00000000 00000000
-# SORTED_NA-NEXT: 0160 55000000 00000000
+# SORTED_NA: Contents of section .aaa:
+# SORTED_NA: 01000000 00000000 00000000 00000000
+# SORTED_NA: 11000000 00000000 22000000 00000000
+# SORTED_NA: 02000000 00000000 00000000 00000000
+# SORTED_NA: 55000000 00000000
.global _start
_start:
Modified: lld/trunk/test/ELF/linkerscript/linkerscript-sort.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/linkerscript-sort.s?rev=277706&r1=277705&r2=277706&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/linkerscript-sort.s (original)
+++ lld/trunk/test/ELF/linkerscript/linkerscript-sort.s Thu Aug 4 03:56:17 2016
@@ -57,15 +57,14 @@
# RUN: ld.lld -o %t5 --script %t5.script %t1.o %t2.o
# RUN: llvm-objdump -s %t5 | FileCheck -check-prefix=SORTED_ALIGNMENT %s
# SORTED_ALIGNMENT: Contents of section .aaa:
-# SORTED_ALIGNMENT-NEXT: 0120 01000000 00000000 55000000 00000000
-# SORTED_ALIGNMENT-NEXT: 0130 02000000 00000000 44000000 00000000
-# SORTED_ALIGNMENT-NEXT: 0140 03000000 00000000 33000000 00000000
-# SORTED_ALIGNMENT-NEXT: 0150 04000000 00000000 00000000 00000000
-# SORTED_ALIGNMENT-NEXT: 0160 22000000 00000000 00000000 00000000
-# SORTED_ALIGNMENT-NEXT: 0170 00000000 00000000 00000000 00000000
-# SORTED_ALIGNMENT-NEXT: 0180 05000000 00000000 00000000 00000000
-# SORTED_ALIGNMENT-NEXT: 0190 00000000 00000000 00000000 00000000
-# SORTED_ALIGNMENT-NEXT: 01a0 11000000 00000000
+# SORTED_ALIGNMENT-NEXT: 0120 05000000 00000000 00000000 00000000
+# SORTED_ALIGNMENT-NEXT: 0130 00000000 00000000 00000000 00000000
+# SORTED_ALIGNMENT-NEXT: 0140 11000000 00000000 00000000 00000000
+# SORTED_ALIGNMENT-NEXT: 0150 04000000 00000000 00000000 00000000
+# SORTED_ALIGNMENT-NEXT: 0160 22000000 00000000 03000000 00000000
+# SORTED_ALIGNMENT-NEXT: 0170 33000000 00000000 02000000 00000000
+# SORTED_ALIGNMENT-NEXT: 0180 44000000 00000000 01000000 00000000
+# SORTED_ALIGNMENT-NEXT: 0190 55000000 00000000
.global _start
_start:
More information about the llvm-commits
mailing list