[PATCH] D80049: [lld-macho] Add some relocation validation logic

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 21 14:05:35 PDT 2020


smeenai added inline comments.


================
Comment at: lld/MachO/Arch/X86_64.cpp:45-46
+                                    const relocation_info &rel) {
+  return ("invalid type " + std::to_string(rel.r_type) +
+          " relocation at offset " + std::to_string(rel.r_address) + " of " +
+          sec.segname + "," + sec.sectname + " in " + mb.getBufferIdentifier())
----------------
int3 wrote:
> smeenai wrote:
> > Nit: I feel like "invalid relocation of type X" would read better than "invalid type X relocation", both here and in getImplicitAddend below.
> > 
> > It would be really nice to be able to print the enum as a string instead of just its number (e.g. saying "relocation of type X86_64_RELOC_BRANCH" instead of "relocation of type 2"). There's `MachOObjectFile::getRelocationTypeName` for this purpose; it's a member function, but we could factor its main logic out into a static function. That definitely shouldn't block this change from going in though; it can easily just be another (low-pri) follow-up.
> sounds good. (Also on second thought I don't think we need to put `invalid relocation of type X` in the prefix; the specific checks will likely always depend on the type and so will mention it in the second part of the error message)
Looks great!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80049





More information about the llvm-commits mailing list