This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objdump][macho] Add initial --chained_fixups support
Needs ReviewPublic

Authored by PRESIDENT810 on Jan 27 2022, 12:56 AM.

Details

Reviewers
keith
Bigcheese
jhenderson
MaskRay
smeenai
int3
Group Reviewers
Restricted Project
Summary

iOS15 introduces fixup chain to speeds up the dynamic linking process; when building application targeting OS higher than iOS15 / macOS12, Mach-O uses fixup chain in replacement of rebase / binding information, to instruct dyld how to link dynamic libraries. This option aims to behave like the -chained_fixups option of MacOS's otool-classic, which dumps structs related to fixup chain in Mach-O object files, including dyld_chained_fixups_header, dyld_chained_starts_in_image, dyld_chained_starts_in_segment and dyld_chained_import[_addend][64].

Diff Detail

Event Timeline

PRESIDENT810 created this revision.Jan 27 2022, 12:56 AM
PRESIDENT810 requested review of this revision.Jan 27 2022, 12:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2022, 12:56 AM
MaskRay added a reviewer: Restricted Project.Jan 29 2022, 12:55 PM
jhenderson added inline comments.Feb 1 2022, 7:17 AM
llvm/include/llvm/BinaryFormat/MachO.h
298

Comments should use full English grammar, including leading capital letter and trailing period. Applies throughout.

llvm/test/tools/llvm-objdump/MachO/chained_fixups_dump.test
1

If possible, it would be preferable to have yaml2obj generate this input (or generate it from IR/assembly), so that the test doesn't rely on an opaque binary.

51

Nit: add new line at EOF.

llvm/tools/llvm-objdump/MachODump.cpp
10774–10775

Please refer to the LLVM coding standards for error and warning messages.

Is there a generic llvm-objdump error function you could use instead?

llvm/tools/llvm-objdump/ObjdumpOpts.td
248–250

Please make sure new options are in the llvlm-objdump CommandGuide located in llvm/docs.

This is great, but I recently started a patch series to upstream Apple's internal implementation. Maybe we can work together to land this feature?

See https://reviews.llvm.org/D113630 and dependencies. (There are more patches waiting in the pipeline).

This is great, but I recently started a patch series to upstream Apple's internal implementation. Maybe we can work together to land this feature?

Great! I'm new to llvm and I didn't know that there are already patches supporting this feature, so maybe it's better to stick with your implementation. I will be glad to work together to land this feature if there is anything I can help. :)

keith added a comment.Feb 9 2022, 8:29 PM

FWIW I started working on yaml2obj support for chained fixups, I have it working where the chained fixups are just bytes and not a structured representation, but it would help avoid checking in more binaries for test fixtures.

I'm really excited about all this interest in chained fixups. I won't be able to make any progress on this throughout the next week, but I promise I'll get back to pushing out more patches right after. In the meantime it would be great if you could take a look at my existing patch stack (which just lays down the very first steps) and add your review comments. Thanks for your patience!

I submitted https://reviews.llvm.org/D119671 which if accepted would aid with the tests here

smeenai resigned from this revision.Apr 28 2022, 1:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2022, 1:42 PM
Herald added a subscriber: StephenFan. · View Herald Transcript
int3 resigned from this revision.Dec 8 2022, 7:26 PM