Chromium Code Reviews| Index: src/eh-frame.cc |
| diff --git a/src/eh-frame.cc b/src/eh-frame.cc |
| index af85e0b8d5f7143beb3c5243513a69fef0f5f919..04b8b457bf0bbaaf03d2a24a187b92cf7007ca48 100644 |
| --- a/src/eh-frame.cc |
| +++ b/src/eh-frame.cc |
| @@ -3,21 +3,457 @@ |
| // found in the LICENSE file. |
| #include "src/eh-frame.h" |
| -#include "src/objects-inl.h" |
| -#include "src/objects.h" |
| + |
| +#include <iomanip> |
| +#include <ostream> |
| + |
| +#if !defined(V8_TARGET_ARCH_X64) && !defined(V8_TARGET_ARCH_ARM) && \ |
| + !defined(V8_TARGET_ARCH_ARM64) |
| + |
| +// Placeholders for unsupported architectures. |
| + |
| +namespace v8 { |
| +namespace internal { |
| + |
| +STATIC_CONST_MEMBER_DEFINITION const int EhFrameWriter::kDataAlignmentFactor = |
| + 1; |
| + |
| +void EhFrameWriter::WriteReturnAddressRegisterCode() { UNIMPLEMENTED(); } |
| + |
| +void EhFrameWriter::WriteInitialState() { UNIMPLEMENTED(); } |
| + |
| +const char* EhFrameWriter::DwarfRegisterCodeToString(int) { |
| + UNIMPLEMENTED(); |
| + return nullptr; |
| +} |
| + |
| +int EhFrameWriter::RegisterToDwarfCode(Register) { |
| + UNIMPLEMENTED(); |
| + return -1; |
| +} |
| + |
| +} // namespace internal |
| +} // namespace v8 |
| + |
| +#endif |
| namespace v8 { |
| namespace internal { |
| -static const int DW_EH_PE_pcrel = 0x10; |
| -static const int DW_EH_PE_datarel = 0x30; |
| -static const int DW_EH_PE_udata4 = 0x03; |
| -static const int DW_EH_PE_sdata4 = 0x0b; |
| +STATIC_CONST_MEMBER_DEFINITION const int EhFrameWriter::kTerminatorSize; |
| +STATIC_CONST_MEMBER_DEFINITION const uint32_t EhFrameWriter::kInt32Placeholder; |
|
rmcilroy
2016/07/05 10:56:12
I don't think you need these do you?
Stefano Sanfilippo
2016/07/05 16:02:13
Unfortunately I do, otherwise I get a linking erro
|
| + |
| +EhFrameWriter::EhFrameWriter() |
| + : last_pc_offset_(0), |
| + eh_frame_finalised_(false), |
| + base_register_(no_reg), |
| + base_offset_(0) { |
|
rmcilroy
2016/07/05 10:56:12
Set cie_size_ to zero here, to ensure they are pro
Stefano Sanfilippo
2016/07/05 16:02:13
Done.
|
| + eh_frame_buffer_.reserve(100); |
|
rmcilroy
2016/07/05 10:56:12
100 seems slightly random. Why not 128?
Stefano Sanfilippo
2016/07/05 16:02:13
I observed that the eh_frame for our code objects
rmcilroy
2016/07/06 13:59:30
64 in that case seems reasonable in that case (see
Stefano Sanfilippo
2016/07/06 16:54:49
Done, I went with 128 so we are covered in almost
|
| + int cie_start_offset = eh_frame_offset(); |
| + WriteCIE(); |
| + cie_size_ = eh_frame_offset() - cie_start_offset; |
|
rmcilroy
2016/07/05 10:56:12
Set this in WriteCIE ?
Stefano Sanfilippo
2016/07/05 16:02:13
Done.
|
| + WriteFDEHeader(); |
| +} |
| + |
| +void EhFrameWriter::WriteCIE() { |
| + static const int kCIEIdentifier = 0; |
| + static const int kCIEVersion = 3; |
| + static const int kCodeAlignmentFactor = 1; |
| + static const int kAugmentationDataSize = 2; |
| + static const byte kAugmentationString[] = {'z', 'L', 'R', 0}; |
| + |
| + int cie_size_offset = eh_frame_offset(); |
| + WriteInt32(kInt32Placeholder); |
| + int cie_start_offset = eh_frame_offset(); |
| + WriteInt32(kCIEIdentifier); |
| + WriteByte(kCIEVersion); |
| + WriteBytes(&kAugmentationString[0], sizeof(kAugmentationString)); |
| + WriteSLEB128(kCodeAlignmentFactor); |
| + WriteSLEB128(kDataAlignmentFactor); |
| + WriteReturnAddressRegisterCode(); |
| + WriteByte(kAugmentationDataSize); |
| + WriteByte(kOmit); |
| + WriteByte(kSData4 | kPcRel); |
| + DCHECK_EQ(eh_frame_offset() - cie_size_offset, kInitialStateOffsetInCIE); |
| + WriteInitialState(); |
| + Align(); |
| + int cie_end_offset = eh_frame_offset(); |
| + int encoded_cie_size = cie_end_offset - cie_start_offset; |
| + PatchInt32(cie_size_offset, encoded_cie_size); |
|
rmcilroy
2016/07/05 10:56:12
Some whitespace would be good to break up this cod
Stefano Sanfilippo
2016/07/05 16:02:13
Done.
|
| +} |
| + |
| +void EhFrameWriter::WriteFDEHeader() { |
| + DCHECK_EQ(eh_frame_offset(), fde_offset()); |
|
rmcilroy
2016/07/05 10:56:12
DCHECK_NE(cie_size_, 0)
Stefano Sanfilippo
2016/07/05 16:02:13
Done.
|
| + WriteInt32(kInt32Placeholder); // Placeholder for size of the FDE |
| + WriteInt32(cie_size_ + kInt32Size); // Backwards offset to the CIE |
| + DCHECK_EQ(eh_frame_offset(), procedure_address_offset()); |
| + WriteInt32(kInt32Placeholder); // Placeholder for pointer to procedure |
| + DCHECK_EQ(eh_frame_offset(), procedure_size_offset()); |
| + WriteInt32(kInt32Placeholder); // Placeholder for size of the procedure |
| + WriteByte(0); // No augmentation data |
|
rmcilroy
2016/07/05 10:56:12
Newlines between each of these fields, with commen
Stefano Sanfilippo
2016/07/05 16:02:13
Done.
|
| +} |
| + |
| +void EhFrameWriter::Align() { |
| + DCHECK(!eh_frame_finalised_); |
| + |
| + int unpadded_size = eh_frame_offset(); |
| + int padded_size = RoundUp(unpadded_size, 8); |
| + int padding_size = padded_size - unpadded_size; |
| -const int EhFrameHdr::kCIESize = 0; |
| + static const byte kPadding[] = {kNop, kNop, kNop, kNop, |
| + kNop, kNop, kNop, kNop}; |
| + DCHECK_LE(padding_size, static_cast<int>(sizeof(kPadding))); |
| + WriteBytes(&kPadding[0], padding_size); |
| +} |
| + |
| +void EhFrameWriter::AdvanceLocation(int pc_offset) { |
| + DCHECK(!eh_frame_finalised_); |
| + DCHECK_GE(pc_offset, last_pc_offset_); |
| + uint32_t delta = pc_offset - last_pc_offset_; |
| + |
| + if (delta <= kLocationMask) { |
| + WriteByte((kLocationTag << kLocationMaskSize) | (delta & kLocationMask)); |
| + } else if (delta <= kMaxUInt8) { |
| + WriteByte(kAdvanceLoc1); |
| + WriteByte(delta); |
| + } else if (delta <= kMaxUInt16) { |
| + WriteByte(kAdvanceLoc2); |
| + WriteInt16(delta); |
| + } else { |
| + WriteByte(kAdvanceLoc4); |
| + WriteInt32(delta); |
| + } |
| + |
| + last_pc_offset_ = pc_offset; |
| +} |
| + |
| +void EhFrameWriter::SetBaseAddressOffset(int base_offset) { |
| + DCHECK(!eh_frame_finalised_); |
| + DCHECK_GE(base_offset, 0); |
| + WriteByte(kDefCfaOffset); |
| + WriteULEB128(base_offset); |
| + base_offset_ = base_offset; |
| +} |
| + |
| +void EhFrameWriter::SetBaseAddressRegister(Register base_register) { |
| + DCHECK(!eh_frame_finalised_); |
| + int code = RegisterToDwarfCode(base_register); |
| + WriteByte(kDefCfaRegister); |
| + WriteULEB128(code); |
| + base_register_ = base_register; |
| +} |
| + |
| +void EhFrameWriter::SetBaseAddressRegisterAndOffset(Register base_register, |
| + int base_offset) { |
| + DCHECK(!eh_frame_finalised_); |
| + int code = RegisterToDwarfCode(base_register); |
| + WriteByte(kDefCfa); |
| + WriteULEB128(code); |
| + WriteULEB128(base_offset); |
| + base_offset_ = base_offset; |
| + base_register_ = base_register; |
| +} |
| -static const int kVersionSize = 1; |
| -static const int kEncodingSpecifiersSize = 3; |
| +void EhFrameWriter::RegisterSavedToStack(int register_code, int offset) { |
|
rmcilroy
2016/07/05 10:56:12
RecordRegisterSavedToStack
Stefano Sanfilippo
2016/07/05 16:02:13
Done.
|
| + DCHECK(!eh_frame_finalised_); |
| + DCHECK_EQ(offset % kDataAlignmentFactor, 0); |
| + int factored_offset = offset / std::abs(kDataAlignmentFactor); |
| + if (factored_offset >= 0) { |
| + DCHECK_LE(register_code, kSavedRegisterMask); |
| + WriteByte((kSavedRegisterTag << kSavedRegisterMaskSize) | |
| + (register_code & kSavedRegisterMask)); |
| + WriteULEB128(factored_offset); |
| + } else { |
| + WriteByte(kOffsetExtendedSf); |
| + WriteULEB128(register_code); |
| + WriteSLEB128(factored_offset); |
| + } |
| +} |
| + |
| +void EhFrameWriter::RegisterIsValid(Register name) { |
|
rmcilroy
2016/07/05 10:56:12
RecordRegisterIsValid
Stefano Sanfilippo
2016/07/05 16:02:13
Done.
|
| + int code = RegisterToDwarfCode(name); |
| + DCHECK(!eh_frame_finalised_); |
| + DCHECK_GE(code, 0); |
| + WriteByte(kSameValue); |
| + WriteULEB128(code); |
| +} |
| + |
| +void EhFrameWriter::Finish(int code_size) { |
| + DCHECK(!eh_frame_finalised_); |
| + DCHECK_GE(eh_frame_offset(), cie_size_); |
| + |
| + Align(); |
| + |
| + // Write the size of the FDE now that we know it. |
| + int fde_size = eh_frame_offset() - fde_offset(); |
| + PatchInt32(fde_offset(), fde_size); |
| + |
| + // Write the size and offset to procedure. |
| + PatchInt32(procedure_address_offset(), |
| + -(RoundUp(code_size, 8) + procedure_address_offset())); |
| + PatchInt32(procedure_size_offset(), code_size); |
| + |
| + // Terminate the .eh_frame. |
| + static const byte kTerminator[kTerminatorSize] = {0}; |
| + WriteBytes(&kTerminator[0], kTerminatorSize); |
| + |
| + // Write .eh_frame_hdr |
| + EhFrameHdr eh_frame_hdr(code_size, eh_frame_offset(), cie_size_); |
| + WriteBytes(reinterpret_cast<const byte*>(&eh_frame_hdr), |
| + EhFrameHdr::kRecordSize); |
| + |
| + eh_frame_finalised_ = true; |
| +} |
| + |
| +void EhFrameWriter::GetEhFrame(CodeDesc* desc) { |
| + DCHECK(eh_frame_finalised_); |
| + desc->unwinding_info_size = static_cast<int>(eh_frame_buffer_.size()); |
| + desc->unwinding_info = eh_frame_buffer_.data(); |
| +} |
| + |
| +void EhFrameWriter::WriteULEB128(uint32_t value) { |
| + do { |
| + byte chunk = value & 0x7f; |
| + value >>= 7; |
| + if (value != 0) chunk |= 0x80; |
| + eh_frame_buffer_.push_back(chunk); |
| + } while (value != 0); |
| +} |
| + |
| +void EhFrameWriter::WriteSLEB128(int32_t value) { |
| + static const int kSignBitMask = 0x40; |
| + bool done; |
| + do { |
| + byte chunk = value & 0x7f; |
| + value >>= 7; |
| + done = ((value == 0) && ((chunk & kSignBitMask) == 0)) || |
| + ((value == -1) && ((chunk & kSignBitMask) != 0)); |
| + if (!done) chunk |= 0x80; |
| + eh_frame_buffer_.push_back(chunk); |
| + } while (!done); |
| +} |
| + |
| +// static |
| +uint32_t EhFrameWriter::DecodeULEB128(const byte* encoded, int* encoded_size) { |
| + const byte* current = encoded; |
| + uint32_t result = 0; |
| + int shift = 0; |
| + |
| + do { |
| + DCHECK_LT(shift, 8 * static_cast<int>(sizeof(result))); |
| + result |= (*current & 0x7f) << shift; |
| + shift += 7; |
| + } while (*current++ >= 128); |
| + |
| + DCHECK_NOT_NULL(encoded_size); |
| + *encoded_size = static_cast<int>(current - encoded); |
| + |
| + return result; |
| +} |
| + |
| +// static |
| +int32_t EhFrameWriter::DecodeSLEB128(const byte* encoded, int* encoded_size) { |
| + static const byte kSignBitMask = 0x40; |
| + |
| + const byte* current = encoded; |
| + int32_t result = 0; |
| + int shift = 0; |
| + byte chunk; |
| + |
| + do { |
| + chunk = *current++; |
| + DCHECK_LT(shift, 8 * static_cast<int>(sizeof(result))); |
| + result |= (chunk & 0x7f) << shift; |
| + shift += 7; |
| + } while (chunk >= 128); |
| + |
| + // Sign extend the result if the last chunk has the sign bit set. |
| + if (chunk & kSignBitMask) result |= (~0ull) << shift; |
| + |
| + DCHECK_NOT_NULL(encoded_size); |
| + *encoded_size = static_cast<int>(current - encoded); |
| + |
| + return result; |
| +} |
| + |
| +#ifdef ENABLE_DISASSEMBLER |
| + |
| +namespace { |
| + |
| +class StreamModifiersScope final { |
| + public: |
| + explicit StreamModifiersScope(std::ostream* stream) |
| + : stream_(stream), flags_(stream->flags()) {} |
| + ~StreamModifiersScope() { stream_->flags(flags_); } |
| + |
| + private: |
| + std::ostream* stream_; |
| + std::ios::fmtflags flags_; |
| +}; |
| + |
| +} // namespace |
| + |
| +// static |
| +void EhFrameWriter::DumpDWARFDirectives(std::ostream& stream, // NOLINT |
| + const byte* begin, const byte* end) { |
| + StreamModifiersScope modifiers_scope(&stream); |
| + |
| + const byte* cur = begin; |
| + uint32_t offset_in_procedure = 0; |
| + |
| + while (cur != end) { |
| + stream << reinterpret_cast<const void*>(cur) << " "; |
| + |
| + if (((*cur >> kLocationMaskSize) & 0xff) == kLocationTag) { |
| + int value = *cur & kLocationMask; |
| + cur += sizeof(byte); |
| + offset_in_procedure += value; |
| + stream << "| pc_offset=" << std::dec << offset_in_procedure |
| + << " (delta=0x" << std::hex << value << ")\n"; |
| + continue; |
| + } |
| + |
| + if (((*cur >> kSavedRegisterMaskSize) & 0xff) == kSavedRegisterTag) { |
| + stream << "| " << DwarfRegisterCodeToString(*cur & kLocationMask); |
| + cur += sizeof(byte); |
| + int decoded_size = 0; |
| + int decoded_offset = static_cast<int>(DecodeULEB128(cur, &decoded_size)); |
| + cur += decoded_size; |
| + stream << " saved at base" << std::showpos << std::dec |
| + << decoded_offset * kDataAlignmentFactor << '\n'; |
| + continue; |
| + } |
| + |
| + uint8_t bytecode = *cur; |
| + cur += sizeof(byte); |
| + |
| + switch (bytecode) { |
| + case kOffsetExtendedSf: { |
| + int decoded_size = 0; |
| + stream << "| " |
| + << DwarfRegisterCodeToString(DecodeULEB128(cur, &decoded_size)); |
| + cur += decoded_size; |
| + int32_t decoded_offset = DecodeSLEB128(cur, &decoded_size); |
| + cur += decoded_size; |
| + stream << " saved at base" << std::showpos << std::dec |
| + << decoded_offset * kDataAlignmentFactor << '\n'; |
| + } |
| + case kAdvanceLoc1: { |
| + unsigned value = *reinterpret_cast<const uint8_t*>(cur); |
| + cur += sizeof(uint8_t); |
| + offset_in_procedure += value; |
| + stream << "| pc_offset=" << std::dec << offset_in_procedure |
| + << " (delta=0x" << std::hex << value << ")\n"; |
| + break; |
| + } |
| + case kAdvanceLoc2: { |
| + uint16_t value = ReadUnalignedUInt16(cur); |
| + cur += sizeof(uint16_t); |
| + offset_in_procedure += value; |
| + stream << "| pc_offset=" << std::dec << offset_in_procedure |
| + << " (delta=0x" << std::hex << value << ")\n"; |
| + break; |
| + } |
| + case kAdvanceLoc4: { |
| + uint32_t value = ReadUnalignedUInt32(cur); |
| + offset_in_procedure += value; |
| + cur += sizeof(uint32_t); |
| + stream << "| pc_offset=" << std::dec << offset_in_procedure |
| + << " (delta=0x" << std::hex << value << ")\n"; |
| + break; |
| + } |
| + case kDefCfa: { |
| + int decoded_size = 0; |
| + int base_register = DecodeULEB128(cur, &decoded_size); |
| + cur += decoded_size; |
| + int base_offset = DecodeULEB128(cur, &decoded_size); |
| + cur += decoded_size; |
| + stream << "| base_register=" << DwarfRegisterCodeToString(base_register) |
| + << ", base_offset=0x" << std::hex << base_offset << '\n'; |
| + break; |
| + } |
| + case kDefCfaOffset: { |
| + int decoded_size = 0; |
| + stream << "| base_offset=0x" << std::hex |
| + << DecodeULEB128(cur, &decoded_size) << '\n'; |
| + cur += decoded_size; |
| + break; |
| + } |
| + case kDefCfaRegister: { |
| + int decoded_size = 0; |
| + stream << "| base_register=" |
| + << DwarfRegisterCodeToString(DecodeULEB128(cur, &decoded_size)) |
| + << '\n'; |
| + cur += decoded_size; |
| + break; |
| + } |
| + case kSameValue: { |
| + int decoded_size = 0; |
| + stream << "| " |
| + << DwarfRegisterCodeToString(DecodeULEB128(cur, &decoded_size)) |
| + << " to initial value\n"; |
| + cur += decoded_size; |
| + break; |
| + } |
| + case kNop: |
| + stream << "| nop\n"; |
| + break; |
| + default: |
| + UNREACHABLE(); |
| + return; |
| + } |
| + } |
| +} |
| + |
| +// static |
| +void EhFrameWriter::DisassembleToStream(std::ostream& stream, // NOLINT |
| + const byte* start, const byte* end) { |
| + // The encoded CIE size does not include the size field itself. |
| + const int cie_size = ReadUnalignedUInt32(start) + kInt32Size; |
| + const int fde_offset = cie_size; |
| + |
| + const byte* cie_directives_start = start + kInitialStateOffsetInCIE; |
| + const byte* cie_directives_end = start + cie_size; |
| + DCHECK_LE(cie_directives_start, cie_directives_end); |
| + |
| + stream << reinterpret_cast<const void*>(start) << " .eh_frame: CIE\n"; |
| + DumpDWARFDirectives(stream, cie_directives_start, cie_directives_end); |
| + |
| + const byte* procedure_offset_address = |
| + start + fde_offset + kProcedureAddressOffsetInFde; |
| + int32_t procedure_offset = |
| + ReadUnalignedValue<int32_t>(procedure_offset_address); |
| + |
| + const byte* procedure_size_address = |
| + start + fde_offset + kProcedureSizeOffsetInFde; |
| + uint32_t procedure_size = ReadUnalignedUInt32(procedure_size_address); |
| + |
| + const byte* fde_start = start + fde_offset; |
| + stream << reinterpret_cast<const void*>(fde_start) << " .eh_frame: FDE\n" |
| + << reinterpret_cast<const void*>(procedure_offset_address) |
| + << " | procedure offset=" << procedure_offset << '\n' |
| + << reinterpret_cast<const void*>(procedure_size_address) |
| + << " | procedure size=" << procedure_size << '\n'; |
| + |
| + const int fde_directives_offset = fde_offset + 4 * kInt32Size + 1; |
| + |
| + const byte* fde_directives_start = start + fde_directives_offset; |
| + const byte* fde_directives_end = |
| + end - EhFrameHdr::kRecordSize - kTerminatorSize; |
| + DCHECK_LE(fde_directives_start, fde_directives_end); |
| + |
| + DumpDWARFDirectives(stream, fde_directives_start, fde_directives_end); |
| + |
| + const byte* fde_terminator_start = fde_directives_end; |
| + stream << reinterpret_cast<const void*>(fde_terminator_start) |
| + << " .eh_frame: terminator\n"; |
| + |
| + const byte* eh_frame_hdr_start = fde_terminator_start + kTerminatorSize; |
| + stream << reinterpret_cast<const void*>(eh_frame_hdr_start) |
| + << " .eh_frame_hdr: placeholder\n"; |
| +} |
| + |
| +#endif |
| // |
| // In order to calculate offsets in the .eh_frame_hdr, we must know the layout |
| @@ -51,45 +487,51 @@ static const int kEncodingSpecifiersSize = 3; |
| // +---------------+ | |
| // | ... | ... |
| // |
| -// (F) is aligned at a 16-byte boundary. |
| -// (D) is aligned at a 8-byte boundary. |
| -// (B) is aligned at a 4-byte boundary. |
| -// (E), (C) and (A) have no alignment requirements. |
| +// (F) is aligned to a 16-byte boundary. |
| +// (D) is aligned to a 8-byte boundary. |
| +// (B) is aligned to a 4-byte boundary. |
| +// (C) is aligned to an addressing unit size boundary. |
| +// (E) and (A) have no alignment requirements. |
| // |
| // The distance between (A) and (B) is 4 bytes. |
| // |
| -// The size of the .eh_frame is required to be a multiple of the pointer size, |
| -// which means that (B) will be naturally aligned to a 4-byte boundary on all |
| -// the architectures we support. |
| +// The size of the FDE is required to be a multiple of the pointer size, which |
| +// means that (B) will be naturally aligned to a 4-byte boundary on all the |
| +// architectures we support. |
| // |
| // Because (E) has no alignment requirements, there is padding between (E) and |
| // (D). (F) is aligned at a 16-byte boundary, thus to a 8-byte one as well. |
| // |
| -EhFrameHdr::EhFrameHdr(Code* code) { |
| - int code_size = code->is_crankshafted() ? code->safepoint_table_offset() |
| - : code->instruction_size(); |
| - version_ = 1; |
| - eh_frame_ptr_encoding_ = DW_EH_PE_sdata4 | DW_EH_PE_pcrel; |
| - lut_size_encoding_ = DW_EH_PE_udata4; |
| - lut_entries_encoding_ = DW_EH_PE_sdata4 | DW_EH_PE_datarel; |
| - |
| - // .eh_frame pointer and LUT |
| - if (code->has_unwinding_info()) { |
| - DCHECK_GE(code->unwinding_info_size(), EhFrameHdr::kRecordSize); |
| - int eh_frame_size = code->unwinding_info_size() - EhFrameHdr::kRecordSize; |
| - |
| - offset_to_eh_frame_ = |
| - -(eh_frame_size + kVersionSize + kEncodingSpecifiersSize); // A -> D |
| - lut_entries_number_ = 1; |
| - offset_to_procedure_ = -(RoundUp(code_size, 8) + eh_frame_size); // B -> F |
| - offset_to_fde_ = -(eh_frame_size - kCIESize); // B -> C |
| - } else { |
| - // Create a dummy table |
| - offset_to_eh_frame_ = 0; |
| - lut_entries_number_ = 0; |
| - offset_to_procedure_ = 0; |
| - offset_to_fde_ = 0; |
| - } |
| +EhFrameHdr::EhFrameHdr(int code_size, int eh_frame_size, int cie_size) { |
| + static const int kFdeVersionSize = 1; |
| + static const int kFdeEncodingSpecifiersSize = 3; |
| + |
| + version_ = kEhFrameHdrVersion; |
| + |
| + eh_frame_ptr_encoding_ = EhFrameWriter::kSData4 | EhFrameWriter::kPcRel; |
| + lut_size_encoding_ = EhFrameWriter::kUData4; |
| + lut_entries_encoding_ = EhFrameWriter::kSData4 | EhFrameWriter::kDataRel; |
| + offset_to_eh_frame_ = -(eh_frame_size + kFdeVersionSize + |
| + kFdeEncodingSpecifiersSize); // A -> D |
| + lut_entries_number_ = 1; |
| + offset_to_procedure_ = -(RoundUp(code_size, 8) + eh_frame_size); // B -> F |
| + offset_to_fde_ = -(eh_frame_size - cie_size); // B -> C |
| +} |
| + |
| +// static |
| +EhFrameHdr EhFrameHdr::CreateEmptyHeader() { |
| + EhFrameHdr dummy_frame; |
| + dummy_frame.version_ = kEhFrameHdrVersion; |
| + dummy_frame.eh_frame_ptr_encoding_ = |
| + EhFrameWriter::kSData4 | EhFrameWriter::kPcRel; |
| + dummy_frame.lut_size_encoding_ = EhFrameWriter::kUData4; |
| + dummy_frame.lut_entries_encoding_ = |
| + EhFrameWriter::kSData4 | EhFrameWriter::kDataRel; |
| + dummy_frame.offset_to_eh_frame_ = 0; |
| + dummy_frame.lut_entries_number_ = 0; |
| + dummy_frame.offset_to_procedure_ = 0; |
| + dummy_frame.offset_to_fde_ = 0; |
| + return dummy_frame; |
| } |
| } // namespace internal |