[lld] r240446 - [MachO] Initialize all fields of NormalizedFile.
Benjamin Kramer
benny.kra at googlemail.com
Tue Jun 23 12:55:05 PDT 2015
Author: d0k
Date: Tue Jun 23 14:55:04 2015
New Revision: 240446
URL: http://llvm.org/viewvc/llvm-project?rev=240446&view=rev
Log:
[MachO] Initialize all fields of NormalizedFile.
The ObjectFileYAML.roundTrip serializes a default-constructed
NormalizedFile to YAML, triggering uninitialized memory reads.
While there use in-class member initializers.
Modified:
lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFile.h
Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFile.h?rev=240446&r1=240445&r2=240446&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFile.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFile.h Tue Jun 23 14:55:04 2015
@@ -210,15 +210,9 @@ LLVM_YAML_STRONG_TYPEDEF(uint32_t, FileF
///
struct NormalizedFile {
- NormalizedFile() : arch(MachOLinkingContext::arch_unknown),
- fileType(llvm::MachO::MH_OBJECT),
- flags(0),
- hasUUID(false),
- os(MachOLinkingContext::OS::unknown) { }
-
- MachOLinkingContext::Arch arch;
- HeaderFileType fileType;
- FileFlags flags;
+ MachOLinkingContext::Arch arch = MachOLinkingContext::arch_unknown;
+ HeaderFileType fileType = llvm::MachO::MH_OBJECT;
+ FileFlags flags = 0;
std::vector<Segment> segments; // Not used in object files.
std::vector<Section> sections;
@@ -229,20 +223,20 @@ struct NormalizedFile {
// Maps to load commands with no LINKEDIT content (final linked images only).
std::vector<DependentDylib> dependentDylibs;
- StringRef installName; // dylibs only
- PackedVersion compatVersion; // dylibs only
- PackedVersion currentVersion; // dylibs only
- bool hasUUID;
+ StringRef installName; // dylibs only
+ PackedVersion compatVersion = 0; // dylibs only
+ PackedVersion currentVersion = 0; // dylibs only
+ bool hasUUID = false;
std::vector<StringRef> rpaths;
- Hex64 entryAddress;
- Hex64 stackSize;
- MachOLinkingContext::OS os;
- Hex64 sourceVersion;
- PackedVersion minOSverson;
- PackedVersion sdkVersion;
+ Hex64 entryAddress = 0;
+ Hex64 stackSize = 0;
+ MachOLinkingContext::OS os = MachOLinkingContext::OS::unknown;
+ Hex64 sourceVersion = 0;
+ PackedVersion minOSverson = 0;
+ PackedVersion sdkVersion = 0;
// Maps to load commands with LINKEDIT content (final linked images only).
- Hex32 pageSize;
+ Hex32 pageSize = 0;
std::vector<RebaseLocation> rebasingInfo;
std::vector<BindLocation> bindingInfo;
std::vector<BindLocation> weakBindingInfo;
More information about the llvm-commits
mailing list