LIEF: Library to Instrument Executable Formats Version 1.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 <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 enum class LANG : uint8_t {
35 C = 0x00,
36 CPP = 0x01,
37 FORTRAN = 0x02,
38 MASM = 0x03,
39 PASCAL_LANG = 0x04,
40 BASIC = 0x05,
41 COBOL = 0x06,
42 LINK = 0x07,
43 CVTRES = 0x08,
44 CVTPGD = 0x09,
45 CSHARP = 0x0a,
46 VB = 0x0b,
47 ILASM = 0x0c,
48 JAVA = 0x0d,
49 JSCRIPT = 0x0e,
50 MSIL = 0x0f,
51 HLSL = 0x10,
52 OBJC = 0x11,
53 OBJCPP = 0x12,
54 SWIFT = 0x13,
55 ALIASOBJ = 0x14,
56 RUST = 0x15,
57 GO = 0x16,
58
59 UNKNOWN = 0xFF,
60 };
61
62 enum class CPU : uint16_t {
63 INTEL_8080 = 0x0,
64 INTEL_8086 = 0x1,
65 INTEL_80286 = 0x2,
66 INTEL_80386 = 0x3,
67 INTEL_80486 = 0x4,
68 PENTIUM = 0x5,
69 PENTIUMPRO = 0x6,
70 PENTIUM3 = 0x7,
71 MIPS = 0x10,
72 MIPS16 = 0x11,
73 MIPS32 = 0x12,
74 MIPS64 = 0x13,
75 MIPSI = 0x14,
76 MIPSII = 0x15,
77 MIPSIII = 0x16,
78 MIPSIV = 0x17,
79 MIPSV = 0x18,
80 M68000 = 0x20,
81 M68010 = 0x21,
82 M68020 = 0x22,
83 M68030 = 0x23,
84 M68040 = 0x24,
85 ALPHA = 0x30,
86 ALPHA_21164 = 0x31,
87 ALPHA_21164A = 0x32,
88 ALPHA_21264 = 0x33,
89 ALPHA_21364 = 0x34,
90 PPC601 = 0x40,
91 PPC603 = 0x41,
92 PPC604 = 0x42,
93 PPC620 = 0x43,
94 PPCFP = 0x44,
95 PPCBE = 0x45,
96 SH3 = 0x50,
97 SH3E = 0x51,
98 SH3DSP = 0x52,
99 SH4 = 0x53,
100 SHMEDIA = 0x54,
101 ARM3 = 0x60,
102 ARM4 = 0x61,
103 ARM4T = 0x62,
104 ARM5 = 0x63,
105 ARM5T = 0x64,
106 ARM6 = 0x65,
107 ARM_XMAC = 0x66,
108 ARM_WMMX = 0x67,
109 ARM7 = 0x68,
110 OMNI = 0x70,
111 IA64 = 0x80,
112 IA64_2 = 0x81,
113 CEE = 0x90,
114 AM33 = 0xa0,
115 M32R = 0xb0,
116 TRICORE = 0xc0,
117 X64 = 0xd0,
118 EBC = 0xe0,
119 THUMB = 0xf0,
120 ARMNT = 0xf4,
121 ARM64 = 0xf6,
122 HYBRID_X86ARM64 = 0xf7,
123 ARM64EC = 0xf8,
124 ARM64X = 0xf9,
125 D3D11_SHADER = 0x100,
126 UNKNOWN = 0xff,
127 };
128
130 struct version_t {
132 uint16_t major = 0;
133
135 uint16_t minor = 0;
136
138 uint16_t build = 0;
139
141 uint16_t qfe = 0;
142 };
143
148 std::string cwd;
149
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 std::ostream& operator<<(std::ostream& os,
192 const BuildMetadata& meta) {
193 os << meta.to_string();
194 return os;
195 }
196
197 private:
198 std::unique_ptr<details::BuildMetadata> impl_;
199};
200
203
204}
205}
206#endif
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:34
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:62
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:191
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:146
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:148
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:130
uint16_t minor
Minor version.
Definition BuildMetadata.hpp:135
uint16_t build
Build version.
Definition BuildMetadata.hpp:138
uint16_t qfe
Quick Fix Engineering version.
Definition BuildMetadata.hpp:141
uint16_t major
Major version.
Definition BuildMetadata.hpp:132
#define LIEF_API
Definition visibility.h:45