Skip to content

Commit

Permalink
Extend EntryPoint with flags. Use this to indicate that the code type…
Browse files Browse the repository at this point in the history
… for the entry point needs to be probed, for example in the case of ARM/Thumb where it's known that this is an entry point, but the Thumb bit cannot be used.

PiperOrigin-RevId: 419777572
Change-Id: I321118e6172e48ba6b6d510ec409b7bf037da420
  • Loading branch information
rmngoog authored and copybara-github committed Jan 5, 2022
1 parent c884874 commit 5326478
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
10 changes: 6 additions & 4 deletions entry_point.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@

#include "base/logging.h"

EntryPoint::EntryPoint(Address address, EntryPoint::Source source)
: address_(address), source_(source) {}
EntryPoint::EntryPoint(Address address, EntryPoint::Source source,
const int flags)
: address_(address), source_(source), flags_(flags) {}

bool operator<(const EntryPoint& lhs, const EntryPoint& rhs) {
return lhs.address_ < rhs.address_;
Expand Down Expand Up @@ -75,8 +76,9 @@ EntryPointManager::~EntryPointManager() {
LOG(INFO) << "Added " << count_ << " entry points from " << name_;
}

void EntryPointManager::Add(Address address, EntryPoint::Source source) {
entry_points_->emplace_back(address, source);
void EntryPointManager::Add(Address address, EntryPoint::Source source,
const int flags) {
entry_points_->emplace_back(address, source, flags);
++count_;
if (parent_) {
++parent_->count_;
Expand Down
12 changes: 10 additions & 2 deletions entry_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ class EntryPoint {
GOLANG_TYPE_INFO,
};

EntryPoint(Address address, EntryPoint::Source source);
static constexpr int kFlagsNone = 0;
// Used to indicate that the disassembler should probe for the code type
// (where this is appropriate to do so i.e. ARM, otherwise ignore it).
static constexpr int kFlagsProbeCodeType = 1 << 0;

EntryPoint(Address address, EntryPoint::Source source,
const int flags = kFlagsNone);

std::string SourceToString() const;

Expand All @@ -68,6 +74,7 @@ class EntryPoint {

Address address_;
EntryPoint::Source source_;
int flags_;
};

bool operator<(const EntryPoint& lhs, const EntryPoint& rhs);
Expand Down Expand Up @@ -97,7 +104,8 @@ class EntryPointManager {

~EntryPointManager();

void Add(Address address, EntryPoint::Source source);
void Add(Address address, EntryPoint::Source source,
const int flags = EntryPoint::kFlagsNone);

EntryPoints* entry_points() { return entry_points_; }

Expand Down

0 comments on commit 5326478

Please sign in to comment.