* libbfd.c (bfd_seek): fix 'seek beyond EOF' error when writing
out a structure that is BFD_IN_MEMORY.
This commit is contained in:
parent
7f7888218f
commit
e67f03db5b
2 changed files with 30 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
|||
2000-07-12 Charles Wilson <cwilson@ece.gatech.edu>
|
||||
|
||||
* libbfd.c (bfd_seek): fix 'seek beyond EOF' error when writing
|
||||
out a structure that is BFD_IN_MEMORY.
|
||||
|
||||
2000-07-11 Alan Modra <alan@linuxcare.com.au>
|
||||
|
||||
* elf64-hppa.c (get_dyn_name): Pass in section pointer instead of
|
||||
|
|
28
bfd/libbfd.c
28
bfd/libbfd.c
|
@ -691,11 +691,31 @@ bfd_seek (abfd, position, direction)
|
|||
|
||||
if ((bfd_size_type) abfd->where > bim->size)
|
||||
{
|
||||
abfd->where = bim->size;
|
||||
bfd_set_error (bfd_error_file_truncated);
|
||||
return -1;
|
||||
if ((abfd->direction == write_direction) ||
|
||||
(abfd->direction == both_direction))
|
||||
{
|
||||
long newsize, oldsize = (bim->size + 127) & ~127;
|
||||
bim->size = abfd->where;
|
||||
/* Round up to cut down on memory fragmentation */
|
||||
newsize = (bim->size + 127) & ~127;
|
||||
if (newsize > oldsize)
|
||||
{
|
||||
bim->buffer = bfd_realloc (bim->buffer, newsize);
|
||||
if (bim->buffer == 0)
|
||||
{
|
||||
bim->size = 0;
|
||||
bfd_set_error (bfd_error_no_memory);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
abfd->where = bim->size;
|
||||
bfd_set_error (bfd_error_file_truncated);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue