aboutsummaryrefslogtreecommitdiff
path: root/bfd/bfd.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2023-08-07 08:28:55 +0930
committerAlan Modra <amodra@gmail.com>2023-08-09 08:47:35 +0930
commitf82ee0c8dc4ee32556e23e6cd83ef083618f704f (patch)
tree6775612169afe1cd7270f7fe4c10f5b451dfdb44 /bfd/bfd.c
parent7570a17cbbe647db6260ae2391f92c0509de7924 (diff)
downloadfsf-binutils-gdb-f82ee0c8dc4ee32556e23e6cd83ef083618f704f.zip
fsf-binutils-gdb-f82ee0c8dc4ee32556e23e6cd83ef083618f704f.tar.gz
fsf-binutils-gdb-f82ee0c8dc4ee32556e23e6cd83ef083618f704f.tar.bz2
PR30724, cygwin ld performance regression since 014a602b86
According to the reporter of this bug the newlib fseek implementation is likely slowed down by locking and fflush, only attempting to optimise seeks when the file is opened read-only. Thus when writing the output we get a dramatic slowdown due to commit 014a602b86. PR 30724 * bfd.c (enum bfd_last_io): New. (struct bfd): Add last_io field. * bfd-in2.h: Regenerate. * bfd-io.c (bfd_bread, bfd_bwrite): Force seek if last_io is opposite direction. (bfd_seek): Reinstate optimisation for seek to same position.
Diffstat (limited to 'bfd/bfd.c')
-rw-r--r--bfd/bfd.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/bfd/bfd.c b/bfd/bfd.c
index e43a388..88943a0 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -53,6 +53,14 @@ EXTERNAL
. both_direction = 3
. };
.
+.enum bfd_last_io
+. {
+. bfd_io_seek = 0,
+. bfd_io_read = 1,
+. bfd_io_write = 2,
+. bfd_io_force = 3
+. };
+.
.enum bfd_plugin_format
. {
. bfd_plugin_unknown = 0,
@@ -208,6 +216,20 @@ CODE_FRAGMENT
. {* The direction with which the BFD was opened. *}
. ENUM_BITFIELD (bfd_direction) direction : 2;
.
+. {* POSIX.1-2017 (IEEE Std 1003.1) says of fopen : "When a file is
+. opened with update mode ('+' as the second or third character in
+. the mode argument), both input and output may be performed on
+. the associated stream. However, the application shall ensure
+. that output is not directly followed by input without an
+. intervening call to fflush() or to a file positioning function
+. (fseek(), fsetpos(), or rewind()), and input is not directly
+. followed by output without an intervening call to a file
+. positioning function, unless the input operation encounters
+. end-of-file."
+. This field tracks the last IO operation, so that bfd can insert
+. a seek when IO direction changes. *}
+. ENUM_BITFIELD (bfd_last_io) last_io : 2;
+.
. {* Is the file descriptor being cached? That is, can it be closed as
. needed, and re-opened when accessed later? *}
. unsigned int cacheable : 1;