LIEF: Library to Instrument Executable Formats Version 0.17.4
Loading...
Searching...
No Matches
BuildMetadata.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 2025 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_PDB_BUILD_METADATA_H
16#define LIEF_PDB_BUILD_METADATA_H
17#include <memory>
18#include <ostream>
19
20#include "LIEF/visibility.h"
21#include "LIEF/optional.hpp"
22
23namespace LIEF {
24namespace pdb {
25
26namespace details {
27class BuildMetadata;
28}
29
33 public:
34
35 enum class LANG : uint8_t {
36 C = 0x00,
37 CPP = 0x01,
38 FORTRAN = 0x02,
39 MASM = 0x03,
40 PASCAL_LANG = 0x04,
41 BASIC = 0x05,
42 COBOL = 0x06,
43 LINK = 0x07,
44 CVTRES = 0x08,
45 CVTPGD = 0x09,
46 CSHARP = 0x0a,
47 VB = 0x0b,
48 ILASM = 0x0c,
49 JAVA = 0x0d,
50 JSCRIPT = 0x0e,
51 MSIL = 0x0f,
52 HLSL = 0x10,
53 OBJC = 0x11,
54 OBJCPP = 0x12,
55 SWIFT = 0x13,
56 ALIASOBJ = 0x14,
57 RUST = 0x15,
58 GO = 0x16,
59
60 UNKNOWN = 0xFF,
61 };
62
63 enum class CPU : uint16_t {
64 INTEL_8080 = 0x0,
65 INTEL_8086 = 0x1,
66 INTEL_80286 = 0x2,
67 INTEL_80386 = 0x3,
68 INTEL_80486 = 0x4,
69 PENTIUM = 0x5,
70 PENTIUMPRO = 0x6,
71 PENTIUM3 = 0x7,
72 MIPS = 0x10,
73 MIPS16 = 0x11,
74 MIPS32 = 0x12,
75 MIPS64 = 0x13,
76 MIPSI = 0x14,
77 MIPSII = 0x15,
78 MIPSIII = 0x16,
79 MIPSIV = 0x17,
80 MIPSV = 0x18,
81 M68000 = 0x20,
82 M68010 = 0x21,
83 M68020 = 0x22,
84 M68030 = 0x23,
85 M68040 = 0x24,
86 ALPHA = 0x30,
87 ALPHA_21164 = 0x31,
88 ALPHA_21164A = 0x32,
89 ALPHA_21264 = 0x33,
90 ALPHA_21364 = 0x34,
91 PPC601 = 0x40,
92 PPC603 = 0x41,
93 PPC604 = 0x42,
94 PPC620 = 0x43,
95 PPCFP = 0x44,
96 PPCBE = 0x45,
97 SH3 = 0x50,
98 SH3E = 0x51,
99 SH3DSP = 0x52,
100 SH4 = 0x53,
101 SHMEDIA = 0x54,
102 ARM3 = 0x60,
103 ARM4 = 0x61,
104 ARM4T = 0x62,
105 ARM5 = 0x63,
106 ARM5T = 0x64,
107 ARM6 = 0x65,
108 ARM_XMAC = 0x66,
109 ARM_WMMX = 0x67,
110 ARM7 = 0x68,
111 OMNI = 0x70,
112 IA64 = 0x80,
113 IA64_2 = 0x81,
114 CEE = 0x90,
115 AM33 = 0xa0,
116 M32R = 0xb0,
117 TRICORE = 0xc0,
118 X64 = 0xd0,
119 EBC = 0xe0,
120 THUMB = 0xf0,
121 ARMNT = 0xf4,
122 ARM64 = 0xf6,
123 HYBRID_X86ARM64 = 0xf7,
124 ARM64EC = 0xf8,
125 ARM64X = 0xf9,
126 D3D11_SHADER = 0x100,
127 UNKNOWN = 0xff,
128 };
129
131 struct version_t {
133 uint16_t major = 0;
134
136 uint16_t minor = 0;
137
139 uint16_t build = 0;
140
142 uint16_t qfe = 0;
143 };
144
149 std::string cwd;
150
152 std::string build_tool;
153
155 std::string source_file;
156
158 std::string pdb;
159
161 std::string command_line;
162 };
163
164 BuildMetadata(std::unique_ptr<details::BuildMetadata> impl);
166
169
172
175 std::string version() const;
176
178 LANG language() const;
179
182
185
187 std::vector<std::string> env() const;
188
189 std::string to_string() const;
190
191 LIEF_API friend
192 std::ostream& operator<<(std::ostream& os, const BuildMetadata& meta)
193 {
194 os << meta.to_string();
195 return os;
196 }
197
198 private:
199 std::unique_ptr<details::BuildMetadata> impl_;
200};
201
204
205}
206}
207#endif
208
Definition optional.hpp:23
This class wraps build metadata represented by the codeview symbols: S_COMPILE3, S_COMPILE2,...
Definition BuildMetadata.hpp:32
LANG language() const
Source language.
std::vector< std::string > env() const
Environment information represented by the S_ENVBLOCK symbol.
optional< build_info_t > build_info() const
Build information represented by the S_BUILDINFO symbol.
version_t backend_version() const
Version of the backend (e.g. 14.36.32537).
LANG
Definition BuildMetadata.hpp:35
version_t frontend_version() const
Version of the frontend (e.g. 19.36.32537).
std::string to_string() const
CPU target_cpu() const
Target CPU.
CPU
Definition BuildMetadata.hpp:63
BuildMetadata(std::unique_ptr< details::BuildMetadata > impl)
std::string version() const
Version of the tool as a string. For instance, Microsoft (R) CVTRES, Microsoft (R) LINK.
friend std::ostream & operator<<(std::ostream &os, const BuildMetadata &meta)
Definition BuildMetadata.hpp:192
Definition BuildMetadata.hpp:26
Definition BuildMetadata.hpp:24
const char * to_string(BuildMetadata::CPU cpu)
LIEF namespace.
Definition Abstract/Binary.hpp:40
This structure represents information wrapped by the S_BUILDINFO symbol.
Definition BuildMetadata.hpp:147
std::string command_line
Command line arguments used to invoke the build tool.
Definition BuildMetadata.hpp:161
std::string cwd
Working directory where the build tool was invoked.
Definition BuildMetadata.hpp:149
std::string build_tool
Path to the build tool (e.g. C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14...
Definition BuildMetadata.hpp:152
std::string pdb
PDB path.
Definition BuildMetadata.hpp:158
std::string source_file
Source file consumed by the build tool.
Definition BuildMetadata.hpp:155
This structure represents a version for the backend or the frontend.
Definition BuildMetadata.hpp:131
uint16_t minor
Minor version.
Definition BuildMetadata.hpp:136
uint16_t build
Build version.
Definition BuildMetadata.hpp:139
uint16_t qfe
Quick Fix Engineeringa version.
Definition BuildMetadata.hpp:142
uint16_t major
Major version.
Definition BuildMetadata.hpp:133
#define LIEF_API
Definition visibility.h:41