| 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..60b89067d04fafff719497f188e00d5c2f78f3e4
|
| --- /dev/null
|
| +++ b/test/unittests/eh-frame-hdr-unittest.cc
|
| @@ -0,0 +1,71 @@
|
| +// 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 EhFrameHdrLayout : public testing::Test {
|
| + public:
|
| + EhFrameHdrLayout()
|
| + : eh_frame_hdr_(10, 30),
|
| + dummy_eh_frame_hdr_(v8::internal::EhFrameHdr::MakeDummy()) {}
|
| +
|
| + protected:
|
| + v8::internal::EhFrameHdr eh_frame_hdr_;
|
| + v8::internal::EhFrameHdr dummy_eh_frame_hdr_;
|
| +};
|
| +
|
| +} // namespace
|
| +
|
| +TEST_F(EhFrameHdrLayout, Real) {
|
| + //
|
| + // 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.
|
| + //
|
| + 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 - v8::internal::EhFrameWriter::kCIESize),
|
| + eh_frame_hdr_.offset_to_fde()); // B -> C
|
| +}
|
| +
|
| +TEST_F(EhFrameHdrLayout, Dummy) {
|
| + // A dummy 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());
|
| +}
|
|
|