This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Improve dynamic relocations support for CI
ClosedPublic

Authored by yota9 on Feb 10 2023, 8:51 AM.

Details

Summary

This patch fixes few problems with supporting dynamic relocations in CI.

  1. After dynamic relocations and functions were read search for dynamic

relocations located in functions. Currently we expected them only to be
relative and only to be in constant island. Mark islands of such
functions to have dynamic relocations and create CI access symbol on the
relocation offset, so the BD would be created for such place.

  1. During function disassemble and handling address reference for

constant island check if the referred external CI has dynamic
relocation. And if it has one we would continue to refer original CI
rather then creating a local copy.

  1. After function disassembly stage mark function that has dynamic reloc

in CI as non-simple. We don't want such functions to be optimized, since
such passes as split function would create 2 copies of CI which we
unable to support currently.

  1. During updating output values for BF search for BD located in CI and

update their output locations.

  1. On dynamic relocation patching stage search for binary data located

on relocation offset. If it was moved use new relocation offset value
rather then an old one.

Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei

Diff Detail

Event Timeline

yota9 created this revision.Feb 10 2023, 8:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2023, 8:51 AM
yota9 requested review of this revision.Feb 10 2023, 8:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2023, 8:51 AM
yota9 updated this revision to Diff 497390.Feb 14 2023, 10:54 AM

nit
@rafauler Gentle ping :)

yota9 updated this revision to Diff 497418.Feb 14 2023, 1:07 PM

clang format

rafauler added inline comments.Feb 28 2023, 12:04 PM
bolt/include/bolt/Core/BinaryFunction.h
170

Can you expand this comment to:

Set true if constant island contains dynamic relocations, which happens if binary is linked with -znotext

1944

Add comment

Support dynamic relocations in constant islands, which happens if binary is linked with -znotext

1946

nit: Dynamic -> dynamic

bolt/lib/Core/BinaryContext.cpp
401

Is this because we don't support cloning dynamic relocs? If yes, we can expand this comment to clarify:

// Fall-back to referencing the original constant island in the presence of dynamic relocs, as we currently do not support cloning them. Notice: we might fail to link because of this, if the original constant island is far away.

yota9 updated this revision to Diff 501266.Feb 28 2023, 12:37 PM
yota9 marked 4 inline comments as done.

Add comments to code

bolt/lib/Core/BinaryContext.cpp
401

Yes, it is true. Add comment

This revision is now accepted and ready to land.Feb 28 2023, 2:28 PM
This revision was automatically updated to reflect the committed changes.