anevilyak+bonefish: Fix several instances of off-by-one errors when
computing the data block for CFA expressions. This fixes unwinding the stack frame on gcc4.4. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39047 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -430,6 +430,8 @@ DwarfFile::UnwindCallFrame(CompilationUnit* unit,
|
|||||||
bool dwarf64;
|
bool dwarf64;
|
||||||
off_t entryOffset = dataReader.Offset();
|
off_t entryOffset = dataReader.Offset();
|
||||||
uint64 length = dataReader.ReadInitialLength(dwarf64);
|
uint64 length = dataReader.ReadInitialLength(dwarf64);
|
||||||
|
TRACE_CFI("DwarfFile::UnwindCallFrame(): offset: %Lx, length: %Lx\n",
|
||||||
|
entryOffset, length);
|
||||||
if (length > (uint64)dataReader.BytesRemaining())
|
if (length > (uint64)dataReader.BytesRemaining())
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
off_t lengthOffset = dataReader.Offset();
|
off_t lengthOffset = dataReader.Offset();
|
||||||
@@ -443,8 +445,10 @@ DwarfFile::UnwindCallFrame(CompilationUnit* unit,
|
|||||||
? cieID == 0xffffffffffffffffULL
|
? cieID == 0xffffffffffffffffULL
|
||||||
: cieID == 0xffffffff)) {
|
: cieID == 0xffffffff)) {
|
||||||
// this is a CIE -- skip it
|
// this is a CIE -- skip it
|
||||||
|
TRACE_CFI("Skipping CIE: %Lx\n", cieID);
|
||||||
previousCIE = entryOffset;
|
previousCIE = entryOffset;
|
||||||
} else {
|
} else {
|
||||||
|
TRACE_CFI("Found FDE\n");
|
||||||
// this is a FDE
|
// this is a FDE
|
||||||
target_addr_t initialLocation = dataReader.ReadAddress(0);
|
target_addr_t initialLocation = dataReader.ReadAddress(0);
|
||||||
target_size_t addressRange = dataReader.ReadAddress(0);
|
target_size_t addressRange = dataReader.ReadAddress(0);
|
||||||
@@ -452,6 +456,8 @@ DwarfFile::UnwindCallFrame(CompilationUnit* unit,
|
|||||||
if (dataReader.HasOverflow())
|
if (dataReader.HasOverflow())
|
||||||
return B_BAD_DATA;
|
return B_BAD_DATA;
|
||||||
|
|
||||||
|
TRACE_CFI("location: %Lx, initial location: %Lx, address range: %Lx\n",
|
||||||
|
location, initialLocation, addressRange);
|
||||||
if (location >= initialLocation
|
if (location >= initialLocation
|
||||||
&& location < initialLocation + addressRange) {
|
&& location < initialLocation + addressRange) {
|
||||||
// This is the FDE we're looking for.
|
// This is the FDE we're looking for.
|
||||||
@@ -1656,8 +1662,8 @@ DwarfFile::_ParseFrameInfoInstructions(CompilationUnit* unit,
|
|||||||
}
|
}
|
||||||
case DW_CFA_def_cfa_expression:
|
case DW_CFA_def_cfa_expression:
|
||||||
{
|
{
|
||||||
uint8* block = (uint8*)dataReader.Data();
|
|
||||||
uint64 blockLength = dataReader.ReadUnsignedLEB128(0);
|
uint64 blockLength = dataReader.ReadUnsignedLEB128(0);
|
||||||
|
uint8* block = (uint8*)dataReader.Data();
|
||||||
dataReader.Skip(blockLength);
|
dataReader.Skip(blockLength);
|
||||||
|
|
||||||
TRACE_CFI(" DW_CFA_def_cfa_expression: %p, %llu\n",
|
TRACE_CFI(" DW_CFA_def_cfa_expression: %p, %llu\n",
|
||||||
@@ -1670,8 +1676,8 @@ DwarfFile::_ParseFrameInfoInstructions(CompilationUnit* unit,
|
|||||||
case DW_CFA_expression:
|
case DW_CFA_expression:
|
||||||
{
|
{
|
||||||
uint32 reg = dataReader.ReadUnsignedLEB128(0);
|
uint32 reg = dataReader.ReadUnsignedLEB128(0);
|
||||||
uint8* block = (uint8*)dataReader.Data();
|
|
||||||
uint64 blockLength = dataReader.ReadUnsignedLEB128(0);
|
uint64 blockLength = dataReader.ReadUnsignedLEB128(0);
|
||||||
|
uint8* block = (uint8*)dataReader.Data();
|
||||||
dataReader.Skip(blockLength);
|
dataReader.Skip(blockLength);
|
||||||
|
|
||||||
TRACE_CFI(" DW_CFA_expression: reg: %lu, block: %p, "
|
TRACE_CFI(" DW_CFA_expression: reg: %lu, block: %p, "
|
||||||
@@ -1752,8 +1758,8 @@ DwarfFile::_ParseFrameInfoInstructions(CompilationUnit* unit,
|
|||||||
case DW_CFA_val_expression:
|
case DW_CFA_val_expression:
|
||||||
{
|
{
|
||||||
uint32 reg = dataReader.ReadUnsignedLEB128(0);
|
uint32 reg = dataReader.ReadUnsignedLEB128(0);
|
||||||
uint8* block = (uint8*)dataReader.Data();
|
|
||||||
uint64 blockLength = dataReader.ReadUnsignedLEB128(0);
|
uint64 blockLength = dataReader.ReadUnsignedLEB128(0);
|
||||||
|
uint8* block = (uint8*)dataReader.Data();
|
||||||
dataReader.Skip(blockLength);
|
dataReader.Skip(blockLength);
|
||||||
|
|
||||||
TRACE_CFI(" DW_CFA_val_expression: reg: %lu, block: %p, "
|
TRACE_CFI(" DW_CFA_val_expression: reg: %lu, block: %p, "
|
||||||
|
|||||||
Reference in New Issue
Block a user