[binutils-gdb] bfd: fix potential missing seek
Alan Modra
amodra@sourceware.org
Sun Nov 30 03:24:00 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2fbe667884bc37e710f12937ded1b355be42fa56
commit 2fbe667884bc37e710f12937ded1b355be42fa56
Author: Roman Kapl <code@rkapl.cz>
Date: Sat Nov 29 12:45:27 2025 +0100
bfd: fix potential missing seek
If a file was closed by cache and then bfd_open_file was called followed
by e.g. bfd_seek to the original position, the seek would be optimized out
while the real file position was still zero (as fopened). I added
`bfd_io_force` to force the seek at next IO occasion.
This could lead e.g. to appearence of a corrupted object in ld:
symbol number 0 uses unsupported binding of 6
or invalid string offset #X >= #Y for section
Signed-off-by: Roman Kapl <code@rkapl.cz>
Diff:
---
bfd/cache.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/bfd/cache.c b/bfd/cache.c
index 3bf9c9449a4..3342e2d5008 100644
--- a/bfd/cache.c
+++ b/bfd/cache.c
@@ -177,6 +177,7 @@ bfd_cache_delete (bfd *abfd)
BFD_ASSERT (open_files > 0);
--open_files;
abfd->flags |= BFD_CLOSED_BY_CACHE;
+ abfd->last_io = bfd_io_force;
return ret;
}
More information about the Binutils-cvs
mailing list