projects
/
deliverable
/
binutils-gdb.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
2012-05-09 Frank Ch. Eigler <fche@redhat.com>
[deliverable/binutils-gdb.git]
/
gold
/
descriptors.cc
diff --git
a/gold/descriptors.cc
b/gold/descriptors.cc
index 3d059e2c222ed79a02157d282d9a2d70d4ddce55..2ab0d5c8816306dd58d561bf69a08e47d0f6ef57 100644
(file)
--- a/
gold/descriptors.cc
+++ b/
gold/descriptors.cc
@@
-1,6
+1,6
@@
// descriptors.cc -- manage file descriptors for gold
// descriptors.cc -- manage file descriptors for gold
-// Copyright 2008, 2009 Free Software Foundation, Inc.
+// Copyright 2008, 2009
, 2010, 2011
Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
@@
-23,6
+23,7
@@
#include "gold.h"
#include <cerrno>
#include "gold.h"
#include <cerrno>
+#include <cstdio>
#include <cstring>
#include <fcntl.h>
#include <unistd.h>
#include <cstring>
#include <fcntl.h>
#include <unistd.h>
@@
-31,16
+32,26
@@
#include "options.h"
#include "gold-threads.h"
#include "descriptors.h"
#include "options.h"
#include "gold-threads.h"
#include "descriptors.h"
+#include "binary-io.h"
+
+// O_CLOEXEC is only available on newer systems.
+#ifndef O_CLOEXEC
+#define O_CLOEXEC 0
+#endif
// Very old systems may not define FD_CLOEXEC.
#ifndef FD_CLOEXEC
#define FD_CLOEXEC 1
#endif
// Very old systems may not define FD_CLOEXEC.
#ifndef FD_CLOEXEC
#define FD_CLOEXEC 1
#endif
-// O_CLOEXEC is only available on newer systems.
-#ifndef O_CLOEXEC
-#define O_CLOEXEC 0
+static inline void
+set_close_on_exec(int fd)
+{
+// Mingw does not define F_SETFD.
+#ifdef F_SETFD
+ fcntl(fd, F_SETFD, FD_CLOEXEC);
#endif
#endif
+}
namespace gold
{
namespace gold
{
@@
-98,6
+109,9
@@
Descriptors::open(int descriptor, const char* name, int flags, int mode)
// require callers to pass it.
flags |= O_CLOEXEC;
// require callers to pass it.
flags |= O_CLOEXEC;
+ // Always open the file as a binary file.
+ flags |= O_BINARY;
+
int new_descriptor = ::open(name, flags, mode);
if (new_descriptor < 0
&& errno != ENFILE
int new_descriptor = ::open(name, flags, mode);
if (new_descriptor < 0
&& errno != ENFILE
@@
-108,8
+122,7
@@
Descriptors::open(int descriptor, const char* name, int flags, int mode)
{
Hold_lock hl(*this->lock_);
{
Hold_lock hl(*this->lock_);
- gold_error(_("file %s was removed during the link"),
- this->open_descriptors_[descriptor].name);
+ gold_error(_("file %s was removed during the link"), name);
}
errno = ENOENT;
}
errno = ENOENT;
@@
-129,7
+142,7
@@
Descriptors::open(int descriptor, const char* name, int flags, int mode)
if (O_CLOEXEC == 0
&& parameters->options_valid()
&& parameters->options().has_plugins())
if (O_CLOEXEC == 0
&& parameters->options_valid()
&& parameters->options().has_plugins())
-
fcntl(new_descriptor, F_SETFD, FD_CLOEXEC
);
+
set_close_on_exec(new_descriptor
);
{
Hold_optional_lock hl(this->lock_);
{
Hold_optional_lock hl(this->lock_);
This page took
0.023507 seconds
and
4
git commands to generate.