Bug Summary

File:tools/lld/COFF/Config.h
Warning:line 82, column 8
Excessive padding in 'struct lld::coff::Configuration' (43 padding bytes, where 3 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, Order, MapFile, NoDefaultLibs, DelayLoads, DLLOrder, LTOCachePolicy, Merge, Section, AlignComm, MustMatch, AlternateNames, PDBPath, Machine, Subsystem, DebugTypes, GuardCF, LTOOptLevel, LTOJobs, LTOPartitions, Manifest, ManifestID, MajorImageVersion, MinorImageVersion, MajorOSVersion, MinorOSVersion, Verbose, NoEntry, DoGC, DoICF, Relocatable, Force, Debug, DebugDwarf, DebugGHashes, ShowTiming, NoDefaultLibAll, DLL, SaveTemps, ManifestUAC, DynamicBase, AllowBind, NxCompat, AllowIsolation, TerminalServerAware, LargeAddressAware, HighEntropyVA, AppContainer, MinGW, WarnLocallyDefinedImported, Incremental, consider reordering the fields or adding explicit padding members

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name InputFiles.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-eagerly-assume -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -ffunction-sections -fdata-sections -resource-dir /usr/lib/llvm-7/lib/clang/7.0.0 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I /build/llvm-toolchain-snapshot-7~svn325118/build-llvm/tools/lld/COFF -I /build/llvm-toolchain-snapshot-7~svn325118/tools/lld/COFF -I /build/llvm-toolchain-snapshot-7~svn325118/tools/lld/include -I /build/llvm-toolchain-snapshot-7~svn325118/build-llvm/tools/lld/include -I /build/llvm-toolchain-snapshot-7~svn325118/build-llvm/include -I /build/llvm-toolchain-snapshot-7~svn325118/include -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/x86_64-linux-gnu/c++/7.3.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/7.3.0/../../../../include/c++/7.3.0/backward -internal-isystem /usr/include/clang/7.0.0/include/ -internal-isystem /usr/local/include -internal-isystem /usr/lib/llvm-7/lib/clang/7.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-comment -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /build/llvm-toolchain-snapshot-7~svn325118/build-llvm/tools/lld/COFF -ferror-limit 19 -fmessage-length 0 -fvisibility-inlines-hidden -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -o /tmp/scan-build-2018-02-14-150435-17243-1 -x c++ /build/llvm-toolchain-snapshot-7~svn325118/tools/lld/COFF/InputFiles.cpp
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/StringMap.h"
14#include "llvm/ADT/StringRef.h"
15#include "llvm/Object/COFF.h"
16#include "llvm/Support/CachePruning.h"
17#include <cstdint>
18#include <map>
19#include <set>
20#include <string>
21
22namespace lld {
23namespace coff {
24
25using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN;
26using llvm::COFF::WindowsSubsystem;
27using llvm::StringRef;
28class DefinedAbsolute;
29class DefinedRelative;
30class StringChunk;
31class Symbol;
32
33// Short aliases.
34static const auto AMD64 = llvm::COFF::IMAGE_FILE_MACHINE_AMD64;
35static const auto ARM64 = llvm::COFF::IMAGE_FILE_MACHINE_ARM64;
36static const auto ARMNT = llvm::COFF::IMAGE_FILE_MACHINE_ARMNT;
37static const auto I386 = llvm::COFF::IMAGE_FILE_MACHINE_I386;
38
39// Represents an /export option.
40struct Export {
41 StringRef Name; // N in /export:N or /export:E=N
42 StringRef ExtName; // E in /export:E=N
43 Symbol *Sym = nullptr;
44 uint16_t Ordinal = 0;
45 bool Noname = false;
46 bool Data = false;
47 bool Private = false;
48 bool Constant = false;
49
50 // If an export is a form of /export:foo=dllname.bar, that means
51 // that foo should be exported as an alias to bar in the DLL.
52 // ForwardTo is set to "dllname.bar" part. Usually empty.
53 StringRef ForwardTo;
54 StringChunk *ForwardChunk = nullptr;
55
56 // True if this /export option was in .drectves section.
57 bool Directives = false;
58 StringRef SymbolName;
59 StringRef ExportName; // Name in DLL
60
61 bool operator==(const Export &E) {
62 return (Name == E.Name && ExtName == E.ExtName &&
63 Ordinal == E.Ordinal && Noname == E.Noname &&
64 Data == E.Data && Private == E.Private);
65 }
66};
67
68enum class DebugType {
69 None = 0x0,
70 CV = 0x1, /// CodeView
71 PData = 0x2, /// Procedure Data
72 Fixup = 0x4, /// Relocation Table
73};
74
75enum class GuardCFLevel {
76 Off,
77 NoLongJmp, // Emit gfids but no longjmp tables
78 Full, // Enable all protections.
79};
80
81// Global configuration.
82struct Configuration {
Excessive padding in 'struct lld::coff::Configuration' (43 padding bytes, where 3 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, Order, MapFile, NoDefaultLibs, DelayLoads, DLLOrder, LTOCachePolicy, Merge, Section, AlignComm, MustMatch, AlternateNames, PDBPath, Machine, Subsystem, DebugTypes, GuardCF, LTOOptLevel, LTOJobs, LTOPartitions, Manifest, ManifestID, MajorImageVersion, MinorImageVersion, MajorOSVersion, MinorOSVersion, Verbose, NoEntry, DoGC, DoICF, Relocatable, Force, Debug, DebugDwarf, DebugGHashes, ShowTiming, NoDefaultLibAll, DLL, SaveTemps, ManifestUAC, DynamicBase, AllowBind, NxCompat, AllowIsolation, TerminalServerAware, LargeAddressAware, HighEntropyVA, AppContainer, MinGW, WarnLocallyDefinedImported, Incremental, consider reordering the fields or adding explicit padding members
83 enum ManifestKind { SideBySide, Embed, No };
84 bool is64() { return Machine == AMD64 || Machine == ARM64; }
85
86 llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN;
87 bool Verbose = false;
88 WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN;
89 Symbol *Entry = nullptr;
90 bool NoEntry = false;
91 std::string OutputFile;
92 std::string ImportName;
93 bool DoGC = true;
94 bool DoICF = true;
95 bool Relocatable = true;
96 bool Force = false;
97 bool Debug = false;
98 bool DebugDwarf = false;
99 bool DebugGHashes = false;
100 bool ShowTiming = false;
101 unsigned DebugTypes = static_cast<unsigned>(DebugType::None);
102 llvm::SmallString<128> PDBPath;
103 std::vector<llvm::StringRef> Argv;
104
105 // Symbols in this set are considered as live by the garbage collector.
106 std::vector<Symbol *> GCRoot;
107
108 std::set<StringRef> NoDefaultLibs;
109 bool NoDefaultLibAll = false;
110
111 // True if we are creating a DLL.
112 bool DLL = false;
113 StringRef Implib;
114 std::vector<Export> Exports;
115 std::set<std::string> DelayLoads;
116 std::map<std::string, int> DLLOrder;
117 Symbol *DelayLoadHelper = nullptr;
118
119 bool SaveTemps = false;
120
121 // /guard:cf
122 GuardCFLevel GuardCF = GuardCFLevel::Off;
123
124 // Used for SafeSEH.
125 Symbol *SEHTable = nullptr;
126 Symbol *SEHCount = nullptr;
127
128 // Used for /opt:lldlto=N
129 unsigned LTOOptLevel = 2;
130
131 // Used for /opt:lldltojobs=N
132 unsigned LTOJobs = 0;
133 // Used for /opt:lldltopartitions=N
134 unsigned LTOPartitions = 1;
135
136 // Used for /opt:lldltocache=path
137 StringRef LTOCache;
138 // Used for /opt:lldltocachepolicy=policy
139 llvm::CachePruningPolicy LTOCachePolicy;
140
141 // Used for /merge:from=to (e.g. /merge:.rdata=.text)
142 std::map<StringRef, StringRef> Merge;
143
144 // Used for /section=.name,{DEKPRSW} to set section attributes.
145 std::map<StringRef, uint32_t> Section;
146
147 // Options for manifest files.
148 ManifestKind Manifest = No;
149 int ManifestID = 1;
150 StringRef ManifestDependency;
151 bool ManifestUAC = true;
152 std::vector<std::string> ManifestInput;
153 StringRef ManifestLevel = "'asInvoker'";
154 StringRef ManifestUIAccess = "'false'";
155 StringRef ManifestFile;
156
157 // Used for /aligncomm.
158 std::map<std::string, int> AlignComm;
159
160 // Used for /failifmismatch.
161 std::map<StringRef, StringRef> MustMatch;
162
163 // Used for /alternatename.
164 std::map<StringRef, StringRef> AlternateNames;
165
166 // Used for /order.
167 llvm::StringMap<int> Order;
168
169 // Used for /lldmap.
170 std::string MapFile;
171
172 uint64_t ImageBase = -1;
173 uint64_t StackReserve = 1024 * 1024;
174 uint64_t StackCommit = 4096;
175 uint64_t HeapReserve = 1024 * 1024;
176 uint64_t HeapCommit = 4096;
177 uint32_t MajorImageVersion = 0;
178 uint32_t MinorImageVersion = 0;
179 uint32_t MajorOSVersion = 6;
180 uint32_t MinorOSVersion = 0;
181 bool DynamicBase = true;
182 bool AllowBind = true;
183 bool NxCompat = true;
184 bool AllowIsolation = true;
185 bool TerminalServerAware = true;
186 bool LargeAddressAware = false;
187 bool HighEntropyVA = false;
188 bool AppContainer = false;
189 bool MinGW = false;
190 bool WarnLocallyDefinedImported = true;
191 bool Incremental = true;
192};
193
194extern Configuration *Config;
195
196} // namespace coff
197} // namespace lld
198
199#endif