This is an archive of the discontinued LLVM Phabricator instance.

[dsymutil] Apply relocations present in Swift reflection sections
ClosedPublic

Authored by augusto2112 on Feb 25 2022, 10:36 AM.

Details

Summary

The strippable Swift reflection sections contain subtractor relocations
that need to be applied. There are two situations we need to support.

  1. Both symbols used in the relocation come from the .o file (for example, one symbol lives in swift5_fieldmd and the second in swift5_reflstr).
  2. One symbol comes from th .o file and the second from the main binary (for example, swift5_fieldmd and swift5_typeref).

Diff Detail

Event Timeline

augusto2112 created this revision.Feb 25 2022, 10:36 AM
augusto2112 requested review of this revision.Feb 25 2022, 10:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2022, 10:36 AM

I noticed that there is no test for this change. Can you please add one?

aprantl added inline comments.Feb 25 2022, 11:33 AM
llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
342–500

We might want to sink this into MachO.h if it doesn't exist there already. You might want to check if there is code for it that we could upstream.

llvm/tools/dsymutil/DwarfLinkerForBinary.h
210

The keys in this map will be integers from 0..~10. Should this just be a std::vector instead?

llvm/tools/dsymutil/MachOUtils.cpp
623–642

Can you add a comment that explains that we are applying relocations here?

Updated reflection-dump test, moved isMachOPairedReloc to MachO.h, changed SectionToOffsetInDwarf from a map to a vector.

Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2022, 12:09 PM

I noticed that there is no test for this change. Can you please add one?

Updated the existing test to account for the relocations.

aprantl accepted this revision.Mar 14 2022, 2:00 PM
aprantl added inline comments.
llvm/include/llvm/Object/MachO.h
394

Doxygen Comment?

395

I know this would be a little redundant, but this function should probably have a unit test, since it's entirely self-contained.

This revision is now accepted and ready to land.Mar 14 2022, 2:00 PM
This revision was landed with ongoing or failed builds.Mar 17 2022, 10:23 AM
This revision was automatically updated to reflect the committed changes.