diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 61a4798a355..8164f0094b5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2007-01-24 Andreas Krebbel + + * unwind-dw2-fde.c (get_cie_encoding): Replaced _Unwind_Word with + _uleb128_t and _Unwind_SWord with _sleb128_t. + * unwind-dw2.c (extract_cie_info, execute_stack_op, execute_cfa_program, + uw_frame_state_for, uw_update_context_1): Likewise. + * unwind-c.c (parse_lsda_header, PERSONALITY_FUNCTION): Likewise. + * unwind-pe.h (read_uleb128, read_sleb128, + read_encoded_value_with_base): Likewise. + * unwind-generic.h: Define _sleb128_t and _uleb128_t types. + 2007-01-24 Richard Guenther * builtins.c (expand_builtin_cexpi): Get the fndecl diff --git a/gcc/unwind-c.c b/gcc/unwind-c.c index c8f34acc0ee..f287ea2d9e6 100644 --- a/gcc/unwind-c.c +++ b/gcc/unwind-c.c @@ -50,7 +50,7 @@ static const unsigned char * parse_lsda_header (struct _Unwind_Context *context, const unsigned char *p, lsda_header_info *info) { - _Unwind_Word tmp; + _uleb128_t tmp; unsigned char lpstart_encoding; info->Start = (context ? _Unwind_GetRegionStart (context) : 0); @@ -175,7 +175,7 @@ PERSONALITY_FUNCTION (int version, return _URC_CONTINUE_UNWIND; else { - _Unwind_Word cs_lp, cs_action; + _uleb128_t cs_lp, cs_action; do { p = read_uleb128 (p, &cs_lp); @@ -185,7 +185,7 @@ PERSONALITY_FUNCTION (int version, /* Can never have null landing pad for sjlj -- that would have been indicated by a -1 call site index. */ - landing_pad = cs_lp + 1; + landing_pad = (_Unwind_Ptr)cs_lp + 1; if (cs_action) action_record = info.action_table + cs_action - 1; goto found_something; @@ -195,7 +195,7 @@ PERSONALITY_FUNCTION (int version, while (p < info.action_table) { _Unwind_Ptr cs_start, cs_len, cs_lp; - _Unwind_Word cs_action; + _uleb128_t cs_action; /* Note that all call-site encodings are "absolute" displacements. */ p = read_encoded_value (0, info.call_site_encoding, p, &cs_start); diff --git a/gcc/unwind-dw2-fde.c b/gcc/unwind-dw2-fde.c index ace7a432577..880ba51bf38 100644 --- a/gcc/unwind-dw2-fde.c +++ b/gcc/unwind-dw2-fde.c @@ -266,8 +266,8 @@ get_cie_encoding (const struct dwarf_cie *cie) { const unsigned char *aug, *p; _Unwind_Ptr dummy; - _Unwind_Word utmp; - _Unwind_Sword stmp; + _uleb128_t utmp; + _sleb128_t stmp; aug = cie->augmentation; if (aug[0] != 'z') diff --git a/gcc/unwind-dw2.c b/gcc/unwind-dw2.c index da8289f794f..b40b16fda55 100644 --- a/gcc/unwind-dw2.c +++ b/gcc/unwind-dw2.c @@ -349,7 +349,8 @@ extract_cie_info (const struct dwarf_cie *cie, struct _Unwind_Context *context, const unsigned char *aug = cie->augmentation; const unsigned char *p = aug + strlen ((const char *)aug) + 1; const unsigned char *ret = NULL; - _Unwind_Word utmp; + _uleb128_t utmp; + _sleb128_t stmp; /* g++ v2 "eh" has pointer immediately following augmentation string, so it must be handled first. */ @@ -362,12 +363,17 @@ extract_cie_info (const struct dwarf_cie *cie, struct _Unwind_Context *context, /* Immediately following the augmentation are the code and data alignment and return address column. */ - p = read_uleb128 (p, &fs->code_align); - p = read_sleb128 (p, &fs->data_align); + p = read_uleb128 (p, &utmp); + fs->code_align = (_Unwind_Word)utmp; + p = read_sleb128 (p, &stmp); + fs->data_align = (_Unwind_Sword)stmp; if (cie->version == 1) fs->retaddr_column = *p++; else - p = read_uleb128 (p, &fs->retaddr_column); + { + p = read_uleb128 (p, &utmp); + fs->retaddr_column = (_Unwind_Word)utmp; + } fs->lsda_encoding = DW_EH_PE_omit; /* If the augmentation starts with 'z', then a uleb128 immediately @@ -442,8 +448,9 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end, while (op_ptr < op_end) { enum dwarf_location_atom op = *op_ptr++; - _Unwind_Word result, reg, utmp; - _Unwind_Sword offset, stmp; + _Unwind_Word result; + _uleb128_t reg, utmp; + _sleb128_t offset, stmp; switch (op) { @@ -520,11 +527,12 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end, op_ptr += 8; break; case DW_OP_constu: - op_ptr = read_uleb128 (op_ptr, &result); + op_ptr = read_uleb128 (op_ptr, &utmp); + result = (_Unwind_Word)utmp; break; case DW_OP_consts: op_ptr = read_sleb128 (op_ptr, &stmp); - result = stmp; + result = (_Unwind_Sword)stmp; break; case DW_OP_reg0: @@ -604,7 +612,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end, case DW_OP_bregx: op_ptr = read_uleb128 (op_ptr, ®); op_ptr = read_sleb128 (op_ptr, &offset); - result = _Unwind_GetGR (context, reg) + offset; + result = _Unwind_GetGR (context, reg) + (_Unwind_Word)offset; break; case DW_OP_dup: @@ -698,7 +706,7 @@ execute_stack_op (const unsigned char *op_ptr, const unsigned char *op_end, break; case DW_OP_plus_uconst: op_ptr = read_uleb128 (op_ptr, &utmp); - result += utmp; + result += (_Unwind_Word)utmp; break; default: @@ -857,8 +865,8 @@ execute_cfa_program (const unsigned char *insn_ptr, && fs->pc < context->ra + _Unwind_IsSignalFrame (context)) { unsigned char insn = *insn_ptr++; - _Unwind_Word reg, utmp; - _Unwind_Sword offset, stmp; + _uleb128_t reg, utmp; + _sleb128_t offset, stmp; if ((insn & 0xc0) == DW_CFA_advance_loc) fs->pc += (insn & 0x3f) * fs->code_align; @@ -928,11 +936,12 @@ execute_cfa_program (const unsigned char *insn_ptr, case DW_CFA_register: { - _Unwind_Word reg2; + _uleb128_t reg2; insn_ptr = read_uleb128 (insn_ptr, ®); insn_ptr = read_uleb128 (insn_ptr, ®2); fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].how = REG_SAVED_REG; - fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].loc.reg = reg2; + fs->regs.reg[DWARF_REG_TO_UNWIND_COLUMN (reg)].loc.reg = + (_Unwind_Word)reg2; } break; @@ -962,14 +971,16 @@ execute_cfa_program (const unsigned char *insn_ptr, break; case DW_CFA_def_cfa: - insn_ptr = read_uleb128 (insn_ptr, &fs->regs.cfa_reg); insn_ptr = read_uleb128 (insn_ptr, &utmp); - fs->regs.cfa_offset = utmp; + fs->regs.cfa_reg = (_Unwind_Word)utmp; + insn_ptr = read_uleb128 (insn_ptr, &utmp); + fs->regs.cfa_offset = (_Unwind_Word)utmp; fs->regs.cfa_how = CFA_REG_OFFSET; break; case DW_CFA_def_cfa_register: - insn_ptr = read_uleb128 (insn_ptr, &fs->regs.cfa_reg); + insn_ptr = read_uleb128 (insn_ptr, &utmp); + fs->regs.cfa_reg = (_Unwind_Word)utmp; fs->regs.cfa_how = CFA_REG_OFFSET; break; @@ -1005,14 +1016,17 @@ execute_cfa_program (const unsigned char *insn_ptr, break; case DW_CFA_def_cfa_sf: - insn_ptr = read_uleb128 (insn_ptr, &fs->regs.cfa_reg); - insn_ptr = read_sleb128 (insn_ptr, &fs->regs.cfa_offset); + insn_ptr = read_uleb128 (insn_ptr, &utmp); + fs->regs.cfa_reg = (_Unwind_Word)utmp; + insn_ptr = read_sleb128 (insn_ptr, &stmp); + fs->regs.cfa_offset = (_Unwind_Sword)stmp; fs->regs.cfa_how = CFA_REG_OFFSET; fs->regs.cfa_offset *= fs->data_align; break; case DW_CFA_def_cfa_offset_sf: - insn_ptr = read_sleb128 (insn_ptr, &fs->regs.cfa_offset); + insn_ptr = read_sleb128 (insn_ptr, &stmp); + fs->regs.cfa_offset = (_Unwind_Sword)stmp; fs->regs.cfa_offset *= fs->data_align; /* cfa_how deliberately not set. */ break; @@ -1054,7 +1068,8 @@ execute_cfa_program (const unsigned char *insn_ptr, break; case DW_CFA_GNU_args_size: - insn_ptr = read_uleb128 (insn_ptr, &context->args_size); + insn_ptr = read_uleb128 (insn_ptr, &utmp); + context->args_size = (_Unwind_Word)utmp; break; case DW_CFA_GNU_negative_offset_extended: @@ -1125,7 +1140,7 @@ uw_frame_state_for (struct _Unwind_Context *context, _Unwind_FrameState *fs) insn = NULL; if (fs->saw_z) { - _Unwind_Word i; + _uleb128_t i; aug = read_uleb128 (aug, &i); insn = aug + i; } @@ -1268,7 +1283,7 @@ uw_update_context_1 (struct _Unwind_Context *context, _Unwind_FrameState *fs) case CFA_EXP: { const unsigned char *exp = fs->regs.cfa_exp; - _Unwind_Word len; + _uleb128_t len; exp = read_uleb128 (exp, &len); cfa = (void *) (_Unwind_Ptr) @@ -1307,7 +1322,7 @@ uw_update_context_1 (struct _Unwind_Context *context, _Unwind_FrameState *fs) case REG_SAVED_EXP: { const unsigned char *exp = fs->regs.reg[i].loc.exp; - _Unwind_Word len; + _uleb128_t len; _Unwind_Ptr val; exp = read_uleb128 (exp, &len); @@ -1326,7 +1341,7 @@ uw_update_context_1 (struct _Unwind_Context *context, _Unwind_FrameState *fs) case REG_SAVED_VAL_EXP: { const unsigned char *exp = fs->regs.reg[i].loc.exp; - _Unwind_Word len; + _uleb128_t len; _Unwind_Ptr val; exp = read_uleb128 (exp, &len); diff --git a/gcc/unwind-generic.h b/gcc/unwind-generic.h index 3f4c06530ce..1218d8c2b53 100644 --- a/gcc/unwind-generic.h +++ b/gcc/unwind-generic.h @@ -230,6 +230,35 @@ extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *); contains it. */ extern void * _Unwind_FindEnclosingFunction (void *pc); +#ifndef __SIZEOF_LONG__ + #error "__SIZEOF_LONG__ macro not defined" +#endif + +#ifndef __SIZEOF_POINTER__ + #error "__SIZEOF_POINTER__ macro not defined" +#endif + + +/* leb128 type numbers have a potentially unlimited size. + The target of the following definitions of _sleb128_t and _uleb128_t + is to have efficient data types large enough to hold the leb128 type + numbers used in the unwind code. + Mostly these types will simply be defined to long and unsigned long + except when a unsigned long data type on the target machine is not + capable of storing a pointer. */ + +#if __SIZEOF_LONG__ < __SIZEOF_POINTER__ +#ifdef HAVE_LONG_LONG + typedef long long _sleb128_t; + typedef unsigned long long _uleb128_t; +#else + #error "long long data type is needed to define _sleb128_t" +#endif +#else + typedef long _sleb128_t; + typedef unsigned long _uleb128_t; +#endif + #ifdef __cplusplus } #endif diff --git a/gcc/unwind-pe.h b/gcc/unwind-pe.h index 8cd3fcdfb24..9c56af08486 100644 --- a/gcc/unwind-pe.h +++ b/gcc/unwind-pe.h @@ -130,17 +130,17 @@ base_of_encoded_value (unsigned char encoding, struct _Unwind_Context *context) pointers should not be leb128 encoded on that target. */ static const unsigned char * -read_uleb128 (const unsigned char *p, _Unwind_Word *val) +read_uleb128 (const unsigned char *p, _uleb128_t *val) { unsigned int shift = 0; unsigned char byte; - _Unwind_Word result; + _uleb128_t result; result = 0; do { byte = *p++; - result |= ((_Unwind_Word)byte & 0x7f) << shift; + result |= ((_uleb128_t)byte & 0x7f) << shift; shift += 7; } while (byte & 0x80); @@ -152,26 +152,26 @@ read_uleb128 (const unsigned char *p, _Unwind_Word *val) /* Similar, but read a signed leb128 value. */ static const unsigned char * -read_sleb128 (const unsigned char *p, _Unwind_Sword *val) +read_sleb128 (const unsigned char *p, _sleb128_t *val) { unsigned int shift = 0; unsigned char byte; - _Unwind_Word result; + _uleb128_t result; result = 0; do { byte = *p++; - result |= ((_Unwind_Word)byte & 0x7f) << shift; + result |= ((_uleb128_t)byte & 0x7f) << shift; shift += 7; } while (byte & 0x80); /* Sign-extend a negative value. */ if (shift < 8 * sizeof(result) && (byte & 0x40) != 0) - result |= -(((_Unwind_Word)1L) << shift); + result |= -(((_uleb128_t)1L) << shift); - *val = (_Unwind_Sword) result; + *val = (_sleb128_t) result; return p; } @@ -215,7 +215,7 @@ read_encoded_value_with_base (unsigned char encoding, _Unwind_Ptr base, case DW_EH_PE_uleb128: { - _Unwind_Word tmp; + _uleb128_t tmp; p = read_uleb128 (p, &tmp); result = (_Unwind_Internal_Ptr) tmp; } @@ -223,7 +223,7 @@ read_encoded_value_with_base (unsigned char encoding, _Unwind_Ptr base, case DW_EH_PE_sleb128: { - _Unwind_Sword tmp; + _sleb128_t tmp; p = read_sleb128 (p, &tmp); result = (_Unwind_Internal_Ptr) tmp; } diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 9b785af5f3e..63b3f01a982 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2007-01-24 Andreas Krebbel + + * exception.cc (parse_lsda_header, PERSONALITY_FUNCTION): Replaced + _Unwind_Word with _uleb128_t and _Unwind_SWord with _sleb128_t. + 2007-01-23 H.J. Lu PR libgcj/30550 diff --git a/libjava/exception.cc b/libjava/exception.cc index 3d8fda1d790..4875dfde52f 100644 --- a/libjava/exception.cc +++ b/libjava/exception.cc @@ -128,7 +128,7 @@ static const unsigned char * parse_lsda_header (_Unwind_Context *context, const unsigned char *p, lsda_header_info *info) { - _Unwind_Word tmp; + _uleb128_t tmp; unsigned char lpstart_encoding; info->Start = (context ? _Unwind_GetRegionStart (context) : 0); @@ -251,7 +251,7 @@ PERSONALITY_FUNCTION (int version, return _URC_CONTINUE_UNWIND; else { - _Unwind_Word cs_lp, cs_action; + _uleb128_t cs_lp, cs_action; do { p = read_uleb128 (p, &cs_lp); @@ -271,7 +271,7 @@ PERSONALITY_FUNCTION (int version, while (p < info.action_table) { _Unwind_Ptr cs_start, cs_len, cs_lp; - _Unwind_Word cs_action; + _uleb128_t cs_action; // Note that all call-site encodings are "absolute" displacements. p = read_encoded_value (0, info.call_site_encoding, p, &cs_start); @@ -317,7 +317,7 @@ PERSONALITY_FUNCTION (int version, else { // Otherwise we have a catch handler. - _Unwind_Sword ar_filter, ar_disp; + _sleb128_t ar_filter, ar_disp; while (1) { diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8cf4f9287a8..56f746ab993 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2007-01-24 Andreas Krebbel + + * libsupc++/eh_personality.cc (parse_lsda_header, check_exception_spec, + get_ttype_entry, empty_exception_spec, PERSONALITY_FUNCTION): Replaced + _Unwind_Word with _uleb128_t and _Unwind_SWord with _sleb128_t. + 2007-01-22 Paolo Carlini * include/bits/stl_algobase.h (__fill_aux(unsigned char*, diff --git a/libstdc++-v3/libsupc++/eh_personality.cc b/libstdc++-v3/libsupc++/eh_personality.cc index 9b0654b8875..1e7cc8034df 100644 --- a/libstdc++-v3/libsupc++/eh_personality.cc +++ b/libstdc++-v3/libsupc++/eh_personality.cc @@ -56,7 +56,7 @@ static const unsigned char * parse_lsda_header (_Unwind_Context *context, const unsigned char *p, lsda_header_info *info) { - _Unwind_Word tmp; + _uleb128_t tmp; unsigned char lpstart_encoding; info->Start = (context ? _Unwind_GetRegionStart (context) : 0); @@ -92,7 +92,7 @@ parse_lsda_header (_Unwind_Context *context, const unsigned char *p, // Return an element from a type table. static const std::type_info* -get_ttype_entry(lsda_header_info* info, _Unwind_Word i) +get_ttype_entry(lsda_header_info* info, _uleb128_t i) { _Unwind_Ptr ptr; @@ -112,15 +112,15 @@ typedef _Unwind_Control_Block _throw_typet; static bool check_exception_spec(lsda_header_info* info, _throw_typet* throw_type, - void* thrown_ptr, _Unwind_Sword filter_value) + void* thrown_ptr, _sleb128_t filter_value) { - const _Unwind_Word* e = ((const _Unwind_Word*) info->TType) + const _uleb128_t* e = ((const _uleb128_t*) info->TType) - filter_value - 1; while (1) { const std::type_info* catch_type; - _Unwind_Word tmp; + _uleb128_t tmp; tmp = *e; @@ -210,7 +210,7 @@ typedef const std::type_info _throw_typet; // Return an element from a type table. static const std::type_info * -get_ttype_entry (lsda_header_info *info, _Unwind_Word i) +get_ttype_entry (lsda_header_info *info, _uleb128_t i) { _Unwind_Ptr ptr; @@ -253,14 +253,14 @@ get_adjusted_ptr (const std::type_info *catch_type, static bool check_exception_spec(lsda_header_info* info, _throw_typet* throw_type, - void* thrown_ptr, _Unwind_Sword filter_value) + void* thrown_ptr, _sleb128_t filter_value) { const unsigned char *e = info->TType - filter_value - 1; while (1) { const std::type_info *catch_type; - _Unwind_Word tmp; + _uleb128_t tmp; e = read_uleb128 (e, &tmp); @@ -329,7 +329,7 @@ static bool empty_exception_spec (lsda_header_info *info, _Unwind_Sword filter_value) { const unsigned char *e = info->TType - filter_value - 1; - _Unwind_Word tmp; + _uleb128_t tmp; e = read_uleb128 (e, &tmp); return tmp == 0; @@ -489,7 +489,7 @@ PERSONALITY_FUNCTION (int version, while (p < info.action_table) { _Unwind_Ptr cs_start, cs_len, cs_lp; - _Unwind_Word cs_action; + _uleb128_t cs_action; // Note that all call-site encodings are "absolute" displacements. p = read_encoded_value (0, info.call_site_encoding, p, &cs_start); @@ -535,7 +535,7 @@ PERSONALITY_FUNCTION (int version, { // Otherwise we have a catch handler or exception specification. - _Unwind_Sword ar_filter, ar_disp; + _sleb128_t ar_filter, ar_disp; const std::type_info* catch_type; _throw_typet* throw_type; bool saw_cleanup = false;