Bug Summary

File:tools/lld/COFF/Config.h
Warning:line 73, column 8
Excessive padding in 'struct lld::coff::Configuration' (50 padding bytes, where 2 is optimal). Optimal fields order: Entry, ErrorLimit, DelayLoadHelper, SEHTable, SEHCount, ImageBase, StackReserve, StackCommit, HeapReserve, HeapCommit, PDBPath, Implib, ManifestDependency, ManifestLevel, ManifestUIAccess, ManifestFile, Exports, ManifestInput, OutputFile, MapFile, GCRoot, NoDefaultLibs, DelayLoads, DLLOrder, Merge, Section, MustMatch, AlternateNames, Machine, Subsystem, DebugTypes, LTOOptLevel, LTOJobs, LTOPartitions, Manifest, ManifestID, MajorImageVersion, MinorImageVersion, MajorOSVersion, MinorOSVersion, Verbose, NoEntry, ColorDiagnostics, DoGC, DoICF, Relocatable, Force, Debug, WriteSymtab, NoDefaultLibAll, DLL, SaveTemps, ManifestUAC, DynamicBase, AllowBind, NxCompat, AllowIsolation, TerminalServerAware, LargeAddressAware, HighEntropyVA, DebugPdb, DumpPdb, consider reordering the fields or adding explicit padding members

Annotated Source Code

1//===- Config.h -------------------------------------------------*- C++ -*-===//
2//
3// The LLVM Linker
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef LLD_COFF_CONFIG_H
11#define LLD_COFF_CONFIG_H
12
13#include "llvm/ADT/StringRef.h"
14#include "llvm/Object/COFF.h"
15#include <cstdint>
16#include <map>
17#include <set>
18#include <string>
19
20namespace lld {
21namespace coff {
22
23using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN;
24using llvm::COFF::WindowsSubsystem;
25using llvm::StringRef;
26class DefinedAbsolute;
27class DefinedRelative;
28class StringChunk;
29struct Symbol;
30class SymbolBody;
31
32// Short aliases.
33static const auto AMD64 = llvm::COFF::IMAGE_FILE_MACHINE_AMD64;
34static const auto ARMNT = llvm::COFF::IMAGE_FILE_MACHINE_ARMNT;
35static const auto I386 = llvm::COFF::IMAGE_FILE_MACHINE_I386;
36
37// Represents an /export option.
38struct Export {
39 StringRef Name; // N in /export:N or /export:E=N
40 StringRef ExtName; // E in /export:E=N
41 SymbolBody *Sym = nullptr;
42 uint16_t Ordinal = 0;
43 bool Noname = false;
44 bool Data = false;
45 bool Private = false;
46
47 // If an export is a form of /export:foo=dllname.bar, that means
48 // that foo should be exported as an alias to bar in the DLL.
49 // ForwardTo is set to "dllname.bar" part. Usually empty.
50 StringRef ForwardTo;
51 StringChunk *ForwardChunk = nullptr;
52
53 // True if this /export option was in .drectves section.
54 bool Directives = false;
55 StringRef SymbolName;
56 StringRef ExportName; // Name in DLL
57
58 bool operator==(const Export &E) {
59 return (Name == E.Name && ExtName == E.ExtName &&
60 Ordinal == E.Ordinal && Noname == E.Noname &&
61 Data == E.Data && Private == E.Private);
62 }
63};
64
65enum class DebugType {
66 None = 0x0,
67 CV = 0x1, /// CodeView
68 PData = 0x2, /// Procedure Data
69 Fixup = 0x4, /// Relocation Table
70};
71
72// Global configuration.
73struct Configuration {
Excessive padding in 'struct lld::coff::Configuration' (50 padding bytes, where 2 is optimal). Optimal fields order: Entry, ErrorLimit, DelayLoadHelper, SEHTable, SEHCount, ImageBase, StackReserve, StackCommit, HeapReserve, HeapCommit, PDBPath, Implib, ManifestDependency, ManifestLevel, ManifestUIAccess, ManifestFile, Exports, ManifestInput, OutputFile, MapFile, GCRoot, NoDefaultLibs, DelayLoads, DLLOrder, Merge, Section, MustMatch, AlternateNames, Machine, Subsystem, DebugTypes, LTOOptLevel, LTOJobs, LTOPartitions, Manifest, ManifestID, MajorImageVersion, MinorImageVersion, MajorOSVersion, MinorOSVersion, Verbose, NoEntry, ColorDiagnostics, DoGC, DoICF, Relocatable, Force, Debug, WriteSymtab, NoDefaultLibAll, DLL, SaveTemps, ManifestUAC, DynamicBase, AllowBind, NxCompat, AllowIsolation, TerminalServerAware, LargeAddressAware, HighEntropyVA, DebugPdb, DumpPdb, consider reordering the fields or adding explicit padding members
74 enum ManifestKind { SideBySide, Embed, No };
75 bool is64() { return Machine == AMD64; }
76
77 llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN;
78 bool Verbose = false;
79 WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN;
80 SymbolBody *Entry = nullptr;
81 bool NoEntry = false;
82 std::string OutputFile;
83 bool ColorDiagnostics;
84 bool DoGC = true;
85 bool DoICF = true;
86 uint64_t ErrorLimit = 20;
87 bool Relocatable = true;
88 bool Force = false;
89 bool Debug = false;
90 bool WriteSymtab = true;
91 unsigned DebugTypes = static_cast<unsigned>(DebugType::None);
92 StringRef PDBPath;
93
94 // Symbols in this set are considered as live by the garbage collector.
95 std::set<SymbolBody *> GCRoot;
96
97 std::set<StringRef> NoDefaultLibs;
98 bool NoDefaultLibAll = false;
99
100 // True if we are creating a DLL.
101 bool DLL = false;
102 StringRef Implib;
103 std::vector<Export> Exports;
104 std::set<std::string> DelayLoads;
105 std::map<std::string, int> DLLOrder;
106 SymbolBody *DelayLoadHelper = nullptr;
107
108 bool SaveTemps = false;
109
110 // Used for SafeSEH.
111 Symbol *SEHTable = nullptr;
112 Symbol *SEHCount = nullptr;
113
114 // Used for /opt:lldlto=N
115 unsigned LTOOptLevel = 2;
116
117 // Used for /opt:lldltojobs=N
118 unsigned LTOJobs = 1;
119 // Used for /opt:lldltopartitions=N
120 unsigned LTOPartitions = 1;
121
122 // Used for /merge:from=to (e.g. /merge:.rdata=.text)
123 std::map<StringRef, StringRef> Merge;
124
125 // Used for /section=.name,{DEKPRSW} to set section attributes.
126 std::map<StringRef, uint32_t> Section;
127
128 // Options for manifest files.
129 ManifestKind Manifest = SideBySide;
130 int ManifestID = 1;
131 StringRef ManifestDependency;
132 bool ManifestUAC = true;
133 std::vector<std::string> ManifestInput;
134 StringRef ManifestLevel = "'asInvoker'";
135 StringRef ManifestUIAccess = "'false'";
136 StringRef ManifestFile;
137
138 // Used for /failifmismatch.
139 std::map<StringRef, StringRef> MustMatch;
140
141 // Used for /alternatename.
142 std::map<StringRef, StringRef> AlternateNames;
143
144 // Used for /lldmap.
145 std::string MapFile;
146
147 uint64_t ImageBase = -1;
148 uint64_t StackReserve = 1024 * 1024;
149 uint64_t StackCommit = 4096;
150 uint64_t HeapReserve = 1024 * 1024;
151 uint64_t HeapCommit = 4096;
152 uint32_t MajorImageVersion = 0;
153 uint32_t MinorImageVersion = 0;
154 uint32_t MajorOSVersion = 6;
155 uint32_t MinorOSVersion = 0;
156 bool DynamicBase = true;
157 bool AllowBind = true;
158 bool NxCompat = true;
159 bool AllowIsolation = true;
160 bool TerminalServerAware = true;
161 bool LargeAddressAware = false;
162 bool HighEntropyVA = false;
163
164 // This is for debugging.
165 bool DebugPdb = false;
166 bool DumpPdb = false;
167};
168
169extern Configuration *Config;
170
171} // namespace coff
172} // namespace lld
173
174#endif