This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Remove original relocs when moving JTs in relocation mode
Changes PlannedPublic

Authored by Amir on Mar 29 2023, 6:31 AM.

Details

Reviewers
rafauler
maksfb
Group Reviewers
Restricted Project
Summary

Erase original jump table relocations in relocation mode with -jump-tables=move
(or higher). Otherwise we end up updating the original data relocations which
may no longer reference existing labels, as demonstrated by the test case.
Zero out the original jump table entries to trigger a crash if we end up using them.

Diff Detail

Event Timeline

Amir created this revision.Mar 29 2023, 6:31 AM
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Amir requested review of this revision.Mar 29 2023, 6:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 29 2023, 6:31 AM
Amir planned changes to this revision.Mar 29 2023, 2:28 PM

The plan is to explicitly zero out the original jump table entries to trigger a crash if we end up using them.

rafauler accepted this revision.Mar 29 2023, 2:28 PM

Nice solution. Can @maksfb sign off on this too? I'm not sure if he's aware.

The plan is to explicitly zero out the original jump table entries to trigger a crash if we end up using them.

Oh, ok

Amir updated this revision to Diff 509680.Mar 30 2023, 7:51 AM

Zero out the original jump table entries

This revision is now accepted and ready to land.Mar 30 2023, 7:51 AM
Amir edited the summary of this revision. (Show Details)Mar 30 2023, 7:54 AM

Nice solution. Can @maksfb sign off on this too? I'm not sure if he's aware.

We discussed the solution. @maksfb – please check if it looks good. I didn't refactor the creation of a zero symbol, we still create them ad-hoc in a couple of places.

Amir planned changes to this revision.May 16 2023, 11:48 AM

Can't proceed with this change as is.
In one internal test we end up erasing a PIC jump table entry that is added accidentally because it spuriously evaluates to a valid address/instruction/basic block inside the current function, even though it is a start of a jump table in another function, causing a runtime crash.