diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-06-06 21:40:16 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2014-06-06 21:40:16 +0000 |
commit | e9bd916efe5766f2495e5f5599fbb53ddc08d468 (patch) | |
tree | 04e63db0d20bf5739b1ccdc2ae20457ad04c024e /llvm/lib/MC | |
parent | f7432755d0c09b8c01ced9c3b0f337a85a1ccf96 (diff) | |
download | bcm5719-llvm-e9bd916efe5766f2495e5f5599fbb53ddc08d468.tar.gz bcm5719-llvm-e9bd916efe5766f2495e5f5599fbb53ddc08d468.zip |
MC: prevent early DCE of empty sections
Prevent the early elimination of sections in the object writer. There may be
references to the section itself by other symbols, which may potentially not be
possible to resolve. ML (Visual Studio's Macro Assembler) also seems to retain
empty sections.
The elimination of symbols and sections which are unused should really occur at
the link phase. This will not cause any change in the resulting binary, simply
in the generated object files.
The adjustments to the other unit tests account for the fluctuating section
index caused by the appearance of sections which were previously discarded.
llvm-svn: 210373
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r-- | llvm/lib/MC/WinCOFFObjectWriter.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp index 6f9c73b9cc5..2d4b75858a5 100644 --- a/llvm/lib/MC/WinCOFFObjectWriter.cpp +++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp @@ -833,13 +833,9 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm, DenseMap<COFFSection *, uint16_t> SectionIndices; for (auto & Section : Sections) { - if (Layout.getSectionAddressSize(Section->MCData) > 0) { - size_t Number = ++Header.NumberOfSections; - SectionIndices[Section.get()] = Number; - MakeSectionReal(*Section, Number); - } else { - Section->Number = -1; - } + size_t Number = ++Header.NumberOfSections; + SectionIndices[Section.get()] = Number; + MakeSectionReal(*Section, Number); } Header.NumberOfSymbols = 0; |