sass-embedded 1.62.1-x86_64-linux-musl → 1.63.1-x86_64-linux-musl
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/exe/sass +21 -0
- data/ext/sass/cli.rb +12 -0
- data/ext/sass/{sass_embedded/dart-sass-embedded → dart-sass/sass} +3 -3
- data/ext/sass/{sass_embedded → dart-sass}/src/LICENSE +157 -34
- data/ext/sass/dart-sass/src/dart +0 -0
- data/ext/sass/dart-sass/src/sass.snapshot +0 -0
- data/ext/sass/embedded_sass_pb.rb +24 -291
- data/lib/sass/compile_error.rb +12 -10
- data/lib/sass/compile_result.rb +1 -1
- data/lib/sass/elf.rb +276 -0
- data/lib/sass/embedded/channel.rb +3 -3
- data/lib/sass/embedded/compiler.rb +11 -8
- data/lib/sass/embedded/dispatcher.rb +26 -30
- data/lib/sass/embedded/host/logger_registry.rb +27 -24
- data/lib/sass/embedded/host.rb +50 -20
- data/lib/sass/embedded/protofier.rb +8 -7
- data/lib/sass/embedded/varint.rb +6 -0
- data/lib/sass/embedded/version.rb +1 -1
- data/lib/sass/embedded.rb +3 -4
- data/lib/sass/logger/source_span.rb +2 -2
- metadata +17 -100
- data/ext/sass/embedded.rb +0 -12
- data/ext/sass/sass_embedded/src/dart +0 -0
- data/ext/sass/sass_embedded/src/dart-sass-embedded.snapshot +0 -0
- data/lib/sass/embedded/async.rb +0 -58
- data/lib/sass/embedded/elf.rb +0 -275
data/lib/sass/embedded/elf.rb
DELETED
@@ -1,275 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Sass
|
4
|
-
class Embedded
|
5
|
-
# The {ELF} class.
|
6
|
-
#
|
7
|
-
# It parses ELF header to extract interpreter.
|
8
|
-
# @see https://github.com/torvalds/linux/blob/HEAD/include/uapi/linux/elf.h
|
9
|
-
# @see https://github.com/torvalds/linux/blob/HEAD/kernel/kexec_elf.c
|
10
|
-
class ELF
|
11
|
-
# rubocop:disable Naming/ConstantName
|
12
|
-
|
13
|
-
# 32-bit ELF base types.
|
14
|
-
Elf32_Addr = :__u32
|
15
|
-
Elf32_Half = :__u16
|
16
|
-
Elf32_Off = :__u32
|
17
|
-
Elf32_Sword = :__s32
|
18
|
-
Elf32_Word = :__u32
|
19
|
-
|
20
|
-
# 64-bit ELF base types.
|
21
|
-
Elf64_Addr = :__u64
|
22
|
-
Elf64_Half = :__u16
|
23
|
-
Elf64_SHalf = :__s16
|
24
|
-
Elf64_Off = :__u64
|
25
|
-
Elf64_Sword = :__s32
|
26
|
-
Elf64_Word = :__u32
|
27
|
-
Elf64_Xword = :__u64
|
28
|
-
Elf64_Sxword = :__s64
|
29
|
-
|
30
|
-
# rubocop:enable Naming/ConstantName
|
31
|
-
|
32
|
-
# These constants are for the segment types stored in the image headers
|
33
|
-
PT_NULL = 0
|
34
|
-
PT_LOAD = 1
|
35
|
-
PT_DYNAMIC = 2
|
36
|
-
PT_INTERP = 3
|
37
|
-
PT_NOTE = 4
|
38
|
-
PT_SHLIB = 5
|
39
|
-
PT_PHDR = 6
|
40
|
-
PT_TLS = 7
|
41
|
-
PT_LOOS = 0x60000000
|
42
|
-
PT_HIOS = 0x6fffffff
|
43
|
-
PT_LOPROC = 0x70000000
|
44
|
-
PT_HIPROC = 0x7fffffff
|
45
|
-
PT_GNU_EH_FRAME = (PT_LOOS + 0x474e550)
|
46
|
-
PT_GNU_STACK = (PT_LOOS + 0x474e551)
|
47
|
-
PT_GNU_RELRO = (PT_LOOS + 0x474e552)
|
48
|
-
PT_GNU_PROPERTY = (PT_LOOS + 0x474e553)
|
49
|
-
|
50
|
-
# These constants define the different elf file types
|
51
|
-
ET_NONE = 0
|
52
|
-
ET_REL = 1
|
53
|
-
ET_EXEC = 2
|
54
|
-
ET_DYN = 3
|
55
|
-
ET_CORE = 4
|
56
|
-
ET_LOPROC = 0xff00
|
57
|
-
ET_HIPROC = 0xffff
|
58
|
-
|
59
|
-
EI_NIDENT = 16
|
60
|
-
|
61
|
-
# rubocop:disable Naming/ConstantName
|
62
|
-
|
63
|
-
Elf32_Ehdr = [
|
64
|
-
[:unsigned_char, :e_ident, EI_NIDENT],
|
65
|
-
[Elf32_Half, :e_type],
|
66
|
-
[Elf32_Half, :e_machine],
|
67
|
-
[Elf32_Word, :e_version],
|
68
|
-
[Elf32_Addr, :e_entry],
|
69
|
-
[Elf32_Off, :e_phoff],
|
70
|
-
[Elf32_Off, :e_shoff],
|
71
|
-
[Elf32_Word, :e_flags],
|
72
|
-
[Elf32_Half, :e_ehsize],
|
73
|
-
[Elf32_Half, :e_phentsize],
|
74
|
-
[Elf32_Half, :e_phnum],
|
75
|
-
[Elf32_Half, :e_shentsize],
|
76
|
-
[Elf32_Half, :e_shnum],
|
77
|
-
[Elf32_Half, :e_shstrndx]
|
78
|
-
].freeze
|
79
|
-
|
80
|
-
Elf64_Ehdr = [
|
81
|
-
[:unsigned_char, :e_ident, EI_NIDENT],
|
82
|
-
[Elf64_Half, :e_type],
|
83
|
-
[Elf64_Half, :e_machine],
|
84
|
-
[Elf64_Word, :e_version],
|
85
|
-
[Elf64_Addr, :e_entry],
|
86
|
-
[Elf64_Off, :e_phoff],
|
87
|
-
[Elf64_Off, :e_shoff],
|
88
|
-
[Elf64_Word, :e_flags],
|
89
|
-
[Elf64_Half, :e_ehsize],
|
90
|
-
[Elf64_Half, :e_phentsize],
|
91
|
-
[Elf64_Half, :e_phnum],
|
92
|
-
[Elf64_Half, :e_shentsize],
|
93
|
-
[Elf64_Half, :e_shnum],
|
94
|
-
[Elf64_Half, :e_shstrndx]
|
95
|
-
].freeze
|
96
|
-
|
97
|
-
Elf32_Phdr = [
|
98
|
-
[Elf32_Word, :p_type],
|
99
|
-
[Elf32_Off, :p_offset],
|
100
|
-
[Elf32_Addr, :p_vaddr],
|
101
|
-
[Elf32_Addr, :p_paddr],
|
102
|
-
[Elf32_Word, :p_filesz],
|
103
|
-
[Elf32_Word, :p_memsz],
|
104
|
-
[Elf32_Word, :p_flags],
|
105
|
-
[Elf32_Word, :p_align]
|
106
|
-
].freeze
|
107
|
-
|
108
|
-
Elf64_Phdr = [
|
109
|
-
[Elf64_Word, :p_type],
|
110
|
-
[Elf64_Word, :p_flags],
|
111
|
-
[Elf64_Off, :p_offset],
|
112
|
-
[Elf64_Addr, :p_vaddr],
|
113
|
-
[Elf64_Addr, :p_paddr],
|
114
|
-
[Elf64_Xword, :p_filesz],
|
115
|
-
[Elf64_Xword, :p_memsz],
|
116
|
-
[Elf64_Xword, :p_align]
|
117
|
-
].freeze
|
118
|
-
|
119
|
-
# rubocop:enable Naming/ConstantName
|
120
|
-
|
121
|
-
# e_ident[] indexes
|
122
|
-
EI_MAG0 = 0
|
123
|
-
EI_MAG1 = 1
|
124
|
-
EI_MAG2 = 2
|
125
|
-
EI_MAG3 = 3
|
126
|
-
EI_CLASS = 4
|
127
|
-
EI_DATA = 5
|
128
|
-
EI_VERSION = 6
|
129
|
-
EI_OSABI = 7
|
130
|
-
EI_PAD = 8
|
131
|
-
|
132
|
-
# EI_MAG
|
133
|
-
ELFMAG0 = 0x7f
|
134
|
-
ELFMAG1 = 'E'.ord
|
135
|
-
ELFMAG2 = 'L'.ord
|
136
|
-
ELFMAG3 = 'F'.ord
|
137
|
-
ELFMAG = [ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3].pack('C*')
|
138
|
-
SELFMAG = 4
|
139
|
-
|
140
|
-
# e_ident[EI_CLASS]
|
141
|
-
ELFCLASSNONE = 0
|
142
|
-
ELFCLASS32 = 1
|
143
|
-
ELFCLASS64 = 2
|
144
|
-
ELFCLASSNUM = 3
|
145
|
-
|
146
|
-
# e_ident[EI_DATA]
|
147
|
-
ELFDATANONE = 0
|
148
|
-
ELFDATA2LSB = 1
|
149
|
-
ELFDATA2MSB = 2
|
150
|
-
|
151
|
-
def initialize(buffer)
|
152
|
-
@buffer = buffer
|
153
|
-
@ehdr = read_ehdr
|
154
|
-
@buffer.seek(@ehdr[:e_phoff], :SET)
|
155
|
-
@proghdrs = Array.new(@ehdr[:e_phnum]) do
|
156
|
-
read_phdr
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
def relocatable?
|
161
|
-
@ehdr[:e_type] == ET_REL
|
162
|
-
end
|
163
|
-
|
164
|
-
def executable?
|
165
|
-
@ehdr[:e_type] == ET_EXEC
|
166
|
-
end
|
167
|
-
|
168
|
-
def shared_object?
|
169
|
-
@ehdr[:e_type] == ET_DYN
|
170
|
-
end
|
171
|
-
|
172
|
-
def core?
|
173
|
-
@ehdr[:e_type] == ET_CORE
|
174
|
-
end
|
175
|
-
|
176
|
-
def interpreter
|
177
|
-
phdr = @proghdrs.find { |p| p[:p_type] == PT_INTERP }
|
178
|
-
return if phdr.nil?
|
179
|
-
|
180
|
-
@buffer.seek(phdr[:p_offset], :SET)
|
181
|
-
interpreter = @buffer.read(phdr[:p_filesz])
|
182
|
-
raise ArgumentError unless interpreter.end_with?("\0")
|
183
|
-
|
184
|
-
interpreter.chomp("\0")
|
185
|
-
end
|
186
|
-
|
187
|
-
private
|
188
|
-
|
189
|
-
def file_class
|
190
|
-
@ehdr[:e_ident][EI_CLASS]
|
191
|
-
end
|
192
|
-
|
193
|
-
def data_encoding
|
194
|
-
@ehdr[:e_ident][EI_DATA]
|
195
|
-
end
|
196
|
-
|
197
|
-
def read_ehdr
|
198
|
-
@ehdr = { e_ident: @buffer.read(EI_NIDENT).unpack('C*') }
|
199
|
-
raise ArgumentError unless @ehdr[:e_ident].slice(EI_MAG0, SELFMAG).pack('C*') == ELFMAG
|
200
|
-
|
201
|
-
case file_class
|
202
|
-
when ELFCLASS32
|
203
|
-
Elf32_Ehdr
|
204
|
-
when ELFCLASS64
|
205
|
-
Elf64_Ehdr
|
206
|
-
else
|
207
|
-
raise ArgumentError
|
208
|
-
end.drop(1).to_h do |field|
|
209
|
-
[field[1], read1(field[0])]
|
210
|
-
end.merge!(@ehdr)
|
211
|
-
end
|
212
|
-
|
213
|
-
def read_phdr
|
214
|
-
case file_class
|
215
|
-
when ELFCLASS32
|
216
|
-
Elf32_Phdr
|
217
|
-
when ELFCLASS64
|
218
|
-
Elf64_Phdr
|
219
|
-
else
|
220
|
-
raise ArgumentError
|
221
|
-
end.to_h do |field|
|
222
|
-
[field[1], read1(field[0])]
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
def read1(type)
|
227
|
-
case data_encoding
|
228
|
-
when ELFDATA2LSB
|
229
|
-
case type
|
230
|
-
when :__u16
|
231
|
-
@buffer.read(2).unpack1('v*')
|
232
|
-
when :__u32
|
233
|
-
@buffer.read(4).unpack1('V*')
|
234
|
-
when :__u64
|
235
|
-
buffer = @buffer.read(8).unpack('V*')
|
236
|
-
(buffer[1] << 32) | buffer[0]
|
237
|
-
else
|
238
|
-
raise ArgumentError
|
239
|
-
end
|
240
|
-
when ELFDATA2MSB
|
241
|
-
case type
|
242
|
-
when :__u16
|
243
|
-
@buffer.read(2).unpack1('n*')
|
244
|
-
when :__u32
|
245
|
-
@buffer.read(4).unpack1('N*')
|
246
|
-
when :__u64
|
247
|
-
buffer = @buffer.read(8).unpack('N*')
|
248
|
-
(buffer[0] << 32) | buffer[1]
|
249
|
-
else
|
250
|
-
raise ArgumentError
|
251
|
-
end
|
252
|
-
else
|
253
|
-
raise ArgumentError
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
INTERPRETER = proc do
|
258
|
-
proc_self_exe = '/proc/self/exe'
|
259
|
-
if File.exist?(proc_self_exe)
|
260
|
-
File.open(proc_self_exe, 'rb') do |exe|
|
261
|
-
elf = ELF.new(exe)
|
262
|
-
interpreter = elf.interpreter
|
263
|
-
if interpreter.nil? && elf.shared_object?
|
264
|
-
File.readlink(proc_self_exe)
|
265
|
-
else
|
266
|
-
interpreter
|
267
|
-
end
|
268
|
-
end
|
269
|
-
end
|
270
|
-
end.call
|
271
|
-
end
|
272
|
-
|
273
|
-
private_constant :ELF
|
274
|
-
end
|
275
|
-
end
|