[lld] r266857 - Revert "[ELF] - Avoid using memset for zero-initialization of struct member. NFC."
Sean Silva via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 19 21:26:17 PDT 2016
Author: silvas
Date: Tue Apr 19 23:26:16 2016
New Revision: 266857
URL: http://llvm.org/viewvc/llvm-project?rev=266857&view=rev
Log:
Revert "[ELF] - Avoid using memset for zero-initialization of struct member. NFC."
This reverts commit r266618. It breaks basically everything.
I think VS2013 doesn't interpret this code in the same way.
The size field (at least) is left uninitialized, causing all sorts of havok
(e.g. creating a 34GB file for a trivial hello world program).
The offending compiler reports itself as follows:
c:\release-vs2013>cl /?
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.40629 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
Modified:
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/OutputSections.h
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=266857&r1=266856&r2=266857&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Tue Apr 19 23:26:16 2016
@@ -44,6 +44,7 @@ template <class ELFT>
OutputSectionBase<ELFT>::OutputSectionBase(StringRef Name, uint32_t Type,
uintX_t Flags)
: Name(Name) {
+ memset(&Header, 0, sizeof(Elf_Shdr));
Header.sh_type = Type;
Header.sh_flags = Flags;
}
Modified: lld/trunk/ELF/OutputSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.h?rev=266857&r1=266856&r2=266857&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.h (original)
+++ lld/trunk/ELF/OutputSections.h Tue Apr 19 23:26:16 2016
@@ -97,7 +97,7 @@ public:
protected:
StringRef Name;
- Elf_Shdr Header = {};
+ Elf_Shdr Header;
};
template <class ELFT> class GotSection final : public OutputSectionBase<ELFT> {
More information about the llvm-commits
mailing list