sass-embedded 1.83.4-x64-mingw32 → 1.85.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4269ead9530643a3259c865f9a5eb48b6635aa32738d47cc296eefc43b5deff6
4
- data.tar.gz: 587f4ea78fc07ab8d5d3f1fe60e97ce1af2425cce549273cbceb3bae27f1f646
3
+ metadata.gz: cf20323e0ca824dafab5095cd5cb6e51e31964f7fa8e3c4a06ec4b7af862dac9
4
+ data.tar.gz: f54ac85a015c116a7c0a4904bd0e71ef3ff14babdf1ead515b7e6af05f082317
5
5
  SHA512:
6
- metadata.gz: 34ac1a9901e5819e26ea9a9321b1066ebb5728dc9c33feb99f160f15dd8e79f0af6c3349570284aafe4b591426ed168f875b0a65234657ec3e03c0a4e33a947f
7
- data.tar.gz: 8fca8338e4f46252147d4993b13f4af1af0122ab2ae1e6acb2b64aa94383be61e5413dbb7d2d4adfbee8ef77b00f40a19d085edfbc43e4cba76849745e5d5c98
6
+ metadata.gz: d1fb407583f8ae10dc5a70208c4574ffbe36fe705efde4d0df8ef625984a43c50b11100f40e85dc39f91f5c4b72259d22454c310c65f1958a382aabedd68d328
7
+ data.tar.gz: 00d93a19c5f96cfc55879cf3676a9db6e4015690e23ef4d9f991827174aa74edb6e6444f37fa7a1b404f41e7dcea10862b17f7000e48b4c224c731be0a521772
Binary file
Binary file
data/lib/sass/elf.rb CHANGED
@@ -7,73 +7,30 @@ module Sass
7
7
  # @see https://github.com/torvalds/linux/blob/HEAD/include/uapi/linux/elf.h
8
8
  # @see https://github.com/torvalds/linux/blob/HEAD/kernel/kexec_elf.c
9
9
  class ELF
10
- module PackInfo
11
- PACK_MAP = {
12
- Elf32_Ehdr: 'S<2L<5S<6',
13
- Elf64_Ehdr: 'S<2L<Q<3L<S<6',
14
- Elf32_Phdr: 'L<8',
15
- Elf64_Phdr: 'L<2Q<6'
16
- }.freeze
17
-
18
- SIZE_MAP = {
19
- Elf32_Ehdr: 36,
20
- Elf64_Ehdr: 48,
21
- Elf32_Phdr: 32,
22
- Elf64_Phdr: 56
23
- }.freeze
24
-
25
- STRUCT_MAP = {
26
- Elf32_Ehdr: %i[
27
- e_type
28
- e_machine
29
- e_version
30
- e_entry
31
- e_phoff
32
- e_shoff
33
- e_flags
34
- e_ehsize
35
- e_phentsize
36
- e_phnum
37
- e_shentsize
38
- e_shnum
39
- e_shstrndx
40
- ].freeze,
41
- Elf64_Ehdr: %i[
42
- e_type
43
- e_machine
44
- e_version
45
- e_entry
46
- e_phoff
47
- e_shoff
48
- e_flags
49
- e_ehsize
50
- e_phentsize
51
- e_phnum
52
- e_shentsize
53
- e_shnum
54
- e_shstrndx
55
- ].freeze,
56
- Elf32_Phdr: %i[
57
- p_type
58
- p_offset
59
- p_vaddr
60
- p_paddr
61
- p_filesz
62
- p_memsz
63
- p_flags
64
- p_align
65
- ].freeze,
66
- Elf64_Phdr: %i[
67
- p_type
68
- p_flags
69
- p_offset
70
- p_vaddr
71
- p_paddr
72
- p_filesz
73
- p_memsz
74
- p_align
75
- ].freeze
76
- }.freeze
10
+ # The {PackInfo} class.
11
+ class PackInfo
12
+ def initialize(format:, sizeof:, struct:)
13
+ @format_le = format.freeze
14
+ @format_be = format.tr('<', '>').freeze
15
+ @sizeof = sizeof.freeze
16
+ @struct = struct.freeze
17
+ end
18
+
19
+ attr_reader :sizeof
20
+
21
+ def pack(io, data, little_endian)
22
+ raise ArgumentError if io.write(data.values_at(*@struct).pack(format(little_endian))) != @sizeof
23
+ end
24
+
25
+ def unpack(io, little_endian)
26
+ @struct.zip(io.read(@sizeof).unpack(format(little_endian))).to_h
27
+ end
28
+
29
+ private
30
+
31
+ def format(little_endian)
32
+ little_endian ? @format_le : @format_be
33
+ end
77
34
  end
78
35
 
79
36
  private_constant :PackInfo
@@ -92,6 +49,8 @@ module Sass
92
49
  PT_LOPROC = 0x70000000
93
50
  PT_HIPROC = 0x7fffffff
94
51
 
52
+ PN_XNUM = 0xffff
53
+
95
54
  # These constants define the different elf file types
96
55
  ET_NONE = 0
97
56
  ET_REL = 1
@@ -103,6 +62,154 @@ module Sass
103
62
 
104
63
  EI_NIDENT = 16
105
64
 
65
+ Elf32_Ehdr = PackInfo.new(
66
+ format: "a#{EI_NIDENT}S<2L<5S<6",
67
+ sizeof: 52,
68
+ struct: %i[
69
+ e_ident
70
+ e_type
71
+ e_machine
72
+ e_version
73
+ e_entry
74
+ e_phoff
75
+ e_shoff
76
+ e_flags
77
+ e_ehsize
78
+ e_phentsize
79
+ e_phnum
80
+ e_shentsize
81
+ e_shnum
82
+ e_shstrndx
83
+ ]
84
+ ).freeze
85
+
86
+ Elf64_Ehdr = PackInfo.new(
87
+ format: "a#{EI_NIDENT}S<2L<Q<3L<S<6",
88
+ sizeof: 64,
89
+ struct: %i[
90
+ e_ident
91
+ e_type
92
+ e_machine
93
+ e_version
94
+ e_entry
95
+ e_phoff
96
+ e_shoff
97
+ e_flags
98
+ e_ehsize
99
+ e_phentsize
100
+ e_phnum
101
+ e_shentsize
102
+ e_shnum
103
+ e_shstrndx
104
+ ]
105
+ ).freeze
106
+
107
+ # These constants define the permissions on sections in the program header, p_flags.
108
+ PF_R = 0x4
109
+ PF_W = 0x2
110
+ PF_X = 0x1
111
+
112
+ Elf32_Phdr = PackInfo.new(
113
+ format: 'L<8',
114
+ sizeof: 32,
115
+ struct: %i[
116
+ p_type
117
+ p_offset
118
+ p_vaddr
119
+ p_paddr
120
+ p_filesz
121
+ p_memsz
122
+ p_flags
123
+ p_align
124
+ ]
125
+ ).freeze
126
+
127
+ Elf64_Phdr = PackInfo.new(
128
+ format: 'L<2Q<6',
129
+ sizeof: 56,
130
+ struct: %i[
131
+ p_type
132
+ p_flags
133
+ p_offset
134
+ p_vaddr
135
+ p_paddr
136
+ p_filesz
137
+ p_memsz
138
+ p_align
139
+ ]
140
+ ).freeze
141
+
142
+ # sh_type
143
+ SHT_NULL = 0
144
+ SHT_PROGBITS = 1
145
+ SHT_SYMTAB = 2
146
+ SHT_STRTAB = 3
147
+ SHT_RELA = 4
148
+ SHT_HASH = 5
149
+ SHT_DYNAMIC = 6
150
+ SHT_NOTE = 7
151
+ SHT_NOBITS = 8
152
+ SHT_REL = 9
153
+ SHT_SHLIB = 10
154
+ SHT_DYNSYM = 11
155
+ SHT_NUM = 12
156
+ SHT_LOPROC = 0x70000000
157
+ SHT_HIPROC = 0x7fffffff
158
+ SHT_LOUSER = 0x80000000
159
+ SHT_HIUSER = 0xffffffff
160
+
161
+ # sh_flags
162
+ SHF_WRITE = 0x1
163
+ SHF_ALLOC = 0x2
164
+ SHF_EXECINSTR = 0x4
165
+ SHF_RELA_LIVEPATCH = 0x00100000
166
+ SHF_RO_AFTER_INIT = 0x00200000
167
+ SHF_MASKPROC = 0xf0000000
168
+
169
+ # special section indexes
170
+ SHN_UNDEF = 0
171
+ SHN_LORESERVE = 0xff00
172
+ SHN_LOPROC = 0xff00
173
+ SHN_HIPROC = 0xff1f
174
+ SHN_LIVEPATCH = 0xff20
175
+ SHN_ABS = 0xfff1
176
+ SHN_COMMON = 0xfff2
177
+ SHN_HIRESERVE = 0xffff
178
+
179
+ Elf32_Shdr = PackInfo.new(
180
+ format: 'L<10',
181
+ sizeof: 40,
182
+ struct: %i[
183
+ sh_name
184
+ sh_type
185
+ sh_flags
186
+ sh_addr
187
+ sh_offset
188
+ sh_size
189
+ sh_link
190
+ sh_info
191
+ sh_addralign
192
+ sh_entsize
193
+ ]
194
+ ).freeze
195
+
196
+ Elf64_Shdr = PackInfo.new(
197
+ format: 'L<2Q<4L<2Q<2',
198
+ sizeof: 64,
199
+ struct: %i[
200
+ sh_name
201
+ sh_type
202
+ sh_flags
203
+ sh_addr
204
+ sh_offset
205
+ sh_size
206
+ sh_link
207
+ sh_info
208
+ sh_addralign
209
+ sh_entsize
210
+ ]
211
+ ).freeze
212
+
106
213
  # e_ident[] indexes
107
214
  EI_MAG0 = 0
108
215
  EI_MAG1 = 1
@@ -133,24 +240,84 @@ module Sass
133
240
  ELFDATA2LSB = 1
134
241
  ELFDATA2MSB = 2
135
242
 
136
- def initialize(buffer)
137
- @buffer = buffer
243
+ def initialize(io, program_headers: true, section_headers: false)
244
+ io.rewind
245
+ e_ident = io.read(EI_NIDENT).unpack('C*')
246
+ raise ArgumentError unless e_ident.slice(EI_MAG0, SELFMAG).pack('C*') == ELFMAG
247
+
248
+ case e_ident[EI_CLASS]
249
+ when ELFCLASS32
250
+ elf_ehdr = Elf32_Ehdr
251
+ elf_phdr = Elf32_Phdr
252
+ elf_shdr = Elf32_Shdr
253
+ when ELFCLASS64
254
+ elf_ehdr = Elf64_Ehdr
255
+ elf_phdr = Elf64_Phdr
256
+ elf_shdr = Elf64_Shdr
257
+ else
258
+ raise EncodingError
259
+ end
260
+
261
+ case e_ident[EI_DATA]
262
+ when ELFDATA2LSB
263
+ little_endian = true
264
+ when ELFDATA2MSB
265
+ little_endian = false
266
+ else
267
+ raise EncodingError
268
+ end
269
+
270
+ io.rewind
271
+ ehdr = elf_ehdr.unpack(io, little_endian)
272
+ ehdr[:e_ident] = e_ident
138
273
 
139
- @ehdr = { e_ident: @buffer.read(EI_NIDENT).unpack('C*') }
140
- raise ArgumentError unless @ehdr[:e_ident].slice(EI_MAG0, SELFMAG).pack('C*') == ELFMAG
274
+ phdrs = if program_headers && ehdr[:e_phnum].positive?
275
+ io.seek(ehdr[:e_phoff], IO::SEEK_SET)
276
+ Array.new(ehdr[:e_phnum]) do
277
+ elf_phdr.unpack(io, little_endian)
278
+ end
279
+ else
280
+ []
281
+ end
141
282
 
142
- case @ehdr[:e_ident][EI_CLASS]
283
+ shdrs = if section_headers && ehdr[:e_shnum].positive?
284
+ io.seek(ehdr[:e_shoff], IO::SEEK_SET)
285
+ Array.new(ehdr[:e_shnum]) do
286
+ elf_shdr.unpack(io, little_endian)
287
+ end
288
+ else
289
+ []
290
+ end
291
+
292
+ @io = io
293
+ @ehdr = ehdr
294
+ @phdrs = phdrs
295
+ @shdrs = shdrs
296
+ end
297
+
298
+ def dump(io)
299
+ e_ident = @ehdr[:e_ident]
300
+ raise ArgumentError unless e_ident.slice(EI_MAG0, SELFMAG).pack('C*') == ELFMAG
301
+
302
+ ehdr = @ehdr.dup
303
+ ehdr[:e_ident] = e_ident.pack('C*')
304
+ phdrs = @phdrs
305
+ shdrs = @shdrs
306
+
307
+ case e_ident[EI_CLASS]
143
308
  when ELFCLASS32
144
- elf_ehdr = :Elf32_Ehdr
145
- elf_phdr = :Elf32_Phdr
309
+ elf_ehdr = Elf32_Ehdr
310
+ elf_phdr = Elf32_Phdr
311
+ elf_shdr = Elf32_Shdr
146
312
  when ELFCLASS64
147
- elf_ehdr = :Elf64_Ehdr
148
- elf_phdr = :Elf64_Phdr
313
+ elf_ehdr = Elf64_Ehdr
314
+ elf_phdr = Elf64_Phdr
315
+ elf_shdr = Elf64_Shdr
149
316
  else
150
317
  raise EncodingError
151
318
  end
152
319
 
153
- case @ehdr[:e_ident][EI_DATA]
320
+ case e_ident[EI_DATA]
154
321
  when ELFDATA2LSB
155
322
  little_endian = true
156
323
  when ELFDATA2MSB
@@ -159,12 +326,20 @@ module Sass
159
326
  raise EncodingError
160
327
  end
161
328
 
162
- @ehdr.merge!(read(elf_ehdr, little_endian))
329
+ io.rewind
330
+ elf_ehdr.pack(io, ehdr, little_endian)
163
331
 
164
- @buffer.seek(@ehdr[:e_phoff], IO::SEEK_SET)
165
- @proghdrs = Array.new(@ehdr[:e_phnum]) do
166
- read(elf_phdr, little_endian)
332
+ io.seek(ehdr[:e_phoff], IO::SEEK_SET) if (ehdr[:e_phnum]).positive?
333
+ phdrs.each do |phdr|
334
+ elf_phdr.pack(io, phdr, little_endian)
167
335
  end
336
+
337
+ io.seek(ehdr[:e_shoff], IO::SEEK_SET) if (ehdr[:e_shnum]).positive?
338
+ shdrs.each do |shdr|
339
+ elf_shdr.pack(io, shdr, little_endian)
340
+ end
341
+
342
+ io.flush
168
343
  end
169
344
 
170
345
  def relocatable?
@@ -184,24 +359,16 @@ module Sass
184
359
  end
185
360
 
186
361
  def interpreter
187
- phdr = @proghdrs.find { |p| p[:p_type] == PT_INTERP }
362
+ phdr = @phdrs.find { |p| p[:p_type] == PT_INTERP }
188
363
  return if phdr.nil?
189
364
 
190
- @buffer.seek(phdr[:p_offset], IO::SEEK_SET)
191
- interpreter = @buffer.read(phdr[:p_filesz])
365
+ @io.seek(phdr[:p_offset], IO::SEEK_SET)
366
+ interpreter = @io.read(phdr[:p_filesz])
192
367
  raise EncodingError unless interpreter.end_with?("\0")
193
368
 
194
369
  interpreter.chomp!("\0")
195
370
  end
196
371
 
197
- private
198
-
199
- def read(type, little_endian)
200
- size = PackInfo::SIZE_MAP[type]
201
- format = little_endian ? PackInfo::PACK_MAP[type] : PackInfo::PACK_MAP[type].tr('<', '>')
202
- [PackInfo::STRUCT_MAP[type], @buffer.read(size).unpack(format)].transpose.to_h
203
- end
204
-
205
372
  INTERPRETER = begin
206
373
  proc_self_exe = '/proc/self/exe'
207
374
  if File.exist?(proc_self_exe)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sass
4
4
  module Embedded
5
- VERSION = '1.83.4'
5
+ VERSION = '1.85.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass-embedded
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.83.4
4
+ version: 1.85.0
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - なつき
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-01-14 00:00:00.000000000 Z
10
+ date: 2025-02-14 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: google-protobuf
@@ -111,8 +111,8 @@ licenses:
111
111
  - MIT
112
112
  metadata:
113
113
  bug_tracker_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/issues
114
- documentation_uri: https://rubydoc.info/gems/sass-embedded/1.83.4
115
- source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.83.4
114
+ documentation_uri: https://rubydoc.info/gems/sass-embedded/1.85.0
115
+ source_code_uri: https://github.com/sass-contrib/sass-embedded-host-ruby/tree/v1.85.0
116
116
  funding_uri: https://github.com/sponsors/ntkme
117
117
  rubygems_mfa_required: 'true'
118
118
  rdoc_options: []
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
131
  requirements: []
132
- rubygems_version: 3.6.2
132
+ rubygems_version: 3.6.3
133
133
  specification_version: 4
134
134
  summary: Use dart-sass with Ruby!
135
135
  test_files: []