Make dwarf_vma uint64_t

This replaces dwarf_vma, dwarf_size_type and dwarf_signed_vma with
uint64_t and int64_t everywhere.  The patch also gets rid of
DWARF_VMA_FMT since we can't use that with uint64_t, and all of the
configure support for deciding the flavour of HOST_WIDEST_INT.
dwarf_vmatoa also disappears, replacing most uses with one of
PRIx64, PRId64 or PRIu64.  Printing of size_t and ptrdiff_t values
now use %z and %t rather than by casting to unsigned long.  Also,
most warning messages that used 0x%lx or similar now use %#lx and a
few that didn't print the 0x hex prefix now also use %#.  The patch
doesn't change normal readelf output, except in odd cases where values
previously might have been truncated.
This commit is contained in:
Alan Modra 2022-08-12 17:47:51 +09:30
parent 625d49fce7
commit 31e5a3a380
8 changed files with 935 additions and 1306 deletions

View File

@ -185,12 +185,6 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG
/* The size of `long long', as computed by sizeof. */
#undef SIZEOF_LONG_LONG
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS

254
binutils/configure vendored
View File

@ -1980,189 +1980,6 @@ $as_echo "$ac_res" >&6; }
} # ac_fn_c_check_func
# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
# --------------------------------------------
# Tries to find the compile-time value of EXPR in a program that includes
# INCLUDES, setting VAR accordingly. Returns whether the value could be
# computed
ac_fn_c_compute_int ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if test "$cross_compiling" = yes; then
# Depending upon the size, compute the lo and hi bounds.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) >= 0)];
test_array [0] = 0;
return test_array [0];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_lo=0 ac_mid=0
while :; do
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) <= $ac_mid)];
test_array [0] = 0;
return test_array [0];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_hi=$ac_mid; break
else
as_fn_arith $ac_mid + 1 && ac_lo=$as_val
if test $ac_lo -le $ac_mid; then
ac_lo= ac_hi=
break
fi
as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) < 0)];
test_array [0] = 0;
return test_array [0];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_hi=-1 ac_mid=-1
while :; do
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) >= $ac_mid)];
test_array [0] = 0;
return test_array [0];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_lo=$ac_mid; break
else
as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
if test $ac_mid -le $ac_hi; then
ac_lo= ac_hi=
break
fi
as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
else
ac_lo= ac_hi=
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
# Binary search between lo and hi bounds.
while test "x$ac_lo" != "x$ac_hi"; do
as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) <= $ac_mid)];
test_array [0] = 0;
return test_array [0];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_hi=$ac_mid
else
as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
case $ac_lo in #((
?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
'') ac_retval=1 ;;
esac
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
static long int longval () { return $2; }
static unsigned long int ulongval () { return $2; }
#include <stdio.h>
#include <stdlib.h>
int
main ()
{
FILE *f = fopen ("conftest.val", "w");
if (! f)
return 1;
if (($2) < 0)
{
long int i = longval ();
if (i != ($2))
return 1;
fprintf (f, "%ld", i);
}
else
{
unsigned long int i = ulongval ();
if (i != ($2))
return 1;
fprintf (f, "%lu", i);
}
/* Do not output a trailing newline, as this causes \r\n confusion
on some platforms. */
return ferror (f) || fclose (f) != 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
echo >>conftest.val; read $3 <conftest.val; ac_retval=0
else
ac_retval=1
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
rm -f conftest.val
fi
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_compute_int
# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
# ----------------------------------------------------
# Tries to find if the field MEMBER exists in type AGGR, after including
@ -10987,7 +10804,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 10990 "configure"
#line 10807 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -11093,7 +10910,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11096 "configure"
#line 10913 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -13024,73 +12841,6 @@ case "${host}" in
esac
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5
$as_echo_n "checking size of long... " >&6; }
if ${ac_cv_sizeof_long+:} false; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long" "$ac_includes_default"; then :
else
if test "$ac_cv_type_long" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (long)
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_long=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5
$as_echo "$ac_cv_sizeof_long" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_LONG $ac_cv_sizeof_long
_ACEOF
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5
$as_echo_n "checking size of long long... " >&6; }
if ${ac_cv_sizeof_long_long+:} false; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then :
else
if test "$ac_cv_type_long_long" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (long long)
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_long_long=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5
$as_echo "$ac_cv_sizeof_long_long" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long
_ACEOF
# We use headers from include/ that check various HAVE_*_H macros, thus
# should ensure they are set by configure. This is true even when C99
# guarantees they are available.

View File

@ -174,9 +174,6 @@ case "${host}" in
esac
AC_SUBST(DEMANGLER_NAME)
AC_CHECK_SIZEOF([long])
AC_CHECK_SIZEOF([long long])
# We use headers from include/ that check various HAVE_*_H macros, thus
# should ensure they are set by configure. This is true even when C99
# guarantees they are available.

File diff suppressed because it is too large Load Diff

View File

@ -20,18 +20,14 @@
#include "dwarf2.h" /* for enum dwarf_unit_type */
typedef unsigned HOST_WIDEST_INT dwarf_vma;
typedef HOST_WIDEST_INT dwarf_signed_vma;
typedef unsigned HOST_WIDEST_INT dwarf_size_type;
/* Structure found in the .debug_line section. */
typedef struct
{
dwarf_vma li_length;
uint64_t li_length;
unsigned short li_version;
unsigned char li_address_size;
unsigned char li_segment_size;
dwarf_vma li_prologue_length;
uint64_t li_prologue_length;
unsigned char li_min_insn_length;
unsigned char li_max_ops_per_insn;
unsigned char li_default_is_stmt;
@ -45,19 +41,19 @@ DWARF2_Internal_LineInfo;
/* Structure found in .debug_pubnames section. */
typedef struct
{
dwarf_vma pn_length;
uint64_t pn_length;
unsigned short pn_version;
dwarf_vma pn_offset;
dwarf_vma pn_size;
uint64_t pn_offset;
uint64_t pn_size;
}
DWARF2_Internal_PubNames;
/* Structure found in .debug_info section. */
typedef struct
{
dwarf_vma cu_length;
uint64_t cu_length;
unsigned short cu_version;
dwarf_vma cu_abbrev_offset;
uint64_t cu_abbrev_offset;
unsigned char cu_pointer_size;
enum dwarf_unit_type cu_unit_type;
}
@ -66,9 +62,9 @@ DWARF2_Internal_CompUnit;
/* Structure found in .debug_aranges section. */
typedef struct
{
dwarf_vma ar_length;
uint64_t ar_length;
unsigned short ar_version;
dwarf_vma ar_info_offset;
uint64_t ar_info_offset;
unsigned char ar_pointer_size;
unsigned char ar_segment_size;
}
@ -143,8 +139,8 @@ struct dwarf_section
file containing the section. */
const char * filename;
unsigned char * start;
dwarf_vma address;
dwarf_size_type size;
uint64_t address;
uint64_t size;
enum dwarf_section_display_enum abbrev_sec;
/* Used by clients to help them implement the reloc_at callback. */
void * reloc_info;
@ -170,32 +166,32 @@ typedef struct
unsigned int pointer_size;
unsigned int offset_size;
int dwarf_version;
dwarf_vma cu_offset;
dwarf_vma base_address;
uint64_t cu_offset;
uint64_t base_address;
/* This field is filled in when reading the attribute DW_AT_GNU_addr_base and
is used with the form DW_FORM_GNU_addr_index. */
dwarf_vma addr_base;
uint64_t addr_base;
/* This field is filled in when reading the attribute DW_AT_GNU_ranges_base and
is used when calculating ranges. */
dwarf_vma ranges_base;
uint64_t ranges_base;
/* This is an array of offsets to the location list table. */
dwarf_vma * loc_offsets;
uint64_t * loc_offsets;
/* This is an array of offsets to the location view table. */
dwarf_vma * loc_views;
uint64_t * loc_views;
int * have_frame_base;
/* Information for associating location lists with CUs. */
unsigned int num_loc_offsets;
unsigned int max_loc_offsets;
unsigned int num_loc_views;
dwarf_vma loclists_base;
uint64_t loclists_base;
/* List of .debug_ranges offsets seen in this .debug_info. */
dwarf_vma * range_lists;
uint64_t * range_lists;
unsigned int num_range_lists;
unsigned int max_range_lists;
dwarf_vma rnglists_base;
dwarf_vma str_offsets_base;
uint64_t rnglists_base;
uint64_t str_offsets_base;
}
debug_info;
@ -268,10 +264,10 @@ extern void * xcrealloc (void *, size_t, size_t);
/* A callback into the client. Returns TRUE if there is a
relocation against the given debug section at the given
offset. */
extern bool reloc_at (struct dwarf_section *, dwarf_vma);
extern bool reloc_at (struct dwarf_section *, uint64_t);
extern dwarf_vma read_leb128 (unsigned char *, const unsigned char *const,
bool, unsigned int *, int *);
extern uint64_t read_leb128 (unsigned char *, const unsigned char *const,
bool, unsigned int *, int *);
#if HAVE_LIBDEBUGINFOD
extern unsigned char * get_build_id (void *);
@ -307,7 +303,7 @@ report_leb_status (int status)
#define READ_ULEB(var, start, end) \
do \
{ \
dwarf_vma _val; \
uint64_t _val; \
unsigned int _len; \
int _status; \
\
@ -323,7 +319,7 @@ report_leb_status (int status)
#define READ_SLEB(var, start, end) \
do \
{ \
dwarf_signed_vma _val; \
int64_t _val; \
unsigned int _len; \
int _status; \
\

View File

@ -4043,7 +4043,7 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
}
bool
reloc_at (struct dwarf_section * dsec, dwarf_vma offset)
reloc_at (struct dwarf_section * dsec, uint64_t offset)
{
arelent ** relocs;
arelent * rp;

View File

@ -13372,14 +13372,14 @@ display_lto_symtab (Filedata * filedata,
unsigned int sym_type = * ext_data ++;
unsigned int sec_kind = * ext_data ++;
printf (" %10s %10s %11s %08lx %08lx %9s %08lx _",
printf (" %10s %10s %11s %08" PRIx64 " %08" PRIx64 " %9s %08x _",
* comdat_key == 0 ? "-" : (char *) comdat_key,
get_lto_kind (kind),
get_lto_visibility (visibility),
(long) size,
(long) slot,
size,
slot,
get_lto_sym_type (sym_type),
(long) sec_kind);
sec_kind);
print_symbol (6, (const char *) sym_name);
}
else
@ -13391,12 +13391,12 @@ display_lto_symtab (Filedata * filedata,
}
else
{
printf (" %10s %10s %11s %08lx %08lx _",
printf (" %10s %10s %11s %08" PRIx64 " %08" PRIx64 " _",
* comdat_key == 0 ? "-" : (char *) comdat_key,
get_lto_kind (kind),
get_lto_visibility (visibility),
(long) size,
(long) slot);
size,
slot);
print_symbol (21, (const char *) sym_name);
}
putchar ('\n');
@ -14808,7 +14808,7 @@ is_none_reloc (Filedata * filedata, unsigned int reloc_type)
section NAME at OFFSET bytes. */
bool
reloc_at (struct dwarf_section * dsec, dwarf_vma offset)
reloc_at (struct dwarf_section * dsec, uint64_t offset)
{
Elf_Internal_Rela * relocs;
Elf_Internal_Rela * rp;
@ -15119,13 +15119,13 @@ get_section_contents (Elf_Internal_Shdr * section, Filedata * filedata)
/* Uncompresses a section that was compressed using zlib, in place. */
static bool
uncompress_section_contents (unsigned char ** buffer,
dwarf_size_type uncompressed_size,
dwarf_size_type * size)
uncompress_section_contents (unsigned char **buffer,
uint64_t uncompressed_size,
uint64_t *size)
{
dwarf_size_type compressed_size = *size;
unsigned char * compressed_buffer = *buffer;
unsigned char * uncompressed_buffer;
uint64_t compressed_size = *size;
unsigned char *compressed_buffer = *buffer;
unsigned char *uncompressed_buffer;
z_stream strm;
int rc;
@ -15198,8 +15198,8 @@ dump_section_as_strings (Elf_Internal_Shdr * section, Filedata * filedata)
if (decompress_dumps)
{
dwarf_size_type new_size = num_bytes;
dwarf_size_type uncompressed_size = 0;
uint64_t new_size = num_bytes;
uint64_t uncompressed_size = 0;
if ((section->sh_flags & SHF_COMPRESSED) != 0)
{
@ -15414,8 +15414,8 @@ dump_section_as_bytes (Elf_Internal_Shdr *section,
if (decompress_dumps)
{
dwarf_size_type new_size = section_size;
dwarf_size_type uncompressed_size = 0;
uint64_t new_size = section_size;
uint64_t uncompressed_size = 0;
if ((section->sh_flags & SHF_COMPRESSED) != 0)
{
@ -15792,8 +15792,8 @@ load_specific_debug_section (enum dwarf_section_display_enum debug,
else
{
unsigned char *start = section->start;
dwarf_size_type size = sec->sh_size;
dwarf_size_type uncompressed_size = 0;
uint64_t size = sec->sh_size;
uint64_t uncompressed_size = 0;
if ((sec->sh_flags & SHF_COMPRESSED) != 0)
{

View File

@ -120,14 +120,6 @@ extern char **environ;
#include <limits.h>
#if SIZEOF_LONG_LONG > SIZEOF_LONG
/* We can't use any bfd types here since readelf may define BFD64 and
objdump may not. */
#define HOST_WIDEST_INT long long
#else
#define HOST_WIDEST_INT long
#endif
#define POISON_BFD_BOOLEAN 1
#endif /* _BIN_SYSDEP_H */