ubsan: visium: left shift cannot be represented in type 'int'
[deliverable/binutils-gdb.git] / gold / plugin.cc
index b12a7a9fae7fce2d076c3cdcb6730bdadd3aaed8..0bb277e126d3b4829110b6ce70528bdde8f1b815 100644 (file)
@@ -1,6 +1,6 @@
 // plugin.cc -- plugin manager for gold      -*- C++ -*-
 
-// Copyright (C) 2008-2018 Free Software Foundation, Inc.
+// Copyright (C) 2008-2019 Free Software Foundation, Inc.
 // Written by Cary Coutant <ccoutant@google.com>.
 
 // This file is part of gold.
@@ -508,8 +508,20 @@ Plugin_recorder::init()
   // Create a temporary directory where we can stash the log and
   // copies of replacement files.
   char dir_template[] = "gold-recording-XXXXXX";
+#ifdef HAVE_MKDTEMP
   if (mkdtemp(dir_template) == NULL)
     return false;
+#else
+  if (mktemp(dir_template) == NULL)
+    return false;
+#if defined (_WIN32) && !defined (__CYGWIN32__)
+  if (mkdir(dir_template) != 0)
+    return false;
+#else
+  if (mkdir(dir_template, 0700) != 0)
+    return false;
+#endif
+#endif
 
   size_t len = strlen(dir_template) + 1;
   char* tempdir = new char[len];
@@ -562,25 +574,34 @@ link_or_copy_file(const char* inname, const char* outname)
 {
   static char buf[4096];
 
+#ifdef HAVE_LINK
   if (::link(inname, outname) == 0)
     return true;
+#endif
 
   int in = ::open(inname, O_RDONLY);
   if (in < 0)
     {
-      gold_warning(_("%s: can't open (%s)\n"), inname, strerror(errno));
+      gold_warning(_("%s: can't open (%s)"), inname, strerror(errno));
       return false;
     }
   int out = ::open(outname, O_CREAT | O_TRUNC | O_WRONLY, 0600);
   if (out < 0)
     {
-      gold_warning(_("%s: can't create (%s)\n"), outname, strerror(errno));
+      gold_warning(_("%s: can't create (%s)"), outname, strerror(errno));
       ::close(in);
       return false;
     }
   ssize_t len;
   while ((len = ::read(in, buf, sizeof(buf))) > 0)
-    static_cast<void>(::write(out, buf, len));
+    {
+      if (::write(out, buf, len) != len)
+       {
+         gold_warning(_("%s: write error while making copy of file (%s)"),
+                      inname, strerror(errno));
+         break;
+        }
+    }
   ::close(in);
   ::close(out);
   return true;
@@ -1417,7 +1438,8 @@ Sized_pluginobj<size, big_endian>::do_add_symbols(Symbol_table* symtab,
         {
         case LDPK_DEF:
         case LDPK_WEAKDEF:
-          shndx = elfcpp::SHN_ABS;
+          // We use an arbitrary section number for a defined symbol.
+          shndx = 1;
           break;
         case LDPK_COMMON:
           shndx = elfcpp::SHN_COMMON;
This page took 0.02352 seconds and 4 git commands to generate.