1 // Copyright 2013 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #include "courgette/base_test_unittest.h"
8 #include "courgette/disassembler_elf_32_x86.h"
9 #include "courgette/image_utils.h"
11 class TypedRVATest : public BaseTest {
13 void TestRelativeTargetX86(courgette::RVA word, courgette::RVA expected)
18 void TypedRVATest::TestRelativeTargetX86(courgette::RVA word,
19 courgette::RVA expected) const {
20 courgette::DisassemblerElf32X86::TypedRVAX86* typed_rva
21 = new courgette::DisassemblerElf32X86::TypedRVAX86(0);
22 const uint8_t* op_pointer = reinterpret_cast<const uint8_t*>(&word);
24 EXPECT_TRUE(typed_rva->ComputeRelativeTarget(op_pointer));
25 EXPECT_EQ(typed_rva->relative_target(), expected);
30 uint32_t Read32LittleEndian(const void* address) {
31 return *reinterpret_cast<const uint32_t*>(address);
34 TEST_F(TypedRVATest, TestX86) {
35 TestRelativeTargetX86(0x0, 0x4);