This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Fix offset for REL32_HI relocs
ClosedPublic

Authored by foad on Sep 1 2020, 6:56 AM.

Details

Summary

The addend in a REL32 reloc needs to be adjusted to account for the
offset from the PC value returned by the s_getpc instruction to the
point where the reloc is applied. This was being done correctly for
(GOTPC)REL32_LO but not for (GOTPC)REL32_HI. This will only make a
difference if the target symbol happens to get loaded almost exactly
a multiple of 4G away from the relocated instructions.

Diff Detail

Event Timeline

foad created this revision.Sep 1 2020, 6:56 AM
Herald added a project: Restricted Project. · View Herald Transcript
foad requested review of this revision.Sep 1 2020, 6:56 AM
foad edited reviewers, added: arsenm, rampitec, nhaehnle, sebastian-ne; removed: jdoerfert.Sep 1 2020, 6:57 AM
Flakebi added a subscriber: Flakebi.Sep 1 2020, 7:55 AM

Wow, good catch. Looks good to me.

arsenm added a comment.Sep 1 2020, 7:57 AM

I think the lo32/hi32 relocations are a broken concept to begin with and we should be using an expression to extract the low / high bits of the 64-bit relocations

rampitec accepted this revision.Sep 1 2020, 10:51 AM

LGTM even if we need to rework it as Matt suggests.

This revision is now accepted and ready to land.Sep 1 2020, 10:51 AM
This revision was automatically updated to reflect the committed changes.