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/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 return -1; 41 } 42 } 43 44 #ifdef ENABLE_DISASSEMBLER 45 46 // static DwarfRegisterCodeToString(int code)47const char* EhFrameDisassembler::DwarfRegisterCodeToString(int code) { 48 switch (code) { 49 case kFpDwarfCode: 50 return "fp"; 51 case kSpDwarfCode: 52 return "sp"; 53 case kLrDwarfCode: 54 return "lr"; 55 default: 56 UNIMPLEMENTED(); 57 return nullptr; 58 } 59 } 60 61 #endif 62 63 } // namespace internal 64 } // namespace v8 65