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 "testing/gtest/include/gtest/gtest.h" |
| 7 |
| 8 namespace { |
| 9 |
| 10 class EhFrameHdrLayoutTest : public testing::Test {}; |
| 11 |
| 12 } // namespace |
| 13 |
| 14 using v8::internal::EhFrameHdr; |
| 15 |
| 16 TEST_F(EhFrameHdrLayoutTest, Real) { |
| 17 EhFrameHdr eh_frame_hdr(10, 30, 10); |
| 18 // |
| 19 // Plugging some numbers in the DSO layout shown in eh-frame.cc: |
| 20 // |
| 21 // | ... | |
| 22 // +---------------+ <-- (E) -------- |
| 23 // | | ^ |
| 24 // | Instructions | 10 bytes | .text |
| 25 // | | v |
| 26 // +---------------+ <--------------- |
| 27 // |///////////////| |
| 28 // |////Padding////| 6 bytes |
| 29 // |///////////////| |
| 30 // +---------------+ <---(D)--------- |
| 31 // | | ^ |
| 32 // | CIE | N bytes* | |
| 33 // | | | |
| 34 // +---------------+ <-- (C) | .eh_frame |
| 35 // | | | |
| 36 // | FDE | 30 - N bytes | |
| 37 // | | v |
| 38 // +---------------+ <-- (B) -------- |
| 39 // | version | ^ |
| 40 // +---------------+ 4 bytes | |
| 41 // | encoding | | |
| 42 // | specifiers | | |
| 43 // +---------------+ <---(A) | .eh_frame_hdr |
| 44 // | offset to | | |
| 45 // | .eh_frame | | |
| 46 // +---------------+ | |
| 47 // | ... | ... |
| 48 // |
| 49 // (*) the size of the CIE is platform dependent, 10 for this test. |
| 50 // |
| 51 EXPECT_EQ(1, eh_frame_hdr.lut_entries_number()); |
| 52 EXPECT_EQ(-(4 + 30), eh_frame_hdr.offset_to_eh_frame()); // A -> D |
| 53 EXPECT_EQ(-(30 + 6 + 10), eh_frame_hdr.offset_to_procedure()); // B -> E |
| 54 EXPECT_EQ(-(30 - 10), eh_frame_hdr.offset_to_fde()); // B -> C |
| 55 } |
| 56 |
| 57 TEST_F(EhFrameHdrLayoutTest, Empty) { |
| 58 EhFrameHdr dummy_eh_frame_hdr = EhFrameHdr::CreateEmptyHeader(); |
| 59 |
| 60 // An emtpy header has an empty LUT |
| 61 EXPECT_EQ(0, dummy_eh_frame_hdr.lut_entries_number()); |
| 62 |
| 63 // These values should be irrelevant, but check that they have been zeroed. |
| 64 EXPECT_EQ(0, dummy_eh_frame_hdr.offset_to_eh_frame()); |
| 65 EXPECT_EQ(0, dummy_eh_frame_hdr.offset_to_procedure()); |
| 66 EXPECT_EQ(0, dummy_eh_frame_hdr.offset_to_fde()); |
| 67 } |
OLD | NEW |