This is an archive of the discontinued LLVM Phabricator instance.

Add support for chained fixup load commands to MachOObjectFile
ClosedPublic

Authored by aprantl on Nov 10 2021, 4:51 PM.

Details

Summary

This is part of a series of patches to upstream support for Mach-O chained fixups.

This patch adds support for parsing the chained fixup load command and parsing the chained fixups header. It also puts into place the abstract interface that will be used to iterate over the fixups.

Diff Detail

Event Timeline

aprantl created this revision.Nov 10 2021, 4:51 PM
aprantl requested review of this revision.Nov 10 2021, 4:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 10 2021, 4:51 PM
rastogishubham added inline comments.Nov 10 2021, 5:00 PM
llvm/include/llvm/BinaryFormat/MachO.h
1009

Minor issue, but you have a typo in your comment here

aprantl updated this revision to Diff 386560.Nov 11 2021, 9:53 AM

Rebased & fixed typo

aprantl marked an inline comment as done.Nov 11 2021, 9:53 AM
keith added a subscriber: keith.Feb 9 2022, 8:29 PM
JDevlieghere added inline comments.Feb 10 2022, 10:09 PM
llvm/lib/Object/MachOObjectFile.cpp
3257–3270

Could this be a static factory method that returns an Expected<MachOChainedFixupEntry>?

4306–4310

If Start fails but Finish succeeds, won't this trigger the unchecked Error assert?

aprantl updated this revision to Diff 410422.Feb 21 2022, 5:55 PM

Rebased.

llvm/lib/Object/MachOObjectFile.cpp
3257–3270

Definitely, but I'm trying hard to minimize differences with the downstream code as much as possible. I'm more than happy to refactor the code at the end of patch series though!

4306–4310

Good question! No. Finish is initialized with Parse=false and thus will not overwrite Err. This pattern is used all over the file.

keith accepted this revision.Feb 22 2022, 10:56 AM
This revision is now accepted and ready to land.Feb 22 2022, 10:56 AM
kstoimenov added inline comments.
llvm/include/llvm/Object/MachO.h
378

It looks like this change in breaking the sanitizer Android build: https://lab.llvm.org/buildbot/#/builders/77/builds/14698. Could you please fix that?

llvm/lib/Object/MachOObjectFile.cpp
3258

Error here

error: member initializer 'Kind' does not name a non-static data member or base class
    : MachOAbstractFixupEntry(E, O), Kind(Kind)