LIEF: Library to Instrument Executable Formats Version 0.17.0
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}
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 struct version_t { uint16_t major = 0;
134 uint16_t minor = 0;
137 uint16_t build = 0;
140 uint16_t qfe = 0;
143 };
144 struct build_info_t { std::string cwd;
150 std::string build_tool;
153 std::string source_file;
156 std::string pdb;
159 std::string command_line;
162 };
163
164 BuildMetadata(std::unique_ptr<details::BuildMetadata> impl);
166 version_t frontend_version() const;
169 version_t backend_version() const;
172 std::string version() const;
176 LANG language() const;
179 CPU target_cpu() const;
182 optional<build_info_t> build_info() const;
185 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
202LIEF_API const char* to_string(BuildMetadata::CPU cpu);
203LIEF_API const char* to_string(BuildMetadata::LANG cpu);
204
205}
206}
207#endif
208
LIEF::pdb::BuildMetadata
This class wraps build metadata represented by the codeview symbols: S_COMPILE3, S_COMPILE2,...
Definition BuildMetadata.hpp:32
LIEF::pdb::BuildMetadata::language
LANG language() const
Source language.
LIEF::pdb::BuildMetadata::env
std::vector< std::string > env() const
Environment information represented by the S_ENVBLOCK symbol.
LIEF::pdb::BuildMetadata::build_info
optional< build_info_t > build_info() const
Build information represented by the S_BUILDINFO symbol.
LIEF::pdb::BuildMetadata::backend_version
version_t backend_version() const
Version of the backend (e.g. 14.36.32537)
LIEF::pdb::BuildMetadata::LANG
LANG
Definition BuildMetadata.hpp:35
LIEF::pdb::BuildMetadata::frontend_version
version_t frontend_version() const
Version of the frontend (e.g. 19.36.32537)
LIEF::pdb::BuildMetadata::~BuildMetadata
~BuildMetadata()
LIEF::pdb::BuildMetadata::to_string
std::string to_string() const
LIEF::pdb::BuildMetadata::target_cpu
CPU target_cpu() const
Target CPU.
LIEF::pdb::BuildMetadata::CPU
CPU
Definition BuildMetadata.hpp:63
LIEF::pdb::BuildMetadata::BuildMetadata
BuildMetadata(std::unique_ptr< details::BuildMetadata > impl)
LIEF::pdb::BuildMetadata::version
std::string version() const
Version of the tool as a string. For instance, Microsoft (R) CVTRES, Microsoft (R) LINK.
LIEF::pdb::BuildMetadata::operator<<
friend std::ostream & operator<<(std::ostream &os, const BuildMetadata &meta)
Definition BuildMetadata.hpp:192
LIEF::pdb::details
Definition BuildMetadata.hpp:26
LIEF::pdb
Definition BuildMetadata.hpp:24
LIEF::pdb::to_string
const char * to_string(BuildMetadata::CPU cpu)
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
optional.hpp
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41