Use binary mode for reading/writing bytecode files
[oota-llvm.git] / tools / gccld / gccld.cpp
index d33d64a01d68cb29901774412b4e410eb785e6f0..809db2adacc4d0492b76f31712436425819cc532 100644 (file)
@@ -238,7 +238,9 @@ int main(int argc, char **argv, char **envp ) {
     // Create the output file.
     std::string RealBytecodeOutput = OutputFilename;
     if (!LinkAsLibrary) RealBytecodeOutput += ".bc";
-    std::ofstream Out(RealBytecodeOutput.c_str());
+    std::ios::openmode io_mode = std::ios::out | std::ios::trunc |
+                                 std::ios::binary;
+    std::ofstream Out(RealBytecodeOutput.c_str(), io_mode);
     if (!Out.good())
       return PrintAndReturn(argv[0], "error opening '" + RealBytecodeOutput +
                                      "' for writing!");