aboutsummaryrefslogtreecommitdiff
path: root/binutils/elfcomm.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-11-23 07:33:29 +1030
committerAlan Modra <amodra@gmail.com>2022-11-23 07:53:13 +1030
commit26c527e62e701ae256c1af243ec9d73e5560bd48 (patch)
treea44df4341fb9c64b305f0fa86ef4df653c3d8f48 /binutils/elfcomm.c
parent63cf857e24be8e657dd2d3197da5c01a0f590d27 (diff)
downloadfsf-binutils-gdb-26c527e62e701ae256c1af243ec9d73e5560bd48.zip
fsf-binutils-gdb-26c527e62e701ae256c1af243ec9d73e5560bd48.tar.gz
fsf-binutils-gdb-26c527e62e701ae256c1af243ec9d73e5560bd48.tar.bz2
Don't use "long" in readelf for file offsets
The aim here is to improve readelf handling of large 64-bit object files on LLP64 hosts (Windows) where long is only 32 bits. The patch changes more than just file offsets. Addresses and sizes are also changed to avoid "long". Most places get to use uint64_t even where size_t may be more appropriate, because that allows some overflow checks to be implemented easily (*alloc changes). * dwarf.c (cmalloc, xcmalloc, xcrealloc, xcalloc2): Make nmemb parameter uint64_t. * dwarf.h: Update prototypes. (struct dwarf_section): Make num_relocs uint64_t. * elfcomm.c (setup_archive): Update error format. * elfcomm.h (struct archive_info): Make sym_size, longnames_size, nested_member_origin, next_arhdr_offset uint64_t. * readelf.c (struct filedata): Make archive_file_offset, archive_file_size, string_table_length, dynamic_addr, dynamic_nent, dynamic_strings_length, num_dynamic_syms, dynamic_syminfo_offset uint64_t. (many functions): Replace uses of "unsigned long" with "uint64_t" or "size_t".
Diffstat (limited to 'binutils/elfcomm.c')
-rw-r--r--binutils/elfcomm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/binutils/elfcomm.c b/binutils/elfcomm.c
index 0e7d0b5..6070b6e 100644
--- a/binutils/elfcomm.c
+++ b/binutils/elfcomm.c
@@ -530,7 +530,7 @@ setup_archive (struct archive_info *arch, const char *file_name,
/* PR 17531: file: 01068045. */
if (arch->longnames_size < 8)
{
- error (_("%s: long name table is too small, (size = %ld)\n"),
+ error (_("%s: long name table is too small, (size = %" PRId64 ")\n"),
file_name, arch->longnames_size);
return 1;
}
@@ -538,7 +538,7 @@ setup_archive (struct archive_info *arch, const char *file_name,
if ((off_t) arch->longnames_size > file_size
|| (signed long) arch->longnames_size < 0)
{
- error (_("%s: long name table is too big, (size = 0x%lx)\n"),
+ error (_("%s: long name table is too big, (size = %#" PRIx64 ")\n"),
file_name, arch->longnames_size);
return 1;
}