From: Alan Modra Date: Wed, 13 Jun 2018 14:27:17 +0000 (+0930) Subject: PR23282, Reinstate seek optimization X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ff91d2f0e20fc91b6b101a0b20cbd38ab2d7fb50;p=binutils-gdb.git PR23282, Reinstate seek optimization PR 23282 * bfdio.c (bfd_seek): Optimize away seeks to current position. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8b706823194..d9465d5d84f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2018-06-14 Alan Modra + + PR 23282 + * bfdio.c (bfd_seek): Optimize away seeks to current position. + 2018-06-13 Scott Egerton Faraz Shahbazker diff --git a/bfd/bfdio.c b/bfd/bfdio.c index 136fa8b1d3f..1f4caca4ed1 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) {