aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-05-30 06:34:05 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-05-30 06:34:40 -0700
commit8e2f54bcee7e3e8315d4a39a302eaf8e4389e07d (patch)
treef7dbe2132447153b463f363891ce551b065cb685 /bfd
parent08c3f6d234761d92b50d3c56d3cb4b82fdd58c77 (diff)
downloadgdb-8e2f54bcee7e3e8315d4a39a302eaf8e4389e07d.zip
gdb-8e2f54bcee7e3e8315d4a39a302eaf8e4389e07d.tar.gz
gdb-8e2f54bcee7e3e8315d4a39a302eaf8e4389e07d.tar.bz2
Add bfd_get_file_size to get archive element size
We can't use stat() to get archive element size. Add bfd_get_file_size to get size for both normal files and archive elements. bfd/ PR binutils/21519 * bfdio.c (bfd_get_file_size): New function. * bfd-in2.h: Regenerated. binutils/ PR binutils/21519 * objdump.c (dump_relocs_in_section): Replace get_file_size with bfd_get_file_size to get archive element size. * testsuite/binutils-all/objdump.exp (test_objdump_f): New proc. (test_objdump_h): Likewise. (test_objdump_t): Likewise. (test_objdump_r): Likewise. (test_objdump_s): Likewise. Add objdump tests on archive.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/bfd-in2.h2
-rw-r--r--bfd/bfdio.c23
3 files changed, 31 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 4d15e1a..8b113a0 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2017-05-30 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR binutils/21519
+ * bfdio.c (bfd_get_file_size): New function.
+ * bfd-in2.h: Regenerated.
+
2017-05-23 Dilian Palauzov <git-dpa@aegee.org>
* elf32-arc.c (arc_elf_merge_attributes): Add fall through
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index ae2fceb..a23bb98 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -1242,6 +1242,8 @@ long bfd_get_mtime (bfd *abfd);
file_ptr bfd_get_size (bfd *abfd);
+file_ptr bfd_get_file_size (bfd *abfd);
+
void *bfd_mmap (bfd *abfd, void *addr, bfd_size_type len,
int prot, int flags, file_ptr offset,
void **map_addr, bfd_size_type *map_len);
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index 792ccda..e301570 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -434,6 +434,29 @@ bfd_get_size (bfd *abfd)
return buf.st_size;
}
+/*
+FUNCTION
+ bfd_get_file_size
+
+SYNOPSIS
+ file_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.
+
+*/
+
+file_ptr
+bfd_get_file_size (bfd *abfd)
+{
+ if (abfd->my_archive != NULL
+ && !bfd_is_thin_archive (abfd->my_archive))
+ return arelt_size (abfd);
+
+ return bfd_get_size (abfd);
+}
/*
FUNCTION