This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objdump] Start on -chained_fixups for llvm-otool
ClosedPublic

Authored by thakis on Aug 15 2022, 6:53 AM.

Details

Summary

And --chained-fixups for llvm-objdump.

For now, this only prints the dyld_chained_fixups_header and adds
plumbing for the flag. This will be expanded in future commits.

When Apple's effort to upstream their chained fixups code continues,
we'll replace this code with the then-upstreamed code. But we need
something in the meantime for testing ld64.lld's chained fixups
code.

Update chained-fixups.yaml with a file that actually contains
the chained fixup data (LinkEditData doesn't encode it yet,
so use __LINKEDIT via --raw-segment=data).

Diff Detail

Unit TestsFailed

Event Timeline

thakis created this revision.Aug 15 2022, 6:53 AM
Herald added a reviewer: MaskRay. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: rupprecht. · View Herald Transcript
thakis requested review of this revision.Aug 15 2022, 6:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2022, 6:53 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
thakis added inline comments.Aug 15 2022, 6:54 AM
llvm/test/tools/llvm-objdump/MachO/chained-fixups.yaml
21

The test currently doesn't work, because the yaml file here (added in D113733, where I left a question about it) contains invalid data. I'll fix up the yaml file in a bit. Currently, we get:

out/gn/bin/llvm-objdump: error: '.../obj/llvm/test/tools/llvm-objdump/MachO/Output/chained-fixups.yaml.tmp': truncated or malformed object (bad chained fixups: unknown imports format: 0)
thakis updated this revision to Diff 452660.Aug 15 2022, 7:18 AM
thakis edited the summary of this revision. (Show Details)

update test

ok, good to go

I'm not going to review this as it's Mach-O stuff, which is outside my realms of expertise, but please don't forget to update the llvm-objdump and llvm-otool CommandGuides located under llvm/docs/CommandGuide.

thakis updated this revision to Diff 452668.Aug 15 2022, 7:54 AM

update rst files

I'm not going to review this as it's Mach-O stuff, which is outside my realms of expertise, but please don't forget to update the llvm-objdump and llvm-otool CommandGuides located under llvm/docs/CommandGuide.

Done, thanks!

BertalanD accepted this revision.Aug 15 2022, 7:57 AM
This revision is now accepted and ready to land.Aug 15 2022, 7:57 AM
This revision was landed with ongoing or failed builds.Aug 15 2022, 7:59 AM
This revision was automatically updated to reflect the committed changes.

@thakis

It looks like this patch is causing one of the Big Endian bots to fail on Power PC:
https://lab.llvm.org/buildbot/#/builders/231/builds/1440

The failure is the test tools/llvm-objdump/MachO/chained-fixups.yaml.

@thakis

It looks like this patch is causing one of the Big Endian bots to fail on Power PC:
https://lab.llvm.org/buildbot/#/builders/231/builds/1440

The failure is the test tools/llvm-objdump/MachO/chained-fixups.yaml.

Could you paste the whole output of bin/llvm-otool -chained_fixups /home/buildbots/ppc64be-clang-test-suite/clang-ppc64be-test-suite/build/test/tools/llvm-objdump/MachO/Output/chained-fixups.yaml.tmp on that bot?

I'm guessing the problem is that MachOObjectFile.cpp swaps load commands and assumes native byte endianness – but the yaml test here uses __LINKEDIT which always contains little-endian data.

Possible fixes:

  1. Force the yaml2obj output to be little endian somehow (I don't see a flag for this, though – am I not looking closely enough?)
  2. Skip the test on big endian machines (do we have a lit feature for this?)