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 kX0DwarfCode = 0; 11 static const int kJsSpDwarfCode = 28; 12 static const int kFpDwarfCode = 29; 13 static const int kLrDwarfCode = 30; 14 static const int kCSpDwarfCode = 31; 15 16 const int EhFrameConstants::kCodeAlignmentFactor = 4; 17 const int EhFrameConstants::kDataAlignmentFactor = -8; 18 19 void EhFrameWriter::WriteReturnAddressRegisterCode() { 20 WriteULeb128(kLrDwarfCode); 21 } 22 23 void EhFrameWriter::WriteInitialStateInCie() { 24 SetBaseAddressRegisterAndOffset(x29, 0); 25 RecordRegisterNotModified(x30); 26 } 27 28 // static 29 int EhFrameWriter::RegisterToDwarfCode(Register name) { 30 switch (name.code()) { 31 case Register::kCode_x28: 32 return kJsSpDwarfCode; 33 case Register::kCode_x29: 34 return kFpDwarfCode; 35 case Register::kCode_x30: 36 return kLrDwarfCode; 37 case Register::kCode_x31: 38 return kCSpDwarfCode; 39 case Register::kCode_x0: 40 return kX0DwarfCode; 41 default: 42 UNIMPLEMENTED(); 43 return -1; 44 } 45 } 46 47 #ifdef ENABLE_DISASSEMBLER 48 49 // static 50 const char* EhFrameDisassembler::DwarfRegisterCodeToString(int code) { 51 switch (code) { 52 case kFpDwarfCode: 53 return "fp"; 54 case kLrDwarfCode: 55 return "lr"; 56 case kJsSpDwarfCode: 57 return "jssp"; 58 case kCSpDwarfCode: 59 return "csp"; // This could be zr as well 60 default: 61 UNIMPLEMENTED(); 62 return nullptr; 63 } 64 } 65 66 #endif 67 68 } // namespace internal 69 } // namespace v8 70