Index: bfd/bfdio.c |
diff --git a/bfd/bfdio.c b/bfd/bfdio.c |
index 841c781f4bd8e08f4abc842199bf1ad4dc147cd4..43a7684d7badefd2a4184efc1c74f1fe7180f614 100644 |
--- a/bfd/bfdio.c |
+++ b/bfd/bfdio.c |
@@ -87,7 +87,6 @@ FILE * |
real_fopen (const char *filename, const char *modes) |
{ |
#ifdef VMS |
- char vms_modes[4]; |
char *vms_attr; |
/* On VMS, fopen allows file attributes as optionnal arguments. |
@@ -185,7 +184,8 @@ bfd_bread (void *ptr, bfd_size_type size, bfd *abfd) |
this element. */ |
if (abfd->arelt_data != NULL) |
{ |
- size_t maxbytes = ((struct areltdata *) abfd->arelt_data)->parsed_size; |
+ bfd_size_type maxbytes = arelt_size (abfd); |
+ |
if (abfd->where + size > maxbytes) |
{ |
if (abfd->where >= maxbytes) |
@@ -233,10 +233,14 @@ bfd_tell (bfd *abfd) |
if (abfd->iovec) |
{ |
+ bfd *parent_bfd = abfd; |
ptr = abfd->iovec->btell (abfd); |
- if (abfd->my_archive) |
- ptr -= abfd->origin; |
+ while (parent_bfd->my_archive != NULL) |
+ { |
+ ptr -= parent_bfd->origin; |
+ parent_bfd = parent_bfd->my_archive; |
+ } |
} |
else |
ptr = 0; |
@@ -308,8 +312,16 @@ bfd_seek (bfd *abfd, file_ptr position, int direction) |
} |
file_position = position; |
- if (direction == SEEK_SET && abfd->my_archive != NULL) |
- file_position += abfd->origin; |
+ if (direction == SEEK_SET) |
+ { |
+ bfd *parent_bfd = abfd; |
+ |
+ while (parent_bfd->my_archive != NULL) |
+ { |
+ file_position += parent_bfd->origin; |
+ parent_bfd = parent_bfd->my_archive; |
+ } |
+ } |
if (abfd->iovec) |
result = abfd->iovec->bseek (abfd, file_position, direction); |