[lld-macho] Add some relocation validation logic
authorJez Ng <jezng@fb.com>
Fri, 15 May 2020 20:42:28 +0000 (13:42 -0700)
committerJez Ng <jezng@fb.com>
Tue, 2 Jun 2020 20:19:38 +0000 (13:19 -0700)
commit6f6d91867da1bbdd13379a7aac8d6d2526672783
tree4a304b827f2e8a27a1e0cfa02b9c19806eff6e82
parent086be9fb20489540e6228a6d9eb4afad533202fa
[lld-macho] Add some relocation validation logic

I considered making a `Target::validate()` method, but I wasn't sure how
I felt about the overhead of doing yet another switch-dispatch on the
relocation type, so I put the validation in `relocateOne` instead...
might be a bit of a micro-optimization, but `relocateOne` does assume
certain things about the relocations it gets, and this error handling
makes that explicit, so it's not a totally unreasonable code
organization.

Reviewed By: smeenai

Differential Revision: https://reviews.llvm.org/D80049
lld/MachO/Arch/X86_64.cpp
lld/MachO/InputFiles.cpp
lld/MachO/Target.h
lld/test/MachO/invalid/invalid-relocation.yaml [new file with mode: 0644]