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
|
|
|
use PhpProfiler\Lib\Integer\UInt64; |
17
|
|
|
|
18
|
|
|
final class Elf64SymbolTableEntry |
19
|
|
|
{ |
20
|
|
|
public const STB_LOCAL = 0; |
21
|
|
|
public const STB_GLOBAL = 1; |
22
|
|
|
public const STB_WEAK = 2; |
23
|
|
|
public const STB_LOOS = 10; |
24
|
|
|
public const STB_HIOS = 12; |
25
|
|
|
public const STB_LOPROC = 13; |
26
|
|
|
public const STB_HIPROC = 15; |
27
|
|
|
|
28
|
|
|
public const STT_NOTYPE = 0; |
29
|
|
|
public const STT_OBJECT = 1; |
30
|
|
|
public const STT_FUNC = 2; |
31
|
|
|
public const STT_SECTION = 3; |
32
|
|
|
public const STT_FILE = 4; |
33
|
|
|
public const STT_COMMON = 5; |
34
|
|
|
public const STT_TLS = 6; |
35
|
|
|
public const STT_LOOS = 10; |
36
|
|
|
public const STT_HIOS = 12; |
37
|
|
|
public const STT_LOPROC = 13; |
38
|
|
|
public const STT_HIPROC = 15; |
39
|
|
|
|
40
|
|
|
public const STV_DEFAULT = 0; |
41
|
|
|
public const STV_INTERNAL = 1; |
42
|
|
|
public const STV_HIDDEN = 2; |
43
|
|
|
public const STV_PROTECTED = 3; |
44
|
|
|
public const STV_EXPORTED = 4; |
45
|
|
|
public const STV_SINGLETON = 5; |
46
|
|
|
public const STV_ELIMINATE = 6; |
47
|
|
|
|
48
|
|
|
public function __construct( |
49
|
|
|
public int $st_name, // Elf64_Word |
50
|
|
|
public int $st_info, // unsigned char |
51
|
|
|
public int $st_other, // unsigned char |
52
|
|
|
public int $st_shndx, // Elf64_Half |
53
|
|
|
public UInt64 $st_value, // Elf64_Addr |
54
|
|
|
public UInt64 $st_size, // Elf64_Xword |
55
|
|
|
) { |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function getType(): int |
59
|
|
|
{ |
60
|
|
|
return (($this->st_info) & 0xf); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function getBind(): int |
64
|
|
|
{ |
65
|
|
|
return $this->st_info >> 4; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public static function createInfo(int $bind, int $type): int |
69
|
|
|
{ |
70
|
|
|
return ($bind << 4) + ($type & 0x0f); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function isTls(): bool |
74
|
|
|
{ |
75
|
|
|
return $this->getType() === self::STT_TLS; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function isUndefined(): bool |
79
|
|
|
{ |
80
|
|
|
return $this->st_name === 0 |
81
|
|
|
and $this->st_info === 0 |
82
|
|
|
and $this->st_other === 0 |
83
|
|
|
and $this->st_shndx === 0 |
84
|
|
|
and $this->st_value->lo === 0 |
85
|
|
|
and $this->st_value->hi === 0 |
86
|
|
|
and $this->st_size->lo === 0 |
87
|
|
|
and $this->st_size->hi === 0; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|