mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-25 21:41:47 +08:00
fix some (not all) bugs in previous changes
This commit is contained in:
27
bfd/libbfd.c
27
bfd/libbfd.c
@ -257,6 +257,7 @@ DEFUN(bfd_seek,(abfd, position, direction),
|
|||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
file_ptr file_position;
|
||||||
/* For the time being, a BFD may not seek to it's end. The problem
|
/* 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
|
is that we don't easily have a way to recognize the end of an
|
||||||
element in an archive. */
|
element in an archive. */
|
||||||
@ -271,18 +272,26 @@ DEFUN(bfd_seek,(abfd, position, direction),
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
f = bfd_cache_lookup (abfd);
|
f = bfd_cache_lookup (abfd);
|
||||||
|
file_position = position;
|
||||||
if (direction == SEEK_SET && abfd->my_archive != NULL)
|
if (direction == SEEK_SET && abfd->my_archive != NULL)
|
||||||
{
|
file_position += abfd->origin;
|
||||||
/* This is a set within an archive, so we need to
|
|
||||||
add the base of the object within the archive */
|
result = fseek (f, file_position, direction);
|
||||||
result = fseek (f, position + abfd->origin, direction);
|
|
||||||
}
|
if (result != 0)
|
||||||
else
|
|
||||||
{
|
|
||||||
result = fseek (f, position, direction);
|
|
||||||
}
|
|
||||||
/* Force redetermination of `where' field. */
|
/* Force redetermination of `where' field. */
|
||||||
bfd_tell (abfd);
|
bfd_tell (abfd);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#ifdef FILE_OFFSET_IS_CHAR_INDEX
|
||||||
|
/* Adjust `where' field. */
|
||||||
|
if (direction == SEEK_SET)
|
||||||
|
abfd->where = position;
|
||||||
|
else
|
||||||
|
abfd->where += position;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Make a string table */
|
/** Make a string table */
|
||||||
|
Reference in New Issue
Block a user