[lld-macho] check minimum header length when opening linkable input files
authorGreg McGary <gkm@fb.com>
Sat, 27 Feb 2021 07:28:52 +0000 (23:28 -0800)
committerGreg McGary <gkm@fb.com>
Sat, 27 Feb 2021 22:41:40 +0000 (14:41 -0800)
commit0223ab035c199e537a0040857ba147ced87fd533
treeb93dfb2c17413c1edeefd750b992e39120f7b33d
parente0b1df924ae06d6d88582334087d2eacc6702e8f
[lld-macho] check minimum header length when opening linkable input files

Bifurcate the `readFile()` API into ...
* `readRawFile()` which performs no checks, and
* `readLinkableFile()` which enforces minimum length of 20 bytes, same as ld64

There are no new tests because tweaks to existing tests are sufficient.

Differential Revision: https://reviews.llvm.org/D97610
lld/MachO/Driver.cpp
lld/MachO/DriverUtils.cpp
lld/MachO/InputFiles.cpp
lld/MachO/InputFiles.h
lld/test/MachO/invalid/tiny-input.s [new file with mode: 0644]
lld/test/MachO/rename.s