ARC: dw2 unwind: factor CIE specifics for .eh_frame/.debug_frame
This paves way for switching to .eh_frame based unwindiing Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
This commit is contained in:
parent
94f4fb0841
commit
d040876b4a
@ -111,6 +111,8 @@ UNW_REGISTER_INFO};
|
|||||||
#define DW_EH_PE_indirect 0x80
|
#define DW_EH_PE_indirect 0x80
|
||||||
#define DW_EH_PE_omit 0xff
|
#define DW_EH_PE_omit 0xff
|
||||||
|
|
||||||
|
#define CIE_ID 0xffffffffUL
|
||||||
|
|
||||||
typedef unsigned long uleb128_t;
|
typedef unsigned long uleb128_t;
|
||||||
typedef signed long sleb128_t;
|
typedef signed long sleb128_t;
|
||||||
|
|
||||||
@ -232,6 +234,7 @@ void __init arc_unwind_init(void)
|
|||||||
|
|
||||||
static const u32 bad_cie, not_fde;
|
static const u32 bad_cie, not_fde;
|
||||||
static const u32 *cie_for_fde(const u32 *fde, const struct unwind_table *);
|
static const u32 *cie_for_fde(const u32 *fde, const struct unwind_table *);
|
||||||
|
static const u32 *__cie_for_fde(const u32 *fde);
|
||||||
static signed fde_pointer_type(const u32 *cie);
|
static signed fde_pointer_type(const u32 *cie);
|
||||||
|
|
||||||
struct eh_frame_hdr_table_entry {
|
struct eh_frame_hdr_table_entry {
|
||||||
@ -338,10 +341,9 @@ static void init_unwind_hdr(struct unwind_table *table,
|
|||||||
for (fde = table->address, tableSize = table->size, n = 0;
|
for (fde = table->address, tableSize = table->size, n = 0;
|
||||||
tableSize;
|
tableSize;
|
||||||
tableSize -= sizeof(*fde) + *fde, fde += 1 + *fde / sizeof(*fde)) {
|
tableSize -= sizeof(*fde) + *fde, fde += 1 + *fde / sizeof(*fde)) {
|
||||||
/* const u32 *cie = fde + 1 - fde[1] / sizeof(*fde); */
|
const u32 *cie = __cie_for_fde(fde);
|
||||||
const u32 *cie = (const u32 *)(fde[1]);
|
|
||||||
|
|
||||||
if (fde[1] == 0xffffffff)
|
if (fde[1] == CIE_ID)
|
||||||
continue; /* this is a CIE */
|
continue; /* this is a CIE */
|
||||||
ptr = (const u8 *)(fde + 2);
|
ptr = (const u8 *)(fde + 2);
|
||||||
header->table[n].start = read_pointer(&ptr,
|
header->table[n].start = read_pointer(&ptr,
|
||||||
@ -504,6 +506,16 @@ static sleb128_t get_sleb128(const u8 **pcur, const u8 *end)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const u32 *__cie_for_fde(const u32 *fde)
|
||||||
|
{
|
||||||
|
const u32 *cie;
|
||||||
|
|
||||||
|
/* cie = fde + 1 - fde[1] / sizeof(*fde); */
|
||||||
|
cie = (u32 *) fde[1];
|
||||||
|
|
||||||
|
return cie;
|
||||||
|
}
|
||||||
|
|
||||||
static const u32 *cie_for_fde(const u32 *fde, const struct unwind_table *table)
|
static const u32 *cie_for_fde(const u32 *fde, const struct unwind_table *table)
|
||||||
{
|
{
|
||||||
const u32 *cie;
|
const u32 *cie;
|
||||||
@ -511,19 +523,18 @@ static const u32 *cie_for_fde(const u32 *fde, const struct unwind_table *table)
|
|||||||
if (!*fde || (*fde & (sizeof(*fde) - 1)))
|
if (!*fde || (*fde & (sizeof(*fde) - 1)))
|
||||||
return &bad_cie;
|
return &bad_cie;
|
||||||
|
|
||||||
if (fde[1] == 0xffffffff)
|
if (fde[1] == CIE_ID)
|
||||||
return ¬_fde; /* this is a CIE */
|
return ¬_fde; /* this is a CIE */
|
||||||
|
|
||||||
if ((fde[1] & (sizeof(*fde) - 1)))
|
if ((fde[1] & (sizeof(*fde) - 1)))
|
||||||
/* || fde[1] > (unsigned long)(fde + 1) - (unsigned long)table->address) */
|
/* || fde[1] > (unsigned long)(fde + 1) - (unsigned long)table->address) */
|
||||||
return NULL; /* this is not a valid FDE */
|
return NULL; /* this is not a valid FDE */
|
||||||
|
|
||||||
/* cie = fde + 1 - fde[1] / sizeof(*fde); */
|
cie = __cie_for_fde(fde);
|
||||||
cie = (u32 *) fde[1];
|
|
||||||
|
|
||||||
if (*cie <= sizeof(*cie) + 4 || *cie >= fde[1] - sizeof(*fde)
|
if (*cie <= sizeof(*cie) + 4 || *cie >= fde[1] - sizeof(*fde)
|
||||||
|| (*cie & (sizeof(*cie) - 1))
|
|| (*cie & (sizeof(*cie) - 1))
|
||||||
|| (cie[1] != 0xffffffff))
|
|| (cie[1] != CIE_ID))
|
||||||
return NULL; /* this is not a (valid) CIE */
|
return NULL; /* this is not a (valid) CIE */
|
||||||
return cie;
|
return cie;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user