Chromium Code Reviews| 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 #include "src/objects-inl.h" | |
| 7 #include "src/objects.h" | |
| 8 | |
| 9 namespace v8 { | |
| 10 namespace internal { | |
| 11 | |
| 12 static const int DW_EH_PE_pcrel = 0x10; | |
| 13 static const int DW_EH_PE_datarel = 0x30; | |
| 14 static const int DW_EH_PE_udata4 = 0x03; | |
| 15 static const int DW_EH_PE_sdata4 = 0x0b; | |
| 16 | |
| 17 const int EhFrameHdr::kCIESize = 0; | |
| 18 | |
| 19 // | |
| 20 // In order to calculate offsets in the .eh_frame_hdr, we must know the layout | |
| 21 // of the DSO generated by perf inject, which is assumed to be the following: | |
| 22 // | |
| 23 // | ... | | | |
| 24 // +---------------+ <-- (F) --- | Larger offsets in file | |
| 25 // | | ^ | | |
| 26 // | Instructions | | .text v | |
| 27 // | | v | |
| 28 // +---------------+ <-- (E) --- | |
| 29 // |///////////////| | |
| 30 // |////Padding////| | |
| 31 // |///////////////| | |
| 32 // +---------------+ <-- (D) --- | |
| 33 // | | ^ | |
| 34 // | CIE | | | |
| 35 // | | | | |
| 36 // +---------------+ <-- (C) | .eh_frame | |
| 37 // | | | | |
| 38 // | FDE | | | |
| 39 // | | v | |
| 40 // +---------------+ <-- (B) --- | |
| 41 // | version | ^ | |
| 42 // +---------------+ | | |
| 43 // | encoding | | | |
| 44 // | specifiers | | | |
| 45 // +---------------+ <---(A) | .eh_frame_hdr | |
| 46 // | offset to | | | |
| 47 // | .eh_frame | | | |
| 48 // +---------------+ | | |
| 49 // | ... | ... | |
| 50 // | |
| 51 // (F) is aligned at a 16-byte boundary. | |
| 52 // (D) is aligned at a 8-byte boundary. | |
| 53 // (B) is aligned at a 4-byte boundary. | |
| 54 // (E), (C) and (A) have no alignment requirements. | |
| 55 // | |
| 56 // The size of the .eh_frame is required to be a multiple of the pointer size, | |
| 57 // which means that (B) will always be aligned to a 4-byte boundary on all the | |
| 58 // architectures we support. Instead, there could be padding between (E) and (D) | |
| 59 // to reach the appropriate alignment. Since (F) is aligned at a 16-byte | |
| 60 // boundary, thus to a 8-byte one as well, we have D - F = RoundUp(E - F, 8), | |
| 61 // which means we don't need to know the absolute value of E. | |
|
rmcilroy
2016/06/24 09:45:25
I'm not sure what the "Instead..." sentence really
Stefano Sanfilippo
2016/06/24 10:36:37
The point is that we are guaranteed that there wil
| |
| 62 // | |
| 63 EhFrameHdr::EhFrameHdr(Code* code) { | |
| 64 int code_size = code->is_crankshafted() ? code->safepoint_table_offset() | |
| 65 : code->instruction_size(); | |
|
rmcilroy
2016/06/24 09:45:26
Looks like this code is in a couple of places (e.g
Stefano Sanfilippo
2016/06/24 10:36:37
Sure thing, maybe let's coordinate with jarin@.
| |
| 66 version_ = 1; | |
| 67 eh_frame_ptr_encoding_ = DW_EH_PE_sdata4 | DW_EH_PE_pcrel; | |
| 68 lut_size_encoding_ = DW_EH_PE_udata4; | |
| 69 lut_entries_encoding_ = DW_EH_PE_sdata4 | DW_EH_PE_datarel; | |
| 70 | |
| 71 // .eh_frame pointer and LUT | |
| 72 if (code->has_unwinding_info()) { | |
| 73 DCHECK_GE(code->unwinding_info_size(), EhFrameHdr::kRecordSize); | |
| 74 int eh_frame_size = code->unwinding_info_size() - EhFrameHdr::kRecordSize; | |
| 75 | |
| 76 offset_to_eh_frame_ = -(eh_frame_size + 4); // A -> D | |
|
rmcilroy
2016/06/24 09:45:25
Where does the "+ 4" come from? Could you make the
Stefano Sanfilippo
2016/06/24 10:36:36
+ 4 is the size of <version> (1 byte) and <encodin
rmcilroy
2016/06/24 12:55:25
Why not just have two constants: kVersionSize and
Stefano Sanfilippo
2016/06/24 13:17:28
Done.
| |
| 77 lut_entries_number_ = 1; | |
| 78 offset_to_procedure_ = -(RoundUp(code_size, 8) + eh_frame_size); // B -> F | |
| 79 offset_to_fde_ = -(eh_frame_size - kCIESize); // B -> C | |
| 80 } else { | |
| 81 // Create a dummy table | |
| 82 offset_to_eh_frame_ = 0; | |
| 83 lut_entries_number_ = 0; | |
| 84 offset_to_procedure_ = 0; | |
| 85 offset_to_fde_ = 0; | |
| 86 } | |
| 87 } | |
| 88 | |
| 89 } // namespace internal | |
| 90 } // namespace v8 | |
| OLD | NEW |