This is an archive of the discontinued LLVM Phabricator instance.

[LLD][ELF] Make createThunks a class [NFC]
ClosedPublic

Authored by peter.smith on Apr 4 2017, 3:03 AM.

Details

Summary

The main loop for range extension thunks will be something like.

assignAddresses();
while (createThunks()) {
    applySynthetic( ... );
    assignAddresses();
}

createThunks() will need to retain state about the Thunks that it has added so that it can reuse existing thunks. This change is a straight conversion of createThunks into a class so that the state can be retained across calls. The majority of the rangeThunks implementation will be extending this class.

I've kept the class in Relocations.h/Relocations.cpp. It may be better to move this to Thunks.h/Thunks.cpp, the only static functions from Relocations.hpp used will be fromPlt and toPlt.

Alternative ideas:

  • The class could be static so that createThunks() could remain the interface to it.
  • The state could be separated and passed in to createThunks as a parameter

Diff Detail

Repository
rL LLVM

Event Timeline

peter.smith created this revision.Apr 4 2017, 3:03 AM
ruiu accepted this revision.Apr 4 2017, 4:58 PM

LGTM

ELF/Relocations.cpp
998 ↗(On Diff #94024)

Remove == true.

1027 ↗(On Diff #94024)

Flip the condition and do continue early.

ELF/Relocations.h
121 ↗(On Diff #94024)

Please use more vertical space to layout code. I'd add a blank line here as this is the start of a class declaration. Also please add blank lines before comments.

132–137 ↗(On Diff #94024)

So break them into three blocks.

This revision is now accepted and ready to land.Apr 4 2017, 4:58 PM
This revision was automatically updated to reflect the committed changes.