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

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 21 13:32:54 PDT 2020


int3 marked an inline comment as done.
int3 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())
----------------
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)


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