Fix atom order

Shankar Easwaran shankare at codeaurora.org
Thu Apr 4 16:20:51 PDT 2013


Hi,

This  patch sets the atom order while each input file is being read.

This also fixes the testcase failure.

Thanks

Shankar Easwaran

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation

-------------- next part --------------
Index: lib/ReaderWriter/ELF/File.h
===================================================================
--- lib/ReaderWriter/ELF/File.h	(revision 178800)
+++ lib/ReaderWriter/ELF/File.h	(working copy)
@@ -127,6 +127,8 @@
     if (EC)
       return;
 
+    int ordinal = 0;
+
     // Point Obj to correct class and bitwidth ELF object
     _objFile.reset(
         llvm::dyn_cast<llvm::object::ELFObjectFile<ELFT> >(binaryFile.get()));
@@ -334,10 +336,11 @@
         sym->st_size = 0;
         ArrayRef<uint8_t> content((const uint8_t *)sectionContents.data(),
                                   sectionContents.size());
-        _definedAtoms._atoms.push_back(
-            new (_readerStorage)
+        auto newAtom = new (_readerStorage)
             ELFDefinedAtom<ELFT>(*this, sectionName, sectionName, sym, i.first,
-                                 content, 0, 0, _references));
+                                 content, 0, 0, _references);
+        newAtom->setOrdinal(++ordinal);
+        _definedAtoms._atoms.push_back(newAtom);
       }
 
       ELFDefinedAtom<ELFT> *previous_atom = nullptr;
@@ -410,8 +413,10 @@
           sym->setBinding(llvm::ELF::STB_GLOBAL);
           anonAtom = createDefinedAtomAndAssignRelocations(
               "", sectionName, sym, i.first,
-              ArrayRef<uint8_t>((uint8_t *)sectionContents.data() +
-                                (*si)->st_value, contentSize));
+              ArrayRef<uint8_t>(
+                  (uint8_t *)sectionContents.data() + (*si)->st_value,
+                  contentSize));
+          anonAtom->setOrdinal(++ordinal);
 
           // If this is the last atom, lets not create a followon
           // reference
@@ -454,6 +459,8 @@
         auto newAtom = createDefinedAtomAndAssignRelocations(
             symbolName, sectionName, *si, i.first, symbolData);
 
+        newAtom->setOrdinal(++ordinal);
+
         // If the atom was a weak symbol, lets create a followon
         // reference to the anonymous atom that we created
         if ((*si)->getBinding() == llvm::ELF::STB_WEAK && anonAtom) {


More information about the llvm-commits mailing list