diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2019-06-11 02:54:30 +0000 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2019-06-11 02:54:30 +0000 |
| commit | eaf3f569247afc9e681d87905c28189dfb0c1293 (patch) | |
| tree | 8b2a0fdd7ee1c9d58283dcb8b8cb78ea0c2bd658 | |
| parent | e5bdedac9dc5ecb240a56dcb19e5fd923af6c353 (diff) | |
| download | bcm5719-llvm-eaf3f569247afc9e681d87905c28189dfb0c1293.tar.gz bcm5719-llvm-eaf3f569247afc9e681d87905c28189dfb0c1293.zip | |
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.
llvm-svn: 363026
| -rw-r--r-- | lld/ELF/Writer.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 6614d9c4076..c6ba893db0b 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -178,7 +178,9 @@ template <class ELFT> static void copySectionsIntoPartitions() { 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 createSyntheticSections() { 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); |

