patchelf
patchelf copied to clipboard
Introduce Finally to help track section rewrites
Similarly to a concept used in NixOS/nix codebase, introduce the Finally
class that can be given a lambda to execute on destructor.
The desired effect is to execute some code on a scope leave, in this case the method return.
This is used to make sure we only apply sectionRewrite
once per modification and can now support early returns in the code paths.
CC @reidpr
This is desired since I saw some pull-requests may add early returns in the codepaths. Rather than trying to track this across all pull-requests, I thought this approach similar to what Nix does might be sensible.
Open to discussion on it :)