This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Tidy bfdio to consistenly use containing archive
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Thu, 14 Jun 2018 11:30:35 +0930
- Subject: Re: Tidy bfdio to consistenly use containing archive
- References: <20180605130826.GF7660@bubble.grove.modra.org>
On Tue, Jun 05, 2018 at 10:38:26PM +0930, Alan Modra wrote:
> and bfd_seek optimized calls that didn't move the
> file pointer.
Which turns out to be quite important. In cases where section data is
filled in piece by piece with bfd_set_section_contents, you get an
fseek followed by an fwrite of the data. At least when the fwrite
isn't exactly one 4k disk sector that results in an lseek to the
containing sector, a read of that sector, another lseek, then a write,
repeated piece by piece. A huge increase in IO.
This patch reinstates the bfd_seek optimization. Seeks within
archives are optimized too, something that wasn't possible before the
patch that caused this PR.
PR 23282
* bfdio.c (bfd_seek): Optimize away seeks to current position.
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index 136fa8b1d3..1f4caca4ed 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -330,6 +330,10 @@ bfd_seek (bfd *abfd, file_ptr position, int direction)
if (direction != SEEK_CUR)
position += offset;
+ if ((direction == SEEK_CUR && position == 0)
+ || (direction == SEEK_SET && (ufile_ptr) position == abfd->where))
+ return 0;
+
result = abfd->iovec->bseek (abfd, position, direction);
if (result != 0)
{
--
Alan Modra
Australia Development Lab, IBM