This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Change bfd_get_size/bfd_get_file_size to ufile_ptr
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: binutils at sourceware dot org
- Date: Tue, 27 Jun 2017 05:28:13 -0700
- Subject: [PATCH] Change bfd_get_size/bfd_get_file_size to ufile_ptr
- Authentication-results: sourceware.org; auth=none
bfd_get_size and bfd_get_file_size should return the unsigned file
size. Otherwise they return negative values for file >= 2GB with
32-bit ufile_ptr.
OK for master?
H.J.
---
bfd/
* bfd-in2.h: Regenerated.
* bfdio.c (bfd_get_size): Change return type to ufile_ptr.
(bfd_get_file_size): Likewise.
binutils/
* objdump.c (dump_relocs_in_section): Cast to ufile_ptr when
comparing against bfd_get_file_size return.
---
bfd/bfd-in2.h | 4 ++--
bfd/bfdio.c | 8 ++++----
binutils/objdump.c | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 2141bcb..4a6c6b2 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -1240,9 +1240,9 @@ char *bfd_follow_build_id_debuglink (bfd *abfd, const char *dir);
/* Extracted from bfdio.c. */
long bfd_get_mtime (bfd *abfd);
-file_ptr bfd_get_size (bfd *abfd);
+ufile_ptr bfd_get_size (bfd *abfd);
-file_ptr bfd_get_file_size (bfd *abfd);
+ufile_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,
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index 51203e5..107d2b0 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -392,7 +392,7 @@ FUNCTION
bfd_get_size
SYNOPSIS
- file_ptr bfd_get_size (bfd *abfd);
+ ufile_ptr bfd_get_size (bfd *abfd);
DESCRIPTION
Return the file size (as read from file system) for the file
@@ -420,7 +420,7 @@ DESCRIPTION
size reasonable?".
*/
-file_ptr
+ufile_ptr
bfd_get_size (bfd *abfd)
{
struct stat buf;
@@ -439,7 +439,7 @@ FUNCTION
bfd_get_file_size
SYNOPSIS
- file_ptr bfd_get_file_size (bfd *abfd);
+ ufile_ptr bfd_get_file_size (bfd *abfd);
DESCRIPTION
Return the file size (as read from file system) for the file
@@ -448,7 +448,7 @@ DESCRIPTION
*/
-file_ptr
+ufile_ptr
bfd_get_file_size (bfd *abfd)
{
ufile_ptr file_size;
diff --git a/binutils/objdump.c b/binutils/objdump.c
index ed8c645..0b72818 100644
--- a/binutils/objdump.c
+++ b/binutils/objdump.c
@@ -3388,7 +3388,7 @@ dump_relocs_in_section (bfd *abfd,
}
if ((bfd_get_file_flags (abfd) & (BFD_IN_MEMORY | BFD_LINKER_CREATED)) == 0
- && relsize > bfd_get_file_size (abfd))
+ && (ufile_ptr) relsize > bfd_get_file_size (abfd))
{
printf (" (too many: 0x%x)\n", section->reloc_count);
bfd_set_error (bfd_error_file_truncated);
--
2.9.4