aboutsummaryrefslogtreecommitdiff
path: root/src/common/module.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/module.cc')
-rw-r--r--src/common/module.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/common/module.cc b/src/common/module.cc
index dc4f957e..aff22127 100644
--- a/src/common/module.cc
+++ b/src/common/module.cc
@@ -76,11 +76,19 @@ void Module::SetLoadAddress(Address address) {
load_address_ = address;
}
+void Module::SetAddressRanges(const vector<Range>& ranges) {
+ address_ranges_ = ranges;
+}
+
void Module::AddFunction(Function *function) {
// FUNC lines must not hold an empty name, so catch the problem early if
// callers try to add one.
assert(!function->name.empty());
+ if (!AddressIsInModule(function->address)) {
+ return;
+ }
+
// FUNCs are better than PUBLICs as they come with sizes, so remove an extern
// with the same address if present.
Extern ext(function->address);
@@ -123,10 +131,18 @@ void Module::AddFunctions(vector<Function *>::iterator begin,
}
void Module::AddStackFrameEntry(StackFrameEntry *stack_frame_entry) {
+ if (!AddressIsInModule(stack_frame_entry->address)) {
+ return;
+ }
+
stack_frame_entries_.push_back(stack_frame_entry);
}
void Module::AddExtern(Extern *ext) {
+ if (!AddressIsInModule(ext->address)) {
+ return;
+ }
+
std::pair<ExternSet::iterator,bool> ret = externs_.insert(ext);
if (!ret.second) {
// Free the duplicate that was not inserted because this Module
@@ -232,6 +248,19 @@ bool Module::WriteRuleMap(const RuleMap &rule_map, std::ostream &stream) {
return stream.good();
}
+bool Module::AddressIsInModule(Address address) const {
+ if (address_ranges_.empty()) {
+ return true;
+ }
+ for (const auto& segment : address_ranges_) {
+ if (address >= segment.address &&
+ address < segment.address + segment.size) {
+ return true;
+ }
+ }
+ return false;
+}
+
bool Module::Write(std::ostream &stream, SymbolData symbol_data) {
stream << "MODULE " << os_ << " " << architecture_ << " "
<< id_ << " " << name_ << "\n";