chromium/components/zucchini/rel32_finder_unittest.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "components/zucchini/rel32_finder.h"

#include <stddef.h>
#include <stdint.h>

#include <algorithm>
#include <deque>
#include <iterator>
#include <string>
#include <utility>
#include <vector>

#include "base/check_op.h"
#include "base/format_macros.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/stringprintf.h"
#include "components/zucchini/arm_utils.h"
#include "components/zucchini/buffer_view.h"
#include "components/zucchini/disassembler_elf.h"
#include "components/zucchini/image_utils.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace zucchini {

TEST(Abs32GapFinderTest, All) {}

namespace {

// A mock Rel32Finder to inject next search result on Scan().
class TestRel32Finder : public Rel32Finder {};

AddressTranslator GetTrivialTranslator(size_t size) {}

}  // namespace

TEST(Rel32FinderTest, Scan) {}

namespace {

// X86 test data. (x) and +x entries are covered by abs32 references, which have
// width = 4.
constexpr uint8_t kDataX86[] =;

// Abs32 locations corresponding to |kDataX86|, with width = 4.
constexpr offset_t kAbs32X86[] =;

}  // namespace

TEST(Rel32FinderX86Test, FindNext) {}

TEST(Rel32FinderX86Test, Integrated) {}

TEST(Rel32FinderX86Test, Accept) {}

namespace {

// X64 test data. (x) and +x entries are covered by abs32 references, which have
// width = 8.
constexpr uint8_t kDataX64[] =;

// Abs32 locations corresponding to |kDataX64|, with width = 8.
constexpr offset_t kAbs32X64[] =;

}  // namespace

TEST(Rel32FinderX64Test, FindNext) {}

TEST(Rel32FinderX64Test, Integrated) {}

namespace {

// Runs the ARM rel32 extraction (nested) loop on |image| using |rel32_finder|,
// given |abs32_locations| for abs32 references each having |abs32_width|.
// Returns the list of extracted references.
template <class REL32_FINDER>
std::vector<typename REL32_FINDER::Result> ArmExtractRel32(
    ConstBufferView image,
    const std::deque<offset_t>& abs32_locations,
    int abs32_width,
    REL32_FINDER&& rel32_finder) {}

}  // namespace

namespace {

// AArch32 ARM mode test data. (x) and +x entries are covered by abs32
// references (if used), which have width = 4.
constexpr uint8_t kDataAarch32ArmMode[] =;

// Abs32 locations corresponding to |kDataAarch32ArmMode|, with width = 4.
constexpr offset_t kAbs32Aarch32ArmMode[] =;

}  // namespace

TEST(Rel32FinderAArch32Test, IntegratedArmModeWithoutAbs32) {}

TEST(Rel32FinderAArch32Test, IntegratedArmModeWithAbs32) {}

namespace {

// AArch32 THUMB2 mode test data. (x) and +x entries are covered by abs32
// references (if used), which have width = 4.
constexpr uint8_t kDataAarch32Thumb2Mode[] =;

// Abs32 locations corresponding to |kDataAarch32Thumb2Mode|, with width = 4.
constexpr offset_t kAbs32Aarch32Thumb2Mode[] =;

}  // namespace

TEST(Rel32FinderAArch32Test, IntegratedThumb2ModeWithoutAbs32) {}

TEST(Rel32FinderAArch32Test, IntegratedThumb2ModeWithAbs32) {}

namespace {

// AArch32 THUMB2 mode test data. (x) and +x entries are covered by abs32
// references (if used), which have width = 8.
constexpr uint8_t kDataAarch64[] =;

// Abs32 locations corresponding to |kDataAarch64|, with width = 8.
constexpr offset_t kAbs32Aarch64[] =;

}  // namespace

TEST(Rel32FinderAArch64Test, IntegratedWithoutAbs32) {}

TEST(Rel32FinderAArch64Test, IntegratedWithAbs32) {}

}  // namespace zucchini