summaryrefslogtreecommitdiffstats
path: root/lld/ELF/ICF.cpp
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2016-08-22 18:53:09 +0000
committerPetr Hosek <phosek@chromium.org>2016-08-22 18:53:09 +0000
commit901948a205cc215801f07b7643ad682842256aa8 (patch)
tree14be06581afad514df02f6d29d00821d0efa5887 /lld/ELF/ICF.cpp
parentbee2f41fac8384c052b20b116dea091b00b20aec (diff)
downloadbcm5719-llvm-901948a205cc215801f07b7643ad682842256aa8.tar.gz
bcm5719-llvm-901948a205cc215801f07b7643ad682842256aa8.zip
[ELF] ICF should respect section alignment
When performing ICF, we have to respect the alignment requirement of each section within each group. Differential Revision: https://reviews.llvm.org/D23732 llvm-svn: 279456
Diffstat (limited to 'lld/ELF/ICF.cpp')
-rw-r--r--lld/ELF/ICF.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp
index 10a2603b3b3..209cf20439c 100644
--- a/lld/ELF/ICF.cpp
+++ b/lld/ELF/ICF.cpp
@@ -302,7 +302,11 @@ template <class ELFT> void ICF<ELFT>::run() {
// the same group are consecutive in the vector.
std::stable_sort(V.begin(), V.end(),
[](InputSection<ELFT> *A, InputSection<ELFT> *B) {
- return A->GroupId < B->GroupId;
+ if (A->GroupId != B->GroupId)
+ return A->GroupId < B->GroupId;
+ // Within a group, put the highest alignment
+ // requirement first, so that's the one we'll keep.
+ return B->Alignment < A->Alignment;
});
// Compare static contents and assign unique IDs for each static content.
OpenPOWER on IntegriCloud