[PATCH] D66734: [llvm-readobj/llvm-readelf] - Report a proper warning when dumping a broken dynamic relocation.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 26 07:51:09 PDT 2019


MaskRay added inline comments.


================
Comment at: include/llvm/Object/ELFTypes.h:251-255
+    return make_error<StringError>(
+        "st_name (0x" + utohexstr(Offset) +
+            ") is past the end of the string table of size 0x" +
+            utohexstr(StrTab.size()),
+        object_error::parse_failed);
----------------
grimar wrote:
> rupprecht wrote:
> > nit: use `createStringError` w/ a format string
> I think this what I initially did (used `createStringError`) , but it did not compile for me under linux (I am using windows for work most of the time), seems it wanted me to include a ELF.h header, but I was not sure it is a good idea to do that.
> 
> I'll revisit.
    return createStringError(
        object_error::parse_failed,
        "st_name (0x" + utohexstr(Offset) +
            ") is past the end of the string table of size 0x" +
            utohexstr(StrTab.size()));

should work. createStringError is defined in include/llvm/Support/Error.h which is included


================
Comment at: tools/llvm-readobj/ELFDumper.cpp:3539
+  uint32_t SymIndex = R.getSymbol(Obj->isMips64EL());
+  const typename ELFT::Sym *Sym = Dumper->dynamic_symbols().begin() + SymIndex;
+  Expected<StringRef> ErrOrName = Sym->getName(Dumper->getDynamicStringTable());
----------------
rupprecht wrote:
> `using Elf_Sym = typename ELFT::Sym` at the start of this method should allow you to keep it like before (and is more idiomatic)
ELFT::Sym is used once. I think it is fine to keep it as is.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66734/new/

https://reviews.llvm.org/D66734





More information about the llvm-commits mailing list