This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objcopy][MachO] Keep symbols having the flag REFERENCED_DYNAMICALLY set
ClosedPublic

Authored by alexander-shaposhnikov on Jun 10 2021, 7:24 PM.

Details

Summary

Do not strip symbols having the flag REFERENCED_DYNAMICALLY set.

This is compatible with the behavior of cctools' strip and consistent with the documentation ("Mach-O Runtime Architecture"):

"REFERENCED_DYNAMICALLY (0x10)—Must be set for any symbol that might be referenced
by another image. The strip tool uses this bit to avoid removing symbols that must exist:
If the symbol has this bit set, strip does not strip it."

Test plan: make check-all

Diff Detail

Event Timeline

alexander-shaposhnikov requested review of this revision.Jun 10 2021, 7:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 10 2021, 7:24 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
alexander-shaposhnikov retitled this revision from [llvm-objcopy][MachO] Do not strip symbols having the flag REFERENCED_DYNAMICALLY set to [llvm-objcopy][MachO] Keep symbols having the flag REFERENCED_DYNAMICALLY set.Jun 10 2021, 7:25 PM
smeenai accepted this revision.Jun 10 2021, 7:26 PM

LGTM

This revision is now accepted and ready to land.Jun 10 2021, 7:26 PM
alexander-shaposhnikov edited the summary of this revision. (Show Details)Jun 10 2021, 7:26 PM
jhenderson accepted this revision.Jun 11 2021, 12:57 AM

LGTM, with nit.

llvm/test/tools/llvm-objcopy/MachO/Inputs/strip-all-with-dwarf.yaml
295

It's probably worth a comment showing what this n_desc value represents.

This revision was landed with ongoing or failed builds.Jun 11 2021, 4:35 PM
This revision was automatically updated to reflect the committed changes.