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 | a51acc7631fec5bc371d996d7cea45e8a3caee95 (patch) | |
tree | 9740f10aef3c571fb536ee42b5446811a38d173d /lib/MC | |
parent | 0da5960e5b7473b97fbb891e0b2761d3012ba724 (diff) | |
download | llvm-a51acc7631fec5bc371d996d7cea45e8a3caee95.tar.gz llvm-a51acc7631fec5bc371d996d7cea45e8a3caee95.tar.bz2 llvm-a51acc7631fec5bc371d996d7cea45e8a3caee95.tar.xz |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210373 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/WinCOFFObjectWriter.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/lib/MC/WinCOFFObjectWriter.cpp b/lib/MC/WinCOFFObjectWriter.cpp index 6f9c73b9cc..2d4b75858a 100644 --- a/lib/MC/WinCOFFObjectWriter.cpp +++ b/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; |