diff options
author | George Rimar <grimar@accesssoftek.com> | 2018-03-08 15:06:58 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2018-03-08 15:06:58 +0000 |
commit | 1136ec64e86973dc9f3b0da528d752029dc33731 (patch) | |
tree | 7e08387b924e29f25800a5dd52b57755a1f58fc4 /lld/ELF/OutputSections.cpp | |
parent | 6d1aec126078d75d8fe6971d6b62a376c6d1de1a (diff) | |
download | bcm5719-llvm-1136ec64e86973dc9f3b0da528d752029dc33731.tar.gz bcm5719-llvm-1136ec64e86973dc9f3b0da528d752029dc33731.zip |
[ELF] - Fix crash relative to SHF_LINK_ORDER sections.
Our code assumes all input sections in an output SHF_LINK_ORDER
section has SHF_LINK_ORDER flag. We do not check that and that can cause a crash.
That happens because we call
std::stable_sort(Sections.begin(), Sections.end(), compareByFilePosition);,
where compareByFilePosition predicate does not expect to see
null when calls getLinkOrderDep.
The same might happen when sections refer to non-regular sections.
Test cases demonstrate the issues, patch fixes them.
Differential revision: https://reviews.llvm.org/D44193
llvm-svn: 327006
Diffstat (limited to 'lld/ELF/OutputSections.cpp')
-rw-r--r-- | lld/ELF/OutputSections.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 8f29b291b39..1d03c56ebaf 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -98,7 +98,8 @@ void OutputSection::addSection(InputSection *IS) { Flags = IS->Flags; } else { // Otherwise, check if new type or flags are compatible with existing ones. - if ((Flags & (SHF_ALLOC | SHF_TLS)) != (IS->Flags & (SHF_ALLOC | SHF_TLS))) + unsigned Mask = SHF_ALLOC | SHF_TLS | SHF_LINK_ORDER; + if ((Flags & Mask) != (IS->Flags & Mask)) error("incompatible section flags for " + Name + "\n>>> " + toString(IS) + ": 0x" + utohexstr(IS->Flags) + "\n>>> output section " + Name + ": 0x" + utohexstr(Flags)); |