|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the reliforp/reli-prof 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 Reli\Lib\Elf\Process; |
|
15
|
|
|
|
|
16
|
|
|
use Reli\Lib\Elf\Parser\ElfParserException; |
|
17
|
|
|
use Reli\Lib\Elf\Structure\Elf64\Elf64SymbolTableEntry; |
|
18
|
|
|
use Reli\Lib\Elf\SymbolResolver\Elf64SymbolResolver; |
|
19
|
|
|
use Reli\Lib\Elf\SymbolResolver\SymbolResolverCreatorInterface; |
|
20
|
|
|
use Reli\Lib\Process\MemoryMap\ProcessModuleMemoryMap; |
|
21
|
|
|
use Reli\Lib\Process\MemoryReader\MemoryReaderInterface; |
|
22
|
|
|
|
|
23
|
|
|
final class Elf64LazyParseSymbolResolver implements Elf64SymbolResolver |
|
24
|
|
|
{ |
|
25
|
|
|
private ?Elf64SymbolResolver $resolver_cache = null; |
|
26
|
|
|
|
|
27
|
|
|
public function __construct( |
|
28
|
|
|
private string $path, |
|
29
|
|
|
private MemoryReaderInterface $memory_reader, |
|
30
|
|
|
private int $pid, |
|
31
|
|
|
private ProcessModuleMemoryMap $module_memory_map, |
|
32
|
|
|
private SymbolResolverCreatorInterface $symbol_resolver_creator, |
|
33
|
|
|
) { |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
private function loadResolver(): Elf64SymbolResolver |
|
37
|
|
|
{ |
|
38
|
|
|
try { |
|
39
|
|
|
return $this->symbol_resolver_creator->createLinearScanResolverFromPath($this->path); |
|
40
|
|
|
} catch (ElfParserException $e) { |
|
41
|
|
|
try { |
|
42
|
|
|
return $this->symbol_resolver_creator->createDynamicResolverFromPath($this->path); |
|
43
|
|
|
} catch (ElfParserException $e) { |
|
44
|
|
|
return $this->symbol_resolver_creator->createDynamicResolverFromProcessMemory( |
|
45
|
|
|
$this->memory_reader, |
|
46
|
|
|
$this->pid, |
|
47
|
|
|
$this->module_memory_map |
|
48
|
|
|
); |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function resolve(string $symbol_name): Elf64SymbolTableEntry |
|
54
|
|
|
{ |
|
55
|
|
|
if (!isset($this->resolver_cache)) { |
|
56
|
|
|
$this->resolver_cache = $this->loadResolver(); |
|
57
|
|
|
} |
|
58
|
|
|
return $this->resolver_cache->resolve($symbol_name); |
|
|
|
|
|
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.