This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Ignore PC-relative relocations from data to data
ClosedPublic

Authored by maksfb on Apr 12 2022, 6:41 PM.

Details

Summary

BOLT expects PC-relative relocations in data sections to reference code
and the relocated data to form a jump table. However, there are cases
where PC-relative addressing is used for data-to-data references
(e.g. clang-15 can generate such code). BOLT should recognize and ignore
such relocations. Otherwise, they will be considered relocations not
claimed by any jump table and cause a failure in the strict mode.

Diff Detail

Event Timeline

maksfb created this revision.Apr 12 2022, 6:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2022, 6:41 PM
maksfb requested review of this revision.Apr 12 2022, 6:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 12 2022, 6:41 PM
Amir accepted this revision.Apr 13 2022, 11:02 AM

LG. Just to make sure: the primary change is the extra condition to call addPCRelativeDataRelocation (from !IsFromCode to !IsFromCode && IsToCode), right?

This revision is now accepted and ready to land.Apr 13 2022, 11:02 AM

LG. Just to make sure: the primary change is the extra condition to call addPCRelativeDataRelocation (from !IsFromCode to !IsFromCode && IsToCode), right?

Correct. Before we registered any PC-relative relocations from data, but we are really interested only in data-to-code variants.

yota9 accepted this revision.Apr 13 2022, 11:12 AM
This revision was automatically updated to reflect the committed changes.