Class: PatchELF::Saver
- Inherits:
-
Object
- Object
- PatchELF::Saver
- Defined in:
- lib/patchelf/saver.rb
Overview
Internal use only.
For Patcher to do patching things and save to file.
Instance Attribute Summary collapse
-
#in_file ⇒ String
readonly
Input filename.
-
#out_file ⇒ String
readonly
Output filename.
Instance Method Summary collapse
-
#initialize(in_file, out_file, set) ⇒ Saver
constructor
Instantiate a Saver object.
- #save! ⇒ void
Constructor Details
#initialize(in_file, out_file, set) ⇒ Saver
Instantiate a PatchELF::Saver object.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/patchelf/saver.rb', line 29 def initialize(in_file, out_file, set) @in_file = in_file @out_file = out_file @set = set # [{Integer => String}] @inline_patch = {} f = File.open(in_file) @elf = ELFTools::ELFFile.new(f) @mm = PatchELF::MM.new(@elf) @strtab_extend_requests = [] @append_dyn = [] # Ensure file is closed when the {Saver} object is garbage collected. ObjectSpace.define_finalizer(self, Helper.close_file_proc(f)) end |
Instance Attribute Details
#in_file ⇒ String (readonly)
Returns Input filename.
22 23 24 |
# File 'lib/patchelf/saver.rb', line 22 def in_file @in_file end |
#out_file ⇒ String (readonly)
Returns Output filename.
23 24 25 |
# File 'lib/patchelf/saver.rb', line 23 def out_file @out_file end |
Instance Method Details
#save! ⇒ void
This method returns an undefined value.
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/patchelf/saver.rb', line 46 def save! # In this method we assume all attributes that should exist do exist. # e.g. DT_INTERP, DT_DYNAMIC. These should have been checked in the patcher. patch_interpreter patch_dynamic @mm.dispatch! FileUtils.cp(in_file, out_file) if out_file != in_file patch_out(@out_file) # Let output file have the same permission as input. FileUtils.chmod(File.stat(in_file).mode, out_file) end |