@@ -241,12 +241,12 @@ InputSection *InputSectionBase::getLinkOrderDep() const {
241
241
return cast<InputSection>(file->getSections ()[link]);
242
242
}
243
243
244
- // Find a function symbol that encloses a given location.
245
- Defined *InputSectionBase::getEnclosingFunction (uint64_t offset) {
244
+ // Find a symbol that encloses a given location.
245
+ Defined *InputSectionBase::getEnclosingSymbol (uint64_t offset, uint8_t type ) {
246
246
for (Symbol *b : file->getSymbols ())
247
247
if (Defined *d = dyn_cast<Defined>(b))
248
- if (d->section == this && d->type == STT_FUNC && d-> value <= offset &&
249
- offset < d->value + d->size )
248
+ if (d->section == this && d->value <= offset &&
249
+ offset < d->value + d->size && (type == 0 || type == d-> type ) )
250
250
return d;
251
251
return nullptr ;
252
252
}
@@ -296,10 +296,8 @@ std::string InputSectionBase::getObjMsg(uint64_t off) {
296
296
// Find a symbol that encloses a given location. getObjMsg may be called
297
297
// before ObjFile::initSectionsAndLocalSyms where local symbols are
298
298
// initialized.
299
- for (Symbol *b : file->getSymbols ())
300
- if (auto *d = dyn_cast_or_null<Defined>(b))
301
- if (d->section == this && d->value <= off && off < d->value + d->size )
302
- return filename + " :(" + toString (*d) + " )" + archive;
299
+ if (Defined *d = getEnclosingSymbol (off))
300
+ return filename + " :(" + toString (*d) + " )" + archive;
303
301
304
302
// If there's no symbol, print out the offset in the section.
305
303
return (filename + " :(" + name + " +0x" + utohexstr (off) + " )" + archive)
0 commit comments