aboutsummaryrefslogtreecommitdiff
path: root/bfd/libbfd.c
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@cygnus>1993-03-24 05:09:18 +0000
committerKen Raeburn <raeburn@cygnus>1993-03-24 05:09:18 +0000
commite5b0286097763d2d80b8be2ef9202f5e31c791ae (patch)
treef03cb93fe37bc7478a1ab7bc25991b35d029895a /bfd/libbfd.c
parentb0ad85e1f4881a8acd047a16d47c431ecbaab65b (diff)
downloadgdb-e5b0286097763d2d80b8be2ef9202f5e31c791ae.zip
gdb-e5b0286097763d2d80b8be2ef9202f5e31c791ae.tar.gz
gdb-e5b0286097763d2d80b8be2ef9202f5e31c791ae.tar.bz2
fix some (not all) bugs in previous changes
Diffstat (limited to 'bfd/libbfd.c')
-rw-r--r--bfd/libbfd.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/bfd/libbfd.c b/bfd/libbfd.c
index 75ce90e..e11f794 100644
--- a/bfd/libbfd.c
+++ b/bfd/libbfd.c
@@ -257,6 +257,7 @@ DEFUN(bfd_seek,(abfd, position, direction),
{
int result;
FILE *f;
+ file_ptr file_position;
/* For the time being, a BFD may not seek to it's end. The problem
is that we don't easily have a way to recognize the end of an
element in an archive. */
@@ -271,18 +272,26 @@ DEFUN(bfd_seek,(abfd, position, direction),
#endif
f = bfd_cache_lookup (abfd);
+ file_position = position;
if (direction == SEEK_SET && abfd->my_archive != NULL)
- {
- /* This is a set within an archive, so we need to
- add the base of the object within the archive */
- result = fseek (f, position + abfd->origin, direction);
- }
+ file_position += abfd->origin;
+
+ result = fseek (f, file_position, direction);
+
+ if (result != 0)
+ /* Force redetermination of `where' field. */
+ bfd_tell (abfd);
else
{
- result = fseek (f, position, direction);
+#ifdef FILE_OFFSET_IS_CHAR_INDEX
+ /* Adjust `where' field. */
+ if (direction == SEEK_SET)
+ abfd->where = position;
+ else
+ abfd->where += position;
+#endif
}
- /* Force redetermination of `where' field. */
- bfd_tell (abfd);
+ return result;
}
/** Make a string table */