[lld] r264116 - Move empty atom check to target independent code. NFC.

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 16:07:35 PDT 2016


Author: pete
Date: Tue Mar 22 18:07:34 2016
New Revision: 264116

URL: http://llvm.org/viewvc/llvm-project?rev=264116&view=rev
Log:
Move empty atom check to target independent code.  NFC.

Turns out that checking only x86 for empty atoms to fix UBSan then
requires the same code in the other targets too.  Better to just
check this in the main run loop instead of in each target.

Should be NFC, other than fixing UBSan failures.

Modified:
    lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp

Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp?rev=264116&r1=264115&r2=264116&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp Tue Mar 22 18:07:34 2016
@@ -420,11 +420,6 @@ void ArchHandler_x86::generateAtomConten
                                           FindAddressForAtom findSectionAddress,
                                           uint64_t imageBaseAddress,
                                           uint8_t *atomContentBuffer) {
-  if (!atom.size()) {
-    assert(atom.begin() == atom.end() &&
-           "Cannot have references without content");
-    return;
-  }
   // Copy raw bytes.
   memcpy(atomContentBuffer, atom.rawContent().data(), atom.size());
   // Apply fix-ups.

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp?rev=264116&r1=264115&r2=264116&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp Tue Mar 22 18:07:34 2016
@@ -672,6 +672,11 @@ void Util::copySectionContent(Normalized
     uint8_t *sectionContent = file.ownedAllocations.Allocate<uint8_t>(si->size);
     normSect->content = llvm::makeArrayRef(sectionContent, si->size);
     for (AtomInfo &ai : si->atomsAndOffsets) {
+      if (!ai.atom->size()) {
+        assert(ai.atom->begin() == ai.atom->end() &&
+               "Cannot have references without content");
+        continue;
+      }
       uint8_t *atomContent = reinterpret_cast<uint8_t*>
                                           (&sectionContent[ai.offsetInSection]);
       _archHandler.generateAtomContent(*ai.atom, r, addrForAtom,




More information about the llvm-commits mailing list