[lld] r363026 - ELF: Don't process the partition end marker during combineEhSections().
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 10 19:54:30 PDT 2019
Author: pcc
Date: Mon Jun 10 19:54:30 2019
New Revision: 363026
URL: http://llvm.org/viewvc/llvm-project?rev=363026&view=rev
Log:
ELF: Don't process the partition end marker during combineEhSections().
Otherwise the getPartition() accessor may return an OOB pointer. Found
using _GLIBCXX_DEBUG.
The error is benign (we never dereference the pointer for the end marker)
so this wasn't caught by e.g. the sanitizer bots.
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=363026&r1=363025&r2=363026&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Mon Jun 10 19:54:30 2019
@@ -178,7 +178,9 @@ template <class ELFT> static void copySe
template <class ELFT> static void combineEhSections() {
for (InputSectionBase *&S : InputSections) {
- if (!S->isLive())
+ // Ignore dead sections and the partition end marker (.part.end),
+ // whose partition number is out of bounds.
+ if (!S->isLive() || S->Partition == 255)
continue;
Partition &Part = S->getPartition();
@@ -442,7 +444,7 @@ template <class ELFT> static void create
if (Partitions.size() != 1) {
// Create the partition end marker. This needs to be in partition number 255
// so that it is sorted after all other partitions. It also has other
- // special handling (see createPhdrs()).
+ // special handling (see createPhdrs() and combineEhSections()).
In.PartEnd = make<BssSection>(".part.end", Config->MaxPageSize, 1);
In.PartEnd->Partition = 255;
Add(In.PartEnd);
More information about the llvm-commits
mailing list