+/*
+FUNCTION
+ bfd_get_file_size
+
+SYNOPSIS
+ ufile_ptr bfd_get_file_size (bfd *abfd);
+
+DESCRIPTION
+ Return the file size (as read from file system) for the file
+ associated with BFD @var{abfd}. It supports both normal files
+ and archive elements.
+
+*/
+
+ufile_ptr
+bfd_get_file_size (bfd *abfd)
+{
+ ufile_ptr file_size, archive_size = (ufile_ptr) -1;
+
+ if (abfd->my_archive != NULL
+ && !bfd_is_thin_archive (abfd->my_archive))
+ {
+ struct areltdata *adata = (struct areltdata *) abfd->arelt_data;
+ archive_size = adata->parsed_size;
+ /* If the archive is compressed we can't compare against file size. */
+ if (adata->arch_header != NULL
+ && memcmp (((struct ar_hdr *) adata->arch_header)->ar_fmag,
+ "Z\012", 2) == 0)
+ return archive_size;
+ abfd = abfd->my_archive;
+ }
+
+ file_size = bfd_get_size (abfd);
+ if (archive_size < file_size)
+ return archive_size;
+ return file_size;
+}