Bug Summary

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