while (1)
{
- bfd_size_type maxprint;
+ size_t maxprint;
dwarf_vma offset;
SAFE_BYTE_GET_AND_INC (offset, data, offset_size, start);
static unsigned char *
read_cie (unsigned char *start, unsigned char *end,
Frame_Chunk **p_cie, int *p_version,
- bfd_size_type *p_aug_len, unsigned char **p_aug)
+ dwarf_size_type *p_aug_len, unsigned char **p_aug)
{
int version;
Frame_Chunk *fc;
unsigned char *augmentation_data = NULL;
- bfd_size_type augmentation_data_len = 0;
+ dwarf_size_type augmentation_data_len = 0;
* p_cie = NULL;
/* PR 17512: file: 001-228113-0.004. */
READ_ULEB (augmentation_data_len, start, end);
augmentation_data = start;
/* PR 17512: file: 11042-2589-0.004. */
- if (augmentation_data_len > (bfd_size_type) (end - start))
+ if (augmentation_data_len > (size_t) (end - start))
{
warn (_("Augmentation data too long: 0x%s, expected at most %#lx\n"),
dwarf_vmatoa ("x", augmentation_data_len),
output line. */
static void
-display_data (bfd_size_type printed,
- const unsigned char * data,
- const bfd_size_type len)
+display_data (size_t printed, const unsigned char *data, size_t len)
{
if (do_wide || len < ((80 - printed) / 3))
for (printed = 0; printed < len; ++printed)
If do_wide is not enabled, then formats the output to fit into 80 columns. */
static void
-display_augmentation_data (const unsigned char * data, const bfd_size_type len)
+display_augmentation_data (const unsigned char * data, dwarf_size_type len)
{
- bfd_size_type i;
+ size_t i;
i = printf (_(" Augmentation data: "));
display_data (i, data, len);
Frame_Chunk *cie;
int need_col_headers = 1;
unsigned char *augmentation_data = NULL;
- bfd_size_type augmentation_data_len = 0;
+ dwarf_size_type augmentation_data_len = 0;
unsigned int encoded_ptr_size = saved_eh_addr_size;
unsigned int offset_size;
bool all_nops;
READ_ULEB (augmentation_data_len, start, block_end);
augmentation_data = start;
/* PR 17512 file: 722-8446-0.004 and PR 22386. */
- if (augmentation_data_len > (bfd_size_type) (block_end - start))
+ if (augmentation_data_len > (size_t) (block_end - start))
{
warn (_("Augmentation data too long: 0x%s, "
"expected at most %#lx\n"),
}
else /* startswith (section->name, ".gnu_debugaltlink") */
{
- const unsigned char * build_id = section->start + filelen + 1;
- bfd_size_type build_id_len = section->size - (filelen + 1);
- bfd_size_type printed;
+ const unsigned char *build_id = section->start + filelen + 1;
+ size_t build_id_len = section->size - (filelen + 1);
+ size_t printed;
/* FIXME: Should we support smaller build-id notes ? */
if (build_id_len < 0x14)
{
- warn (_("Build-ID is too short (%#lx bytes)\n"), (long) build_id_len);
+ warn (_("Build-ID is too short (%#zx bytes)\n"), build_id_len);
return 0;
}
- printed = printf (_(" Build-ID (%#lx bytes):"), (long) build_id_len);
+ printed = printf (_(" Build-ID (%#zx bytes):"), build_id_len);
display_data (printed, build_id, build_id_len);
putchar ('\n');
}
}
static unsigned long
-calc_gnu_debuglink_crc32 (unsigned long crc,
- const unsigned char * buf,
- bfd_size_type len)
+calc_gnu_debuglink_crc32 (unsigned long crc,
+ const unsigned char *buf,
+ size_t len)
{
static const unsigned long crc32_table[256] =
{
static bool
check_gnu_debuglink (const char * pathname, void * crc_pointer)
{
- static unsigned char buffer [8 * 1024];
- FILE * f;
- bfd_size_type count;
- unsigned long crc = 0;
- void * sep_data;
+ static unsigned char buffer[8 * 1024];
+ FILE *f;
+ size_t count;
+ unsigned long crc = 0;
+ void *sep_data;
sep_data = open_debug_file (pathname);
if (sep_data == NULL)
typedef struct build_id_data
{
- bfd_size_type len;
- const unsigned char * data;
+ size_t len;
+ const unsigned char *data;
} Build_id_data;
static const char *
parse_gnu_debugaltlink (struct dwarf_section * section, void * data)
{
- const char * name;
- bfd_size_type namelen;
- bfd_size_type id_len;
- Build_id_data * build_id_data;
+ const char *name;
+ size_t namelen;
+ size_t id_len;
+ Build_id_data *build_id_data;
/* The name is first.
The build-id follows immediately, with no padding, up to the section's end. */
const char * file_name;
bool is_separate;
FILE * handle;
- bfd_size_type file_size;
+ uint64_t file_size;
Elf_Internal_Ehdr file_header;
unsigned long archive_file_offset;
unsigned long archive_file_size;
char * string_table;
unsigned long string_table_length;
unsigned long dynamic_addr;
- bfd_size_type dynamic_size;
+ uint64_t dynamic_size;
size_t dynamic_nent;
Elf_Internal_Dyn * dynamic_section;
Elf_Internal_Shdr * dynamic_strtab_section;
unsigned int dynamic_syminfo_nent;
Elf_Internal_Syminfo * dynamic_syminfo;
unsigned long dynamic_syminfo_offset;
- bfd_size_type nbuckets;
- bfd_size_type nchains;
+ uint64_t nbuckets;
+ uint64_t nchains;
bfd_vma * buckets;
bfd_vma * chains;
- bfd_size_type ngnubuckets;
- bfd_size_type ngnuchains;
+ uint64_t ngnubuckets;
+ uint64_t ngnuchains;
bfd_vma * gnubuckets;
bfd_vma * gnuchains;
bfd_vma * mipsxlat;
message using REASON as part of the context. */
static void *
-get_data (void * var,
- Filedata * filedata,
- unsigned long offset,
- bfd_size_type size,
- bfd_size_type nmemb,
- const char * reason)
+get_data (void *var,
+ Filedata *filedata,
+ unsigned long offset,
+ uint64_t size,
+ uint64_t nmemb,
+ const char *reason)
{
void * mvar;
- bfd_size_type amt = size * nmemb;
+ uint64_t amt = size * nmemb;
if (size == 0 || nmemb == 0)
return NULL;
- /* If the size_t type is smaller than the bfd_size_type, eg because
- you are building a 32-bit tool on a 64-bit host, then make sure
- that when the sizes are cast to (size_t) no information is lost. */
+ /* If size_t is smaller than uint64_t, eg because you are building
+ on a 32-bit host, then make sure that when the sizes are cast to
+ size_t no information is lost. */
if ((size_t) size != size
|| (size_t) nmemb != nmemb
- || (size_t) amt != amt)
- {
- if (reason)
- error (_("Size truncation prevents reading %" PRIu64
- " elements of size %" PRIu64 " for %s\n"),
- (uint64_t) nmemb, (uint64_t) size, reason);
- return NULL;
- }
-
- /* Check for size overflow. */
- if (amt / size != nmemb || (size_t) amt + 1 == 0)
+ || (size_t) amt != amt
+ || amt / size != nmemb
+ || (size_t) amt + 1 == 0)
{
if (reason)
error (_("Size overflow prevents reading %" PRIu64
" elements of size %" PRIu64 " for %s\n"),
- (uint64_t) nmemb, (uint64_t) size, reason);
+ nmemb, size, reason);
return NULL;
}
{
if (reason)
error (_("Reading %" PRIu64 " bytes extends past end of file for %s\n"),
- (uint64_t) amt, reason);
+ amt, reason);
return NULL;
}
{
if (reason)
error (_("Out of memory allocating %" PRIu64 " bytes for %s\n"),
- (uint64_t) amt, reason);
+ amt, reason);
return NULL;
}
{
if (reason)
error (_("Unable to read in %" PRIu64 " bytes of %s\n"),
- (uint64_t) amt, reason);
+ amt, reason);
if (mvar != var)
free (mvar);
return NULL;
locate_dynamic_section (Filedata *filedata)
{
unsigned long dynamic_addr = 0;
- bfd_size_type dynamic_size = 0;
+ uint64_t dynamic_size = 0;
if (filedata->file_header.e_phnum != 0
&& get_program_headers (filedata))
}
unsigned long dynamic_addr = 0;
- bfd_size_type dynamic_size = 0;
+ uint64_t dynamic_size = 0;
for (i = 0, segment = filedata->program_headers;
i < filedata->file_header.e_phnum;
i++, segment++)
/* Find the file offset corresponding to VMA by using the program headers. */
static long
-offset_from_vma (Filedata * filedata, bfd_vma vma, bfd_size_type size)
+offset_from_vma (Filedata * filedata, bfd_vma vma, uint64_t size)
{
Elf_Internal_Phdr * seg;
}
static unsigned int ATTRIBUTE_WARN_UNUSED_RESULT
-get_compression_header (Elf_Internal_Chdr *chdr, unsigned char *buf, bfd_size_type size)
+get_compression_header (Elf_Internal_Chdr *chdr, unsigned char *buf,
+ uint64_t size)
{
if (is_32bit_elf)
{
#define CHECK_ENTSIZE_VALUES(section, i, size32, size64) \
do \
{ \
- bfd_size_type expected_entsize = is_32bit_elf ? size32 : size64; \
+ uint64_t expected_entsize = is_32bit_elf ? size32 : size64; \
if (section->sh_entsize != expected_entsize) \
{ \
error (_("Section %d has invalid sh_entsize of %" PRIx64 "\n"), \
i, (uint64_t) section->sh_entsize); \
error (_("(Using the expected size of %" PRIx64 " for the rest of this dump)\n"), \
- (uint64_t) expected_entsize); \
+ expected_entsize); \
section->sh_entsize = expected_entsize; \
} \
} \
}
static bfd_vma *
-get_dynamic_data (Filedata * filedata, bfd_size_type number, unsigned int ent_size)
+get_dynamic_data (Filedata * filedata, uint64_t number, unsigned int ent_size)
{
unsigned char * e_data;
bfd_vma * i_data;
- /* If the size_t type is smaller than the bfd_size_type, eg because
- you are building a 32-bit tool on a 64-bit host, then make sure
- that when (number) is cast to (size_t) no information is lost. */
- if (sizeof (size_t) < sizeof (bfd_size_type)
- && (bfd_size_type) ((size_t) number) != number)
+ /* If size_t is smaller than uint64_t, eg because you are building
+ on a 32-bit host, then make sure that when number is cast to
+ size_t no information is lost. */
+ if ((size_t) number != number
+ || ent_size * number / ent_size != number)
{
- error (_("Size truncation prevents reading %" PRIu64
+ error (_("Size overflow prevents reading %" PRIu64
" elements of size %u\n"),
- (uint64_t) number, ent_size);
+ number, ent_size);
return NULL;
}
if (ent_size * number > filedata->file_size)
{
error (_("Invalid number of dynamic entries: %" PRIu64 "\n"),
- (uint64_t) number);
+ number);
return NULL;
}
if (e_data == NULL)
{
error (_("Out of memory reading %" PRIu64 " dynamic entries\n"),
- (uint64_t) number);
+ number);
return NULL;
}
if (fread (e_data, ent_size, (size_t) number, filedata->handle) != number)
{
error (_("Unable to read in %" PRIu64 " bytes of dynamic data\n"),
- (uint64_t) number * ent_size);
+ number * ent_size);
free (e_data);
return NULL;
}
if (i_data == NULL)
{
error (_("Out of memory allocating space for %" PRIu64 " dynamic entries\n"),
- (uint64_t) number);
+ number);
free (e_data);
return NULL;
}
&& filedata->dynamic_info[DT_STRSZ])
{
unsigned long offset;
- bfd_size_type str_tab_len = filedata->dynamic_info[DT_STRSZ];
+ uint64_t str_tab_len = filedata->dynamic_info[DT_STRSZ];
offset = offset_from_vma (filedata,
filedata->dynamic_info[DT_STRTAB],
more relocations ? */
static bool
-apply_relocations (Filedata * filedata,
- const Elf_Internal_Shdr * section,
- unsigned char * start,
- bfd_size_type size,
- void ** relocs_return,
- unsigned long * num_relocs_return)
+apply_relocations (Filedata *filedata,
+ const Elf_Internal_Shdr *section,
+ unsigned char *start,
+ size_t size,
+ void **relocs_return,
+ unsigned long *num_relocs_return)
{
Elf_Internal_Shdr * relsec;
unsigned char * end = start + size;
static char *
get_section_contents (Elf_Internal_Shdr * section, Filedata * filedata)
{
- bfd_size_type num_bytes = section->sh_size;
+ uint64_t num_bytes = section->sh_size;
if (num_bytes == 0 || section->sh_type == SHT_NOBITS)
{
dump_section_as_strings (Elf_Internal_Shdr * section, Filedata * filedata)
{
Elf_Internal_Shdr *relsec;
- bfd_size_type num_bytes;
+ uint64_t num_bytes;
unsigned char *data;
unsigned char *end;
unsigned char *real_start;
Filedata *filedata,
bool relocate)
{
- Elf_Internal_Shdr * relsec;
- bfd_size_type bytes;
- bfd_size_type section_size;
- bfd_vma addr;
- unsigned char * data;
- unsigned char * real_start;
- unsigned char * start;
+ Elf_Internal_Shdr *relsec;
+ size_t bytes;
+ uint64_t section_size;
+ bfd_vma addr;
+ unsigned char *data;
+ unsigned char *real_start;
+ unsigned char *start;
real_start = start = (unsigned char *) get_section_contents (section, filedata);
if (start == NULL)
const char *name = (section_name_valid (filedata, section)
? section_name (filedata, section) : "");
const char *print_name = printable_section_name (filedata, section);
- bfd_size_type length;
+ uint64_t length;
bool result = true;
int i;
if (filedata->handle == NULL)
goto fail;
- filedata->file_size = (bfd_size_type) statbuf.st_size;
+ filedata->file_size = statbuf.st_size;
filedata->file_name = pathname;
filedata->is_separate = is_separate;
return false;
}
- filedata->file_size = (bfd_size_type) statbuf.st_size;
+ filedata->file_size = statbuf.st_size;
filedata->is_separate = false;
if (memcmp (armag, ARMAG, SARMAG) == 0)