| Index: test/unittests/eh-frame-hdr-unittest.cc
|
| diff --git a/test/unittests/eh-frame-hdr-unittest.cc b/test/unittests/eh-frame-hdr-unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..fc11a6e389f2704f01cacc014bd4895167d6cfba
|
| --- /dev/null
|
| +++ b/test/unittests/eh-frame-hdr-unittest.cc
|
| @@ -0,0 +1,67 @@
|
| +// Copyright 2016 the V8 project authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "src/eh-frame.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace {
|
| +
|
| +class EhFrameHdrLayoutTest : public testing::Test {};
|
| +
|
| +} // namespace
|
| +
|
| +using v8::internal::EhFrameHdr;
|
| +
|
| +TEST_F(EhFrameHdrLayoutTest, Real) {
|
| + EhFrameHdr eh_frame_hdr(10, 30, 10);
|
| + //
|
| + // Plugging some numbers in the DSO layout shown in eh-frame.cc:
|
| + //
|
| + // | ... |
|
| + // +---------------+ <-- (E) --------
|
| + // | | ^
|
| + // | Instructions | 10 bytes | .text
|
| + // | | v
|
| + // +---------------+ <---------------
|
| + // |///////////////|
|
| + // |////Padding////| 6 bytes
|
| + // |///////////////|
|
| + // +---------------+ <---(D)---------
|
| + // | | ^
|
| + // | CIE | N bytes* |
|
| + // | | |
|
| + // +---------------+ <-- (C) | .eh_frame
|
| + // | | |
|
| + // | FDE | 30 - N bytes |
|
| + // | | v
|
| + // +---------------+ <-- (B) --------
|
| + // | version | ^
|
| + // +---------------+ 4 bytes |
|
| + // | encoding | |
|
| + // | specifiers | |
|
| + // +---------------+ <---(A) | .eh_frame_hdr
|
| + // | offset to | |
|
| + // | .eh_frame | |
|
| + // +---------------+ |
|
| + // | ... | ...
|
| + //
|
| + // (*) the size of the CIE is platform dependent, 10 for this test.
|
| + //
|
| + EXPECT_EQ(1, eh_frame_hdr.lut_entries_number());
|
| + EXPECT_EQ(-(4 + 30), eh_frame_hdr.offset_to_eh_frame()); // A -> D
|
| + EXPECT_EQ(-(30 + 6 + 10), eh_frame_hdr.offset_to_procedure()); // B -> E
|
| + EXPECT_EQ(-(30 - 10), eh_frame_hdr.offset_to_fde()); // B -> C
|
| +}
|
| +
|
| +TEST_F(EhFrameHdrLayoutTest, Empty) {
|
| + EhFrameHdr dummy_eh_frame_hdr = EhFrameHdr::CreateEmptyHeader();
|
| +
|
| + // An emtpy header has an empty LUT
|
| + EXPECT_EQ(0, dummy_eh_frame_hdr.lut_entries_number());
|
| +
|
| + // These values should be irrelevant, but check that they have been zeroed.
|
| + EXPECT_EQ(0, dummy_eh_frame_hdr.offset_to_eh_frame());
|
| + EXPECT_EQ(0, dummy_eh_frame_hdr.offset_to_procedure());
|
| + EXPECT_EQ(0, dummy_eh_frame_hdr.offset_to_fde());
|
| +}
|
|
|