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