patchelf 1.4.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/patchelf/alt_saver.rb +14 -13
- data/lib/patchelf/cli.rb +2 -2
- data/lib/patchelf/version.rb +1 -1
- metadata +10 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6864f1200743dc0168be4dfba4f26745189fd922a8c8bee181de7a25be206a1
|
4
|
+
data.tar.gz: c5f80780027865b91dd5f4ab32fd4f24aa04c89e38d73c65190de7cbd529620f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d68242284575b512eba346ceb18bf6d399a50ab3bf6da6a5dcea1a69fc7eccbc20d08d502e9f13e54756aa914a38e82539d05256336b3999350567981ca46455
|
7
|
+
data.tar.gz: 67757566f0d8861cd91efb6d5cab270a64f2e09920c94c099bf0bf9cb5ae57b87ff696f4fe8e1418575a6a4f39e0b0036a9aaedcdcd05a473303cd892263e8e3
|
data/lib/patchelf/alt_saver.rb
CHANGED
@@ -177,7 +177,7 @@ module PatchELF
|
|
177
177
|
end
|
178
178
|
|
179
179
|
def modify_needed
|
180
|
-
# due to gsoc time constraints only
|
180
|
+
# due to gsoc time constraints only implementing features used by brew.
|
181
181
|
raise NotImplementedError
|
182
182
|
end
|
183
183
|
|
@@ -257,7 +257,7 @@ module PatchELF
|
|
257
257
|
new_rpath_strtab_idx = shdr_dynstr.sh_size.to_i
|
258
258
|
new_dynstr[new_rpath_strtab_idx..(new_rpath_strtab_idx + new_rpath.size)] = "#{new_rpath}\x00"
|
259
259
|
|
260
|
-
dyn_tags.
|
260
|
+
dyn_tags.each_value do |dyn|
|
261
261
|
dyn[:header].d_val = new_rpath_strtab_idx
|
262
262
|
with_buf_at(dyn[:offset]) { |b| dyn[:header].write(b) }
|
263
263
|
end
|
@@ -273,7 +273,7 @@ module PatchELF
|
|
273
273
|
def modify_soname
|
274
274
|
return unless ehdr.e_type == ELFTools::Constants::ET_DYN
|
275
275
|
|
276
|
-
# due to gsoc time constraints only
|
276
|
+
# due to gsoc time constraints only implementing features used by brew.
|
277
277
|
raise NotImplementedError
|
278
278
|
end
|
279
279
|
|
@@ -306,7 +306,7 @@ module PatchELF
|
|
306
306
|
# consider DT_NULL when copying
|
307
307
|
replacement_size = (dt_null_idx + 1) * dyn_num_bytes
|
308
308
|
|
309
|
-
# make space for dt_runpath tag at the top, shift data by one tag
|
309
|
+
# make space for dt_runpath tag at the top, shift data by one tag position
|
310
310
|
new_dynamic_data[dyn_num_bytes..(replacement_size + dyn_num_bytes)] = new_dynamic_data[0..replacement_size]
|
311
311
|
|
312
312
|
dyn_rpath = ELFTools::Structs::ELF_Dyn.new endian: endian, elf_class: elf_class
|
@@ -451,10 +451,10 @@ module PatchELF
|
|
451
451
|
|
452
452
|
begin
|
453
453
|
new_index = new_section_idx(old_shndx)
|
454
|
-
next unless new_index
|
455
454
|
rescue ArgumentError
|
456
455
|
Logger.warn "entry #{entry} in symbol table refers to a non existing section, skipping"
|
457
456
|
end
|
457
|
+
next unless new_index
|
458
458
|
|
459
459
|
sym[pack[:st_shndx]] = new_index
|
460
460
|
|
@@ -561,11 +561,12 @@ module PatchELF
|
|
561
561
|
if needed_space > start_offset
|
562
562
|
needed_space += seg_num_bytes # new load segment is required
|
563
563
|
|
564
|
-
|
564
|
+
extra_bytes = needed_space - start_offset
|
565
|
+
needed_pages = Helper.alignup(extra_bytes, page_size) / page_size
|
565
566
|
Logger.debug "needed pages is #{needed_pages}"
|
566
567
|
raise PatchError, 'virtual address space underrun' if needed_pages * page_size > first_page
|
567
568
|
|
568
|
-
shift_file(needed_pages, start_offset)
|
569
|
+
shift_file(needed_pages, start_offset, extra_bytes)
|
569
570
|
|
570
571
|
first_page -= needed_pages * page_size
|
571
572
|
start_offset += needed_pages * page_size
|
@@ -776,7 +777,7 @@ module PatchELF
|
|
776
777
|
end
|
777
778
|
# rubocop:enable Metrics/PerceivedComplexity
|
778
779
|
|
779
|
-
def shift_file(extra_pages, start_offset)
|
780
|
+
def shift_file(extra_pages, start_offset, extra_bytes)
|
780
781
|
raise PatchError, "start_offset(#{start_offset}) < ehdr.num_bytes" if start_offset < ehdr.num_bytes
|
781
782
|
|
782
783
|
oldsz = @buffer.size
|
@@ -799,8 +800,8 @@ module PatchELF
|
|
799
800
|
p_offset: split_phdr.p_offset - split_shift - shift,
|
800
801
|
p_vaddr: split_phdr.p_vaddr - split_shift - shift,
|
801
802
|
p_paddr: split_phdr.p_paddr - split_shift - shift,
|
802
|
-
p_filesz: split_shift +
|
803
|
-
p_memsz: split_shift +
|
803
|
+
p_filesz: split_shift + extra_bytes,
|
804
|
+
p_memsz: split_shift + extra_bytes,
|
804
805
|
p_flags: ELFTools::Constants::PF_R | ELFTools::Constants::PF_W,
|
805
806
|
p_align: page_size
|
806
807
|
)
|
@@ -966,7 +967,7 @@ module PatchELF
|
|
966
967
|
def overwrite_replaced_sections
|
967
968
|
# the original source says this has to be done separately to
|
968
969
|
# prevent clobbering the previously written section contents.
|
969
|
-
@replaced_sections.
|
970
|
+
@replaced_sections.each_key do |rsec_name|
|
970
971
|
shdr = find_section(rsec_name)&.header
|
971
972
|
next unless shdr
|
972
973
|
|
@@ -976,7 +977,7 @@ module PatchELF
|
|
976
977
|
end
|
977
978
|
end
|
978
979
|
|
979
|
-
def
|
980
|
+
def write_section_alignment(shdr)
|
980
981
|
return if shdr.sh_type == ELFTools::Constants::SHT_NOTE && shdr.sh_addralign <= @section_alignment
|
981
982
|
|
982
983
|
shdr.sh_addralign = @section_alignment
|
@@ -1012,7 +1013,7 @@ module PatchELF
|
|
1012
1013
|
shdr.sh_addr = start_addr + (cur_off - start_offset)
|
1013
1014
|
shdr.sh_size = rsec_data.size
|
1014
1015
|
|
1015
|
-
|
1016
|
+
write_section_alignment(shdr)
|
1016
1017
|
|
1017
1018
|
seg_type = {
|
1018
1019
|
'.interp' => ELFTools::Constants::PT_INTERP,
|
data/lib/patchelf/cli.rb
CHANGED
@@ -63,11 +63,11 @@ module PatchELF
|
|
63
63
|
|
64
64
|
def patch_requests
|
65
65
|
@options[:set].each do |sym, val|
|
66
|
-
patcher.__send__("#{sym}="
|
66
|
+
patcher.__send__(:"#{sym}=", val)
|
67
67
|
end
|
68
68
|
|
69
69
|
@options[:needed].each do |type, val|
|
70
|
-
patcher.__send__("#{type}_needed"
|
70
|
+
patcher.__send__(:"#{type}_needed", *val)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
data/lib/patchelf/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patchelf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- david942j
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elftools
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,22 +70,16 @@ dependencies:
|
|
70
70
|
name: simplecov
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0.17'
|
76
|
-
- - "<"
|
73
|
+
- - ">="
|
77
74
|
- !ruby/object:Gem::Version
|
78
|
-
version: '0.
|
75
|
+
version: '0.22'
|
79
76
|
type: :development
|
80
77
|
prerelease: false
|
81
78
|
version_requirements: !ruby/object:Gem::Requirement
|
82
79
|
requirements:
|
83
|
-
- - "
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0.17'
|
86
|
-
- - "<"
|
80
|
+
- - ">="
|
87
81
|
- !ruby/object:Gem::Version
|
88
|
-
version: '0.
|
82
|
+
version: '0.22'
|
89
83
|
- !ruby/object:Gem::Dependency
|
90
84
|
name: tty-platform
|
91
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,14 +143,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
143
|
requirements:
|
150
144
|
- - ">="
|
151
145
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
146
|
+
version: '3.1'
|
153
147
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
148
|
requirements:
|
155
149
|
- - ">="
|
156
150
|
- !ruby/object:Gem::Version
|
157
151
|
version: '0'
|
158
152
|
requirements: []
|
159
|
-
rubygems_version: 3.
|
153
|
+
rubygems_version: 3.5.3
|
160
154
|
signing_key:
|
161
155
|
specification_version: 4
|
162
156
|
summary: patchelf
|