[ELF] fix atom order

llvm-svn: 178815
This commit is contained in:
Shankar Easwaran 2013-04-04 23:51:36 +00:00
parent e3377fbca2
commit d953d66ee9
1 changed files with 12 additions and 5 deletions

View File

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