RUN: 2>&1 | FileCheck --check-prefix=VER %s
VER: Error reading file: Invalid data was encountered while parsing the file.
+
+
+// The file is missing the dynamic string table but has references to it.
+RUN: not llvm-readobj -dynamic-table %p/Inputs/corrupt-invalid-strtab.elf.x86-64 \
+RUN: 2>&1 | FileCheck --check-prefix=STRTAB %s
+
+STRTAB: Invalid dynamic string table reference
}
template <class ELFT>
+static const char *getDynamicString(const ELFFile<ELFT> &O, uint64_t Value) {
+ const char *Ret = O.getDynamicString(Value);
+ if (!Ret)
+ reportError("Invalid dynamic string table reference");
+ return Ret;
+}
+
+template <class ELFT>
static void printValue(const ELFFile<ELFT> *O, uint64_t Type, uint64_t Value,
bool Is64, raw_ostream &OS) {
switch (Type) {
OS << Value << " (bytes)";
break;
case DT_NEEDED:
- OS << "SharedLibrary (" << O->getDynamicString(Value) << ")";
+ OS << "SharedLibrary (" << getDynamicString(*O, Value) << ")";
break;
case DT_SONAME:
- OS << "LibrarySoname (" << O->getDynamicString(Value) << ")";
+ OS << "LibrarySoname (" << getDynamicString(*O, Value) << ")";
break;
case DT_RPATH:
case DT_RUNPATH:
- OS << O->getDynamicString(Value);
+ OS << getDynamicString(*O, Value);
break;
case DT_MIPS_FLAGS:
printFlags(Value, makeArrayRef(ElfDynamicDTMipsFlags), OS);
for (const auto &Entry : Obj->dynamic_table())
if (Entry.d_tag == ELF::DT_NEEDED)
- Libs.push_back(Obj->getDynamicString(Entry.d_un.d_val));
+ Libs.push_back(getDynamicString(*Obj, Entry.d_un.d_val));
std::stable_sort(Libs.begin(), Libs.end());
}
// Various helper functions.
+ void reportError(Twine Msg);
void error(std::error_code ec);
bool relocAddressLess(object::RelocationRef A,
object::RelocationRef B);