OLD | NEW |
(Empty) | |
| 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 kRaxDwarfCode = 0; |
| 11 static const int kRbpDwarfCode = 6; |
| 12 static const int kRspDwarfCode = 7; |
| 13 static const int kRipDwarfCode = 16; |
| 14 |
| 15 const int EhFrameConstants::kCodeAlignmentFactor = 1; |
| 16 const int EhFrameConstants::kDataAlignmentFactor = -8; |
| 17 |
| 18 void EhFrameWriter::WriteReturnAddressRegisterCode() { |
| 19 WriteULeb128(kRipDwarfCode); |
| 20 } |
| 21 |
| 22 void EhFrameWriter::WriteInitialStateInCie() { |
| 23 SetBaseAddressRegisterAndOffset(rsp, kPointerSize); |
| 24 // x64 rip (r16) has no Register instance associated. |
| 25 RecordRegisterSavedToStack(kRipDwarfCode, -kPointerSize); |
| 26 } |
| 27 |
| 28 // static |
| 29 int EhFrameWriter::RegisterToDwarfCode(Register name) { |
| 30 switch (name.code()) { |
| 31 case Register::kCode_rbp: |
| 32 return kRbpDwarfCode; |
| 33 case Register::kCode_rsp: |
| 34 return kRspDwarfCode; |
| 35 case Register::kCode_rax: |
| 36 return kRaxDwarfCode; |
| 37 default: |
| 38 UNIMPLEMENTED(); |
| 39 return -1; |
| 40 } |
| 41 } |
| 42 |
| 43 #ifdef ENABLE_DISASSEMBLER |
| 44 |
| 45 // static |
| 46 const char* EhFrameDisassembler::DwarfRegisterCodeToString(int code) { |
| 47 switch (code) { |
| 48 case kRbpDwarfCode: |
| 49 return "rbp"; |
| 50 case kRspDwarfCode: |
| 51 return "rsp"; |
| 52 case kRipDwarfCode: |
| 53 return "rip"; |
| 54 default: |
| 55 UNIMPLEMENTED(); |
| 56 return nullptr; |
| 57 } |
| 58 } |
| 59 |
| 60 #endif |
| 61 |
| 62 } // namespace internal |
| 63 } // namespace v8 |
OLD | NEW |