LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
BuildMetadata.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 2026 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 <string_view>
18#include <cstdint>
19#include <memory>
20#include <ostream>
21#include <string>
22#include <vector>
23
25#include "LIEF/visibility.h"
26#include <optional>
27
28
29namespace LIEF::pdb {
30
31namespace details {
32class BuildMetadata;
33}
34
38 public:
39 enum class LANG : uint8_t {
40 C = 0x00,
41 CPP = 0x01,
42 FORTRAN = 0x02,
43 MASM = 0x03,
44 PASCAL_LANG = 0x04,
45 BASIC = 0x05,
46 COBOL = 0x06,
47 LINK = 0x07,
48 CVTRES = 0x08,
49 CVTPGD = 0x09,
50 CSHARP = 0x0a,
51 VB = 0x0b,
52 ILASM = 0x0c,
53 JAVA = 0x0d,
54 JSCRIPT = 0x0e,
55 MSIL = 0x0f,
56 HLSL = 0x10,
57 OBJC = 0x11,
58 OBJCPP = 0x12,
59 SWIFT = 0x13,
60 ALIASOBJ = 0x14,
61 RUST = 0x15,
62 GO = 0x16,
63
64 UNKNOWN = 0xFF,
65 };
66
67 enum class CPU : uint16_t {
68 INTEL_8080 = 0x0,
69 INTEL_8086 = 0x1,
70 INTEL_80286 = 0x2,
71 INTEL_80386 = 0x3,
72 INTEL_80486 = 0x4,
73 PENTIUM = 0x5,
74 PENTIUMPRO = 0x6,
75 PENTIUM3 = 0x7,
76 MIPS = 0x10,
77 MIPS16 = 0x11,
78 MIPS32 = 0x12,
79 MIPS64 = 0x13,
80 MIPSI = 0x14,
81 MIPSII = 0x15,
82 MIPSIII = 0x16,
83 MIPSIV = 0x17,
84 MIPSV = 0x18,
85 M68000 = 0x20,
86 M68010 = 0x21,
87 M68020 = 0x22,
88 M68030 = 0x23,
89 M68040 = 0x24,
90 ALPHA = 0x30,
91 ALPHA_21164 = 0x31,
92 ALPHA_21164A = 0x32,
93 ALPHA_21264 = 0x33,
94 ALPHA_21364 = 0x34,
95 PPC601 = 0x40,
96 PPC603 = 0x41,
97 PPC604 = 0x42,
98 PPC620 = 0x43,
99 PPCFP = 0x44,
100 PPCBE = 0x45,
101 SH3 = 0x50,
102 SH3E = 0x51,
103 SH3DSP = 0x52,
104 SH4 = 0x53,
105 SHMEDIA = 0x54,
106 ARM3 = 0x60,
107 ARM4 = 0x61,
108 ARM4T = 0x62,
109 ARM5 = 0x63,
110 ARM5T = 0x64,
111 ARM6 = 0x65,
112 ARM_XMAC = 0x66,
113 ARM_WMMX = 0x67,
114 ARM7 = 0x68,
115 OMNI = 0x70,
116 IA64 = 0x80,
117 IA64_2 = 0x81,
118 CEE = 0x90,
119 AM33 = 0xa0,
120 M32R = 0xb0,
121 TRICORE = 0xc0,
122 X64 = 0xd0,
123 EBC = 0xe0,
124 THUMB = 0xf0,
125 ARMNT = 0xf4,
126 ARM64 = 0xf6,
127 HYBRID_X86ARM64 = 0xf7,
128 ARM64EC = 0xf8,
129 ARM64X = 0xf9,
130 D3D11_SHADER = 0x100,
131 UNKNOWN = 0xff,
132 };
133
135 struct version_t {
137 uint16_t major = 0;
138
140 uint16_t minor = 0;
141
143 uint16_t build = 0;
144
146 uint16_t qfe = 0;
147 };
148
153 std::string cwd;
154
157 std::string build_tool;
158
160 std::string source_file;
161
163 std::string pdb;
164
166 std::string command_line;
167 };
168
169 BuildMetadata(std::unique_ptr<details::BuildMetadata> impl);
171
174
177
180 std::string_view version() const LIEF_LIFETIMEBOUND;
181
183 LANG language() const;
184
187
189 std::optional<build_info_t> build_info() const;
190
192 std::vector<std::string> env() const;
193
194 std::string to_string() const;
195
196 LIEF_API friend std::ostream& operator<<(std::ostream& os,
197 const BuildMetadata& meta) {
198 os << meta.to_string();
199 return os;
200 }
201
202 private:
203 std::unique_ptr<details::BuildMetadata> impl_;
204};
205
208
209}
210
211#endif
This class wraps build metadata represented by the codeview symbols: S_COMPILE3, S_COMPILE2,...
Definition BuildMetadata.hpp:37
LANG language() const
Source language.
std::vector< std::string > env() const
Environment information represented by the S_ENVBLOCK symbol.
version_t backend_version() const
Version of the backend (e.g. 14.36.32537).
LANG
Definition BuildMetadata.hpp:39
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.
std::string_view version() const
Version of the tool as a string. For instance, Microsoft (R) CVTRES, Microsoft (R) LINK.
CPU
Definition BuildMetadata.hpp:67
BuildMetadata(std::unique_ptr< details::BuildMetadata > impl)
std::optional< build_info_t > build_info() const
Build information represented by the S_BUILDINFO symbol.
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition BuildMetadata.hpp:31
Definition BuildMetadata.hpp:29
const char * to_string(BuildMetadata::CPU cpu)
This structure represents information wrapped by the S_BUILDINFO symbol.
Definition BuildMetadata.hpp:151
std::string command_line
Command line arguments used to invoke the build tool.
Definition BuildMetadata.hpp:166
std::string cwd
Working directory where the build tool was invoked.
Definition BuildMetadata.hpp:153
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:157
std::string pdb
PDB path.
Definition BuildMetadata.hpp:163
std::string source_file
Source file consumed by the build tool.
Definition BuildMetadata.hpp:160
This structure represents a version for the backend or the frontend.
Definition BuildMetadata.hpp:135
uint16_t minor
Minor version.
Definition BuildMetadata.hpp:140
uint16_t build
Build version.
Definition BuildMetadata.hpp:143
uint16_t qfe
Quick Fix Engineering version.
Definition BuildMetadata.hpp:146
uint16_t major
Major version.
Definition BuildMetadata.hpp:137
#define LIEF_API
Definition visibility.h:45