|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the sj-i/php-profiler package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) sji <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace PhpProfiler\Lib\Elf\Structure\Elf64; |
|
15
|
|
|
|
|
16
|
|
|
final class Elf64DynamicStructureArray |
|
17
|
|
|
{ |
|
18
|
|
|
/** @var Elf64DynamicStructure[] */ |
|
19
|
|
|
private array $entries; |
|
20
|
|
|
|
|
21
|
|
|
public function __construct(Elf64DynamicStructure ...$entries) |
|
22
|
|
|
{ |
|
23
|
|
|
$this->entries = $entries; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @return Elf64DynamicStructure[] |
|
28
|
|
|
*/ |
|
29
|
|
|
public function findAll(): array |
|
30
|
|
|
{ |
|
31
|
|
|
return $this->entries; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @return Elf64DynamicStructure[] |
|
36
|
|
|
*/ |
|
37
|
|
|
public function findStringTableEntries(): array |
|
38
|
|
|
{ |
|
39
|
|
|
$entries = []; |
|
40
|
|
|
foreach ($this->entries as $entry) { |
|
41
|
|
|
if ($entry->isStringTable()) { |
|
42
|
|
|
$entries[Elf64DynamicStructure::DT_STRTAB] = $entry; |
|
43
|
|
|
} elseif ($entry->isStringTableSize()) { |
|
44
|
|
|
$entries[Elf64DynamicStructure::DT_STRSZ] = $entry; |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
return $entries; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @return Elf64DynamicStructure[] |
|
52
|
|
|
*/ |
|
53
|
|
|
public function findSymbolTablEntries(): array |
|
54
|
|
|
{ |
|
55
|
|
|
$entries = []; |
|
56
|
|
|
foreach ($this->entries as $entry) { |
|
57
|
|
|
if ($entry->isSymbolTable()) { |
|
58
|
|
|
$entries[Elf64DynamicStructure::DT_SYMTAB] = $entry; |
|
59
|
|
|
} elseif ($entry->isSymbolTableEntrySize()) { |
|
60
|
|
|
$entries[Elf64DynamicStructure::DT_SYMENT] = $entry; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
return $entries; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function findGnuHashTableEntry(): ?Elf64DynamicStructure |
|
67
|
|
|
{ |
|
68
|
|
|
foreach ($this->entries as $entry) { |
|
69
|
|
|
if ($entry->isGnuHashTable()) { |
|
70
|
|
|
return $entry; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
return null; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
public function findDebugEntry(): ?Elf64DynamicStructure |
|
77
|
|
|
{ |
|
78
|
|
|
foreach ($this->entries as $entry) { |
|
79
|
|
|
if ($entry->isDebug()) { |
|
80
|
|
|
return $entry; |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
return null; |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|