1 // Copyright 2016 the V8 project authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "src/diagnostics/eh-frame.h" 6 7 namespace v8 { 8 namespace internal { 9 10 static const int kR0DwarfCode = 0; 11 static const int kFpDwarfCode = 11; 12 static const int kSpDwarfCode = 13; 13 static const int kLrDwarfCode = 14; 14 15 const int EhFrameConstants::kCodeAlignmentFactor = 4; 16 const int EhFrameConstants::kDataAlignmentFactor = -4; 17 WriteReturnAddressRegisterCode()18void EhFrameWriter::WriteReturnAddressRegisterCode() { 19 WriteULeb128(kLrDwarfCode); 20 } 21 WriteInitialStateInCie()22void EhFrameWriter::WriteInitialStateInCie() { 23 SetBaseAddressRegisterAndOffset(fp, 0); 24 RecordRegisterNotModified(lr); 25 } 26 27 // static RegisterToDwarfCode(Register name)28int EhFrameWriter::RegisterToDwarfCode(Register name) { 29 switch (name.code()) { 30 case kRegCode_fp: 31 return kFpDwarfCode; 32 case kRegCode_sp: 33 return kSpDwarfCode; 34 case kRegCode_lr: 35 return kLrDwarfCode; 36 case kRegCode_r0: 37 return kR0DwarfCode; 38 default: 39 UNIMPLEMENTED(); 40 } 41 } 42 43 #ifdef ENABLE_DISASSEMBLER 44 45 // static DwarfRegisterCodeToString(int code)46const char* EhFrameDisassembler::DwarfRegisterCodeToString(int code) { 47 switch (code) { 48 case kFpDwarfCode: 49 return "fp"; 50 case kSpDwarfCode: 51 return "sp"; 52 case kLrDwarfCode: 53 return "lr"; 54 default: 55 UNIMPLEMENTED(); 56 } 57 } 58 59 #endif 60 61 } // namespace internal 62 } // namespace v8 63