[PATCH] [ELF] Support response file.
Michael Spencer
bigcheesegs at gmail.com
Thu Mar 27 23:23:14 PDT 2014
The memory management here looks sketchy.
================
Comment at: lib/Driver/GnuLdDriver.cpp:80
@@ +79,3 @@
+ const char *SaveString(const char *s) override {
+ return (new (_alloc) std::string(s))->c_str();
+ }
----------------
We should directly allocate the string into _alloc. With this implementation std::string's destructor will never be called.
================
Comment at: lib/Driver/GnuLdDriver.cpp:105-110
@@ +104,8 @@
+ argc = smallvec.size();
+ std::vector<const char *> result;
+ for (size_t i = 0, e = smallvec.size(); i < e; ++i)
+ result.push_back(smallvec[i]);
+ result.push_back(nullptr); // terminate ARGV with NULL
+ auto *resultCopy = new (alloc) std::vector<const char *>(result);
+ return std::make_tuple(argc, &(*resultCopy)[0]);
+}
----------------
This also has the same issue as not destructing std::vector.
char **result = new (alloc) char *[argc + 1];
std::copy(smallvec.begin(), smallvec.end(), result);
result[argc] = nullptr;
return std::make_tuple(argc, result);
http://llvm-reviews.chandlerc.com/D3210
BRANCH
responsefile
ARCANIST PROJECT
lld
More information about the llvm-commits
mailing list