#include <elfutils/debuginfod.h>
#endif
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+#ifndef CHAR_BIT
+#define CHAR_BIT 8
+#endif
+
#undef MAX
#undef MIN
#define MAX(a, b) ((a) > (b) ? (a) : (b))
int do_debug_cu_index;
int do_wide;
int do_debug_links;
-int do_follow_links;
+int do_follow_links = DEFAULT_FOR_FOLLOW_LINKS;
bfd_boolean do_checks;
int dwarf_cutoff_level = -1;
/* Read in a LEB128 encoded value starting at address DATA.
If SIGN is true, return a signed LEB128 value.
If LENGTH_RETURN is not NULL, return in it the number of bytes read.
- If STATUS_RETURN in not NULL, return with bit 0 (LSB) set if the
+ If STATUS_RETURN is not NULL, return with bit 0 (LSB) set if the
terminating byte was not found and with bit 1 set if the value
overflows a dwarf_vma.
No bytes will be read at address END or beyond. */
while (data < end)
{
unsigned char byte = *data++;
- bfd_boolean cont = (byte & 0x80) ? TRUE : FALSE;
+ unsigned char lost, mask;
- byte &= 0x7f;
num_read++;
- if (shift < sizeof (result) * 8)
+ if (shift < CHAR_BIT * sizeof (result))
{
- result |= ((dwarf_vma) byte) << shift;
- if (sign)
- {
- if ((((dwarf_signed_vma) result >> shift) & 0x7f) != byte)
- /* Overflow. */
- status |= 2;
- }
- else if ((result >> shift) != byte)
- {
- /* Overflow. */
- status |= 2;
- }
-
+ result |= ((dwarf_vma) (byte & 0x7f)) << shift;
+ /* These bits overflowed. */
+ lost = byte ^ (result >> shift);
+ /* And this is the mask of possible overflow bits. */
+ mask = 0x7f ^ ((dwarf_vma) 0x7f << shift >> shift);
shift += 7;
}
- else if (byte != 0)
+ else
{
- status |= 2;
+ lost = byte;
+ mask = 0x7f;
}
+ if ((lost & mask) != (sign && (dwarf_signed_vma) result < 0 ? mask : 0))
+ status |= 2;
- if (!cont)
+ if ((byte & 0x80) == 0)
{
status &= ~1;
- if (sign && (shift < 8 * sizeof (result)) && (byte & 0x40))
+ if (sign && shift < CHAR_BIT * sizeof (result) && (byte & 0x40))
result |= -((dwarf_vma) 1 << shift);
break;
}
SAFE_BYTE_GET_AND_INC (compunit.cu_pointer_size, hdrptr, 1, end);
bfd_boolean do_dwo_id = FALSE;
- uint64_t dwo_id;
+ uint64_t dwo_id = 0;
if (compunit.cu_unit_type == DW_UT_split_compile
|| compunit.cu_unit_type == DW_UT_skeleton)
{
else
entry_length = 4;
+ unsigned char *entries_end;
if (length == 0)
{
/* This is probably an old style .debug_str_offset section which
just contains offsets and no header (and the first offset is 0). */
length = section->size;
curr = section->start;
+ entries_end = end;
printf (_(" Length: %#lx\n"), (unsigned long) length);
printf (_(" Index Offset [String]\n"));
}
else
{
+ entries_end = curr + length;
+
int version;
SAFE_BYTE_GET_AND_INC (version, curr, 2, end);
if (version != 5)
printf (_(" Index Offset [String]\n"));
}
- for (idx = 0; length >= entry_length && curr < end; idx++)
+ for (idx = 0; curr < entries_end; idx++)
{
dwarf_vma offset;
const unsigned char * string;
+ if (curr + entry_length > entries_end)
+ /* Not enough space to read one entry_length, give up. */
+ return 0;
+
SAFE_BYTE_GET_AND_INC (offset, curr, entry_length, end);
if (dwo)
string = (const unsigned char *)
{ "links", & do_debug_links, 1 },
{ "loc", & do_debug_loc, 1 },
{ "macro", & do_debug_macinfo, 1 },
+ { "no-follow-links", & do_follow_links, 0 },
{ "pubnames", & do_debug_pubnames, 1 },
{ "pubtypes", & do_debug_pubtypes, 1 },
/* This entry is for compatibility
if (strncmp (p, entry->option, len) == 0
&& (p[len] == ',' || p[len] == '\0'))
{
- * entry->variable |= entry->val;
+ * entry->variable = entry->val;
/* The --debug-dump=frames-interp option also
enables the --debug-dump=frames option. */
case 'g': do_gdb_index = 1; break;
case 'i': do_debug_info = 1; break;
case 'K': do_follow_links = 1; break;
+ case 'N': do_follow_links = 0; break;
case 'k': do_debug_links = 1; break;
case 'l': do_debug_lines |= FLAG_DEBUG_LINES_RAW; break;
case 'L': do_debug_lines |= FLAG_DEBUG_LINES_DECODED; break;
do_debug_str_offsets = 1;
}
-#define NO_ABBREVS NULL, NULL, NULL, 0, 0, 0, NULL, 0, NULL
-#define ABBREV(N) NULL, NULL, NULL, 0, 0, N, NULL, 0, NULL
+#define NO_ABBREVS NULL, NULL, NULL, 0, 0, 0, NULL, 0
+#define ABBREV(N) NULL, NULL, NULL, 0, 0, N, NULL, 0
/* N.B. The order here must match the order in section_display_enum. */