return read_leb128 (data, length_return, FALSE, end);
}
+#define SKIP_ULEB() read_uleb128 (start, & length_return, end); start += length_return
+#define SKIP_SLEB() read_sleb128 (start, & length_return, end); start += length_return
+
+#define READ_ULEB(var) \
+ do \
+ { \
+ dwarf_vma _val; \
+ \
+ (var) = _val = read_uleb128 (start, &length_return, end); \
+ if ((var) != _val) \
+ error (_("Internal error: %s%d: LEB value (%#lx) too large for containing variable\n"), \
+ __FILE__, __LINE__, _val); \
+ start += length_return; \
+ } \
+ while (0)
+
+#define READ_SLEB(var) \
+ do \
+ { \
+ dwarf_signed_vma _val; \
+ \
+ (var) = _val = read_sleb128 (start, &length_return, end); \
+ if ((var) != _val) \
+ error (_("Internal error: %s%d: LEB value (%#lx) too large for containing variable\n"), \
+ __FILE__, __LINE__, _val); \
+ start += length_return; \
+ } \
+ while (0)
+
#define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END) \
do \
{ \
regname (unsigned int regno, int row)
{
static char reg[64];
+
if (dwarf_regnames
&& regno < dwarf_regnames_count
&& dwarf_regnames [regno] != NULL)
}
#define GET(VAR, N) SAFE_BYTE_GET_AND_INC (VAR, start, N, end)
-#define LEB() read_uleb128 (start, & length_return, end); start += length_return
-#define SLEB() read_sleb128 (start, & length_return, end); start += length_return
static unsigned char *
read_cie (unsigned char *start, unsigned char *end,
fc->ptr_size = eh_addr_size;
fc->segment_size = 0;
}
- fc->code_factor = LEB ();
- fc->data_factor = SLEB ();
+ READ_ULEB (fc->code_factor);
+ READ_SLEB (fc->data_factor);
if (version == 1)
{
GET (fc->ra, 1);
}
else
{
- fc->ra = LEB ();
+ READ_ULEB (fc->ra);
}
if (fc->augmentation[0] == 'z')
{
- augmentation_data_len = LEB ();
+ READ_ULEB (augmentation_data_len);
augmentation_data = start;
start += augmentation_data_len;
/* PR 17512: file: 11042-2589-0.004. */
if (start > end)
{
- warn (_("Augmentation data too long: 0x%lx\n"), augmentation_data_len);
+ warn (_("Augmentation data too long: %#lx, expected at most %#lx\n"),
+ augmentation_data_len, (long)((end - start) + augmentation_data_len));
return end;
}
}
if (cie->augmentation[0] == 'z')
{
- augmentation_data_len = LEB ();
+ READ_ULEB (augmentation_data_len);
augmentation_data = start;
start += augmentation_data_len;
/* PR 17512: file: 722-8446-0.004. */
case DW_CFA_advance_loc:
break;
case DW_CFA_offset:
- LEB ();
+ SKIP_ULEB ();
if (frame_need_space (fc, opa) >= 0)
fc->col_type[opa] = DW_CFA_undefined;
break;
break;
case DW_CFA_offset_extended:
case DW_CFA_val_offset:
- reg = LEB (); LEB ();
+ READ_ULEB (reg);
+ SKIP_ULEB ();
if (frame_need_space (fc, reg) >= 0)
fc->col_type[reg] = DW_CFA_undefined;
break;
case DW_CFA_restore_extended:
- reg = LEB ();
+ READ_ULEB (reg);
if (frame_need_space (fc, reg) >= 0)
fc->col_type[reg] = DW_CFA_undefined;
break;
case DW_CFA_undefined:
- reg = LEB ();
+ READ_ULEB (reg);
if (frame_need_space (fc, reg) >= 0)
fc->col_type[reg] = DW_CFA_undefined;
break;
case DW_CFA_same_value:
- reg = LEB ();
+ READ_ULEB (reg);
if (frame_need_space (fc, reg) >= 0)
fc->col_type[reg] = DW_CFA_undefined;
break;
case DW_CFA_register:
- reg = LEB (); LEB ();
+ READ_ULEB (reg);
+ SKIP_ULEB ();
if (frame_need_space (fc, reg) >= 0)
fc->col_type[reg] = DW_CFA_undefined;
break;
case DW_CFA_def_cfa:
- LEB (); LEB ();
+ SKIP_ULEB ();
+ SKIP_ULEB ();
break;
case DW_CFA_def_cfa_register:
- LEB ();
+ SKIP_ULEB ();
break;
case DW_CFA_def_cfa_offset:
- LEB ();
+ SKIP_ULEB ();
break;
case DW_CFA_def_cfa_expression:
- temp = LEB ();
+ READ_ULEB (temp);
new_start = start + temp;
if (new_start < start)
{
break;
case DW_CFA_expression:
case DW_CFA_val_expression:
- reg = LEB ();
- temp = LEB ();
+ READ_ULEB (reg);
+ READ_ULEB (temp);
new_start = start + temp;
if (new_start < start)
{
break;
case DW_CFA_offset_extended_sf:
case DW_CFA_val_offset_sf:
- reg = LEB (); SLEB ();
+ READ_ULEB (reg);
+ SKIP_SLEB ();
if (frame_need_space (fc, reg) >= 0)
fc->col_type[reg] = DW_CFA_undefined;
break;
case DW_CFA_def_cfa_sf:
- LEB (); SLEB ();
+ SKIP_ULEB ();
+ SKIP_SLEB ();
break;
case DW_CFA_def_cfa_offset_sf:
- SLEB ();
+ SKIP_SLEB ();
break;
case DW_CFA_MIPS_advance_loc8:
start += 8;
break;
case DW_CFA_GNU_args_size:
- LEB ();
+ SKIP_ULEB ();
break;
case DW_CFA_GNU_negative_offset_extended:
- reg = LEB (); LEB ();
+ READ_ULEB (reg);
+ SKIP_ULEB ();
if (frame_need_space (fc, reg) >= 0)
fc->col_type[reg] = DW_CFA_undefined;
break;
{
unsigned char * tmp;
unsigned op, opa;
- unsigned long ul, reg, roffs;
- dwarf_vma l;
+ unsigned long ul, roffs;
+ /* Note: It is tempting to use an unsigned long for 'reg' but there
+ are various functions, notably frame_space_needed() that assume that
+ reg is an unsigned int. */
+ unsigned int reg;
+ dwarf_signed_vma l;
dwarf_vma ofs;
dwarf_vma vma;
const char *reg_prefix = "";
break;
case DW_CFA_offset:
- roffs = LEB ();
+ READ_ULEB (roffs);
if (opa >= (unsigned int) fc->ncols)
reg_prefix = bad_reg;
if (! do_debug_frames_interp || *reg_prefix != '\0')
break;
case DW_CFA_offset_extended:
- reg = LEB ();
- roffs = LEB ();
+ READ_ULEB (reg);
+ READ_ULEB (roffs);
if (reg >= (unsigned int) fc->ncols)
reg_prefix = bad_reg;
if (! do_debug_frames_interp || *reg_prefix != '\0')
break;
case DW_CFA_val_offset:
- reg = LEB ();
- roffs = LEB ();
+ READ_ULEB (reg);
+ READ_ULEB (roffs);
if (reg >= (unsigned int) fc->ncols)
reg_prefix = bad_reg;
if (! do_debug_frames_interp || *reg_prefix != '\0')
break;
case DW_CFA_restore_extended:
- reg = LEB ();
+ READ_ULEB (reg);
if (reg >= (unsigned int) fc->ncols)
reg_prefix = bad_reg;
if (! do_debug_frames_interp || *reg_prefix != '\0')
break;
case DW_CFA_undefined:
- reg = LEB ();
+ READ_ULEB (reg);
if (reg >= (unsigned int) fc->ncols)
reg_prefix = bad_reg;
if (! do_debug_frames_interp || *reg_prefix != '\0')
break;
case DW_CFA_same_value:
- reg = LEB ();
+ READ_ULEB (reg);
if (reg >= (unsigned int) fc->ncols)
reg_prefix = bad_reg;
if (! do_debug_frames_interp || *reg_prefix != '\0')
break;
case DW_CFA_register:
- reg = LEB ();
- roffs = LEB ();
+ READ_ULEB (reg);
+ READ_ULEB (roffs);
if (reg >= (unsigned int) fc->ncols)
reg_prefix = bad_reg;
if (! do_debug_frames_interp || *reg_prefix != '\0')
break;
case DW_CFA_def_cfa:
- fc->cfa_reg = LEB ();
- fc->cfa_offset = LEB ();
+ READ_SLEB (fc->cfa_reg);
+ READ_ULEB (fc->cfa_offset);
fc->cfa_exp = 0;
if (! do_debug_frames_interp)
printf (" DW_CFA_def_cfa: %s ofs %d\n",
break;
case DW_CFA_def_cfa_register:
- fc->cfa_reg = LEB ();
+ READ_SLEB (fc->cfa_reg);
fc->cfa_exp = 0;
if (! do_debug_frames_interp)
printf (" DW_CFA_def_cfa_register: %s\n",
break;
case DW_CFA_def_cfa_offset:
- fc->cfa_offset = LEB ();
+ READ_ULEB (fc->cfa_offset);
if (! do_debug_frames_interp)
printf (" DW_CFA_def_cfa_offset: %d\n", (int) fc->cfa_offset);
break;
break;
case DW_CFA_def_cfa_expression:
- ul = LEB ();
+ READ_ULEB (ul);
if (start >= block_end || ul > (unsigned long) (block_end - start))
{
printf (_(" DW_CFA_def_cfa_expression: <corrupt len %lu>\n"), ul);
break;
case DW_CFA_expression:
- reg = LEB ();
- ul = LEB ();
+ READ_ULEB (reg);
+ READ_ULEB (ul);
if (reg >= (unsigned int) fc->ncols)
reg_prefix = bad_reg;
/* PR 17512: file: 069-133014-0.006. */
break;
case DW_CFA_val_expression:
- reg = LEB ();
- ul = LEB ();
+ READ_ULEB (reg);
+ READ_ULEB (ul);
if (reg >= (unsigned int) fc->ncols)
reg_prefix = bad_reg;
tmp = start + ul;
break;
case DW_CFA_offset_extended_sf:
- reg = LEB ();
- l = SLEB ();
+ READ_ULEB (reg);
+ READ_SLEB (l);
if (frame_need_space (fc, reg) < 0)
reg_prefix = bad_reg;
if (! do_debug_frames_interp || *reg_prefix != '\0')
break;
case DW_CFA_val_offset_sf:
- reg = LEB ();
- l = SLEB ();
+ READ_ULEB (reg);
+ READ_SLEB (l);
if (frame_need_space (fc, reg) < 0)
reg_prefix = bad_reg;
if (! do_debug_frames_interp || *reg_prefix != '\0')
break;
case DW_CFA_def_cfa_sf:
- fc->cfa_reg = LEB ();
- fc->cfa_offset = SLEB ();
+ READ_SLEB (fc->cfa_reg);
+ READ_ULEB (fc->cfa_offset);
fc->cfa_offset = fc->cfa_offset * fc->data_factor;
fc->cfa_exp = 0;
if (! do_debug_frames_interp)
break;
case DW_CFA_def_cfa_offset_sf:
- fc->cfa_offset = SLEB ();
+ READ_ULEB (fc->cfa_offset);
fc->cfa_offset *= fc->data_factor;
if (! do_debug_frames_interp)
printf (" DW_CFA_def_cfa_offset_sf: %d\n", (int) fc->cfa_offset);
break;
case DW_CFA_GNU_args_size:
- ul = LEB ();
+ READ_ULEB (ul);
if (! do_debug_frames_interp)
printf (" DW_CFA_GNU_args_size: %ld\n", ul);
break;
case DW_CFA_GNU_negative_offset_extended:
- reg = LEB ();
- l = - LEB ();
+ READ_ULEB (reg);
+ READ_SLEB (l);
+ l = - l;
if (frame_need_space (fc, reg) < 0)
reg_prefix = bad_reg;
if (! do_debug_frames_interp || *reg_prefix != '\0')
}
#undef GET
-#undef LEB
-#undef SLEB
static int
display_gdb_index (struct dwarf_section *section,