Don't use "long" in readelf for file offsets
authorAlan Modra <amodra@gmail.com>
Tue, 22 Nov 2022 21:03:29 +0000 (07:33 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 22 Nov 2022 21:23:13 +0000 (07:53 +1030)
commit26c527e62e701ae256c1af243ec9d73e5560bd48
treea44df4341fb9c64b305f0fa86ef4df653c3d8f48
parent63cf857e24be8e657dd2d3197da5c01a0f590d27
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".
binutils/dwarf.c
binutils/dwarf.h
binutils/elfcomm.c
binutils/elfcomm.h
binutils/readelf.c