[PATCH] Gold-plugin: Broaden scope of get/release_input_file to scope of Module.
Jan Voung
jvoung at chromium.org
Tue Feb 10 11:54:47 PST 2015
Hi rafael, nlewycky,
Move calls to get_input_file and release_input_file out of
getModuleForFile(). Otherwise release_input_file may end up
unmapping a view of the file while the view is still being
used by the Module (on 32-bit hosts).
Fix for PR22482.
http://reviews.llvm.org/D7539
Files:
tools/gold/gold-plugin.cpp
Index: tools/gold/gold-plugin.cpp
===================================================================
--- tools/gold/gold-plugin.cpp
+++ tools/gold/gold-plugin.cpp
@@ -560,11 +560,9 @@
}
static std::unique_ptr<Module>
-getModuleForFile(LLVMContext &Context, claimed_file &F, raw_fd_ostream *ApiFile,
+getModuleForFile(LLVMContext &Context, claimed_file &F,
+ const ld_plugin_input_file &File, raw_fd_ostream *ApiFile,
StringSet<> &Internalize, StringSet<> &Maybe) {
- ld_plugin_input_file File;
- if (get_input_file(F.handle, &File) != LDPS_OK)
- message(LDPL_FATAL, "Failed to get file information");
if (get_symbols(F.handle, F.syms.size(), &F.syms[0]) != LDPS_OK)
message(LDPL_FATAL, "Failed to get symbol information");
@@ -581,9 +579,6 @@
message(LDPL_FATAL, "Could not read bitcode from file : %s",
EC.message().c_str());
- if (release_input_file(F.handle) != LDPS_OK)
- message(LDPL_FATAL, "Failed to release file information");
-
object::IRObjectFile &Obj = **ObjOrErr;
Module &M = Obj.getModule();
@@ -802,16 +797,21 @@
StringSet<> Internalize;
StringSet<> Maybe;
for (claimed_file &F : Modules) {
+ ld_plugin_input_file File;
+ if (get_input_file(F.handle, &File) != LDPS_OK)
+ message(LDPL_FATAL, "Failed to get file information");
std::unique_ptr<Module> M =
- getModuleForFile(Context, F, ApiFile, Internalize, Maybe);
+ getModuleForFile(Context, F, File, ApiFile, Internalize, Maybe);
if (!options::triple.empty())
M->setTargetTriple(options::triple.c_str());
else if (M->getTargetTriple().empty()) {
M->setTargetTriple(DefaultTriple);
}
if (L.linkInModule(M.get()))
message(LDPL_FATAL, "Failed to link module");
+ if (release_input_file(F.handle) != LDPS_OK)
+ message(LDPL_FATAL, "Failed to release file information");
}
for (const auto &Name : Internalize) {
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7539.19698.patch
Type: text/x-patch
Size: 1959 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150210/fe13afa2/attachment.bin>
More information about the llvm-commits
mailing list