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.
Paths
| Differential D97610
[lld-macho] check minimum header length when opening linkable input files ClosedPublic Authored by gkm on Feb 26 2021, 11:51 PM.
Details
Summary Bifurcate the readFile() API into ...
There are no new tests because tweaks to existing tests are sufficient.
Diff Detail
Unit TestsFailed
Event Timelinegkm added a parent revision: D97600: [lld-macho] Implement options -rename_section -rename_segment.Feb 26 2021, 11:51 PM
This revision is now accepted and ready to land.Feb 27 2021, 1:37 PM
gkm added inline comments.
Closed by commit rG0223ab035c19: [lld-macho] check minimum header length when opening linkable input files (authored by gkm). · Explain WhyFeb 27 2021, 2:42 PM This revision was automatically updated to reflect the committed changes. gkm marked an inline comment as done.
Comment Actions a) I think this breaks --reproduce=repro.tar for -order_file since that previously called readFile() which added to the repro tar, but now readRawFile() doesn't. (Looks like -sectcreate has the same problem likely.) Comment Actions
I believe avoiding ASAN errors, per https://reviews.llvm.org/D97600?id=326855#inline-915154 gkm added a reverting change: D97757: [lld-macho] Rework length check when opening input files.Mar 2 2021, 1:29 AM Comment Actions
-sectcreate is subtle. It should be an opaque object immune to meddling, but as-is, if it happens to be MachO::FAT_MAGIC its arch component will be extracted. I am not going to fret about that until it proves troublesome.
The immediate motive was to fix an ASAN overflow when checking magic# of an empty buffer. My solution was an ill-conceived refactor with insufficient understanding. Apologies. This reverts the refactor and adds a modest one-line check that the file buffer is long-enough for a magic number: https://reviews.llvm.org/D97757 gkm added a reverting change: rG4af1522a855e: [lld-macho] Rework length check when opening input files.Mar 2 2021, 1:01 PM
Revision Contents
Diff 326880 lld/MachO/Driver.cpp
lld/MachO/DriverUtils.cpp
lld/MachO/InputFiles.h
lld/MachO/InputFiles.cpp
lld/test/MachO/invalid/bad-archive.slld/test/MachO/invalid/invalid-fat-narch.s
lld/test/MachO/rename.s
|
petition to keep this as addFile -- it's not like we have addRawFile, so the additional word seems unnecessary