/// the size, entity size and virtual address are different entries in arbitrary
/// order (DT_REL, DT_RELSZ, DT_RELENT for example).
struct DynRegionInfo {
- DynRegionInfo(const Binary &Owner) : Obj(&Owner) {}
- DynRegionInfo(const Binary &Owner, const uint8_t *A, uint64_t S, uint64_t ES)
- : Addr(A), Size(S), EntSize(ES), Obj(&Owner) {}
+ DynRegionInfo(const Binary &Owner, const ObjDumper &D)
+ : Obj(&Owner), Dumper(&D) {}
+ DynRegionInfo(const Binary &Owner, const ObjDumper &D, const uint8_t *A,
+ uint64_t S, uint64_t ES)
+ : Addr(A), Size(S), EntSize(ES), Obj(&Owner), Dumper(&D) {}
/// Address in current address space.
const uint8_t *Addr = nullptr;
/// Owner object. Used for error reporting.
const Binary *Obj;
+ /// Dumper used for error reporting.
+ const ObjDumper *Dumper;
/// Error prefix. Used for error reporting to provide more information.
std::string Context;
/// Region size name. Used for error reporting.
const uint64_t ObjSize = Obj->getMemoryBufferRef().getBufferSize();
if (Size > ObjSize - Offset) {
- reportWarning(
- createError("unable to read data at 0x" + Twine::utohexstr(Offset) +
- " of size 0x" + Twine::utohexstr(Size) + " (" +
- SizePrintName +
- "): it goes past the end of the file of size 0x" +
- Twine::utohexstr(ObjSize)),
- Obj->getFileName());
+ Dumper->reportUniqueWarning(createError(
+ "unable to read data at 0x" + Twine::utohexstr(Offset) +
+ " of size 0x" + Twine::utohexstr(Size) + " (" + SizePrintName +
+ "): it goes past the end of the file of size 0x" +
+ Twine::utohexstr(ObjSize)));
return {Start, Start};
}
(" or " + EntSizePrintName + " (0x" + Twine::utohexstr(EntSize) + ")")
.str();
- reportWarning(createError(Msg.c_str()), Obj->getFileName());
+ Dumper->reportUniqueWarning(createError(Msg.c_str()));
return {Start, Start};
}
};
") + size (0x" + Twine::utohexstr(Size) +
") is greater than the file size (0x" +
Twine::utohexstr(Obj.getBufSize()) + ")");
- return DynRegionInfo(ObjF, Obj.base() + Offset, Size, EntSize);
+ return DynRegionInfo(ObjF, *this, Obj.base() + Offset, Size, EntSize);
}
void printAttributes();
if (!DynamicPhdr && !DynamicSec)
return;
- DynRegionInfo FromPhdr(ObjF);
+ DynRegionInfo FromPhdr(ObjF, *this);
bool IsPhdrTableValid = false;
if (DynamicPhdr) {
// Use cantFail(), because p_offset/p_filesz fields of a PT_DYNAMIC are
// Ignore sh_entsize and use the expected value for entry size explicitly.
// This allows us to dump dynamic sections with a broken sh_entsize
// field.
- DynRegionInfo FromSec(ObjF);
+ DynRegionInfo FromSec(ObjF, *this);
bool IsSecTableValid = false;
if (DynamicSec) {
Expected<DynRegionInfo> RegOrErr =
ELFDumper<ELFT>::ELFDumper(const object::ELFObjectFile<ELFT> &O,
ScopedPrinter &Writer)
: ObjDumper(Writer, O.getFileName()), ObjF(O), Obj(*O.getELFFile()),
- DynRelRegion(O), DynRelaRegion(O), DynRelrRegion(O), DynPLTRelRegion(O),
- DynamicTable(O) {
+ DynRelRegion(O, *this), DynRelaRegion(O, *this), DynRelrRegion(O, *this),
+ DynPLTRelRegion(O, *this), DynamicTable(O, *this) {
if (opts::Output == opts::GNU)
ELFDumperStyle.reset(new GNUStyle<ELFT>(Writer, *this));
else
// If we can't map the DT_SYMTAB value to an address (e.g. when there are
// no program headers), we ignore its value.
if (const uint8_t *VA = toMappedAddr(Dyn.getTag(), Dyn.getPtr())) {
- DynSymFromTable.emplace(ObjF);
+ DynSymFromTable.emplace(ObjF, *this);
DynSymFromTable->Addr = VA;
DynSymFromTable->EntSize = sizeof(Elf_Sym);
DynSymFromTable->EntSizePrintName = "";