summaryrefslogtreecommitdiff
path: root/tools/llvm-dwp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2016-05-25 23:37:06 +0000
committerDavid Blaikie <dblaikie@gmail.com>2016-05-25 23:37:06 +0000
commitfe303ed1b894ff21ebafc186816a924be898542d (patch)
tree17e0885e467a90cdf54cdfb61139b840b7ea0f69 /tools/llvm-dwp
parentbdbb8ee4ab0304a7e672c5cfb520382de2dc3bed (diff)
llvm-dwp: Ensure uncompressed sections are not relocated during processing of later inputs
Richard Smith identified this in post commit review of r270466. The string sections in particular (in the future, possibly all sections - so I'm not going to bother pulling out just the string sections for the extra lifetime handling right now) need to remain valid during processing of all inputs so that elements of the DWPStringPool can be looked up repeatedly without having to make in-memory copies of string contents in the noncompressed case (more common in dwp+dwp merge steps where the memory is a bigger problem because the files are larger). Using the SmallVector (or any vector) a reallocation on push_back could cause any of the nested SmallStrings in small mode to move in memory and invalid pointers to their contents. Using a deque the SmallStrings will never move around since no elements are removed from the container. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270797 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-dwp')
-rw-r--r--tools/llvm-dwp/llvm-dwp.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/llvm-dwp/llvm-dwp.cpp b/tools/llvm-dwp/llvm-dwp.cpp
index 941083f5c3f..7bd3d3f3f4d 100644
--- a/tools/llvm-dwp/llvm-dwp.cpp
+++ b/tools/llvm-dwp/llvm-dwp.cpp
@@ -39,6 +39,7 @@
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
+#include <deque>
#include <iostream>
#include <memory>
@@ -360,7 +361,7 @@ std::string buildDWODescription(StringRef Name, StringRef DWPName, StringRef DWO
}
static Error handleCompressedSection(
- SmallVector<SmallString<32>, 4> &UncompressedSections, StringRef &Name,
+ std::deque<SmallString<32>> &UncompressedSections, StringRef &Name,
StringRef &Contents) {
if (!Name.startswith("zdebug_"))
return Error();
@@ -384,7 +385,7 @@ static Error handleSection(
const MCSection *StrSection, const MCSection *StrOffsetSection,
const MCSection *TypesSection, const MCSection *CUIndexSection,
const MCSection *TUIndexSection, const SectionRef &Section, MCStreamer &Out,
- SmallVector<SmallString<32>, 4> &UncompressedSections,
+ std::deque<SmallString<32>> &UncompressedSections,
uint32_t (&ContributionOffsets)[8], UnitIndexEntry &CurEntry,
StringRef &CurStrSection, StringRef &CurStrOffsetSection,
std::vector<StringRef> &CurTypesSection, StringRef &InfoSection,
@@ -489,7 +490,7 @@ static Error write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
SmallVector<OwningBinary<object::ObjectFile>, 128> Objects;
Objects.reserve(Inputs.size());
- SmallVector<SmallString<32>, 4> UncompressedSections;
+ std::deque<SmallString<32>> UncompressedSections;
for (const auto &Input : Inputs) {
auto ErrOrObj = object::ObjectFile::createObjectFile(Input);